Fixing some typos errors with the Mimos import.  If this broke something, let me know.

getconfig needs to use the zoni version and not tashi.  Need to merge these two.
adding the dhcpdns changes from tashi.  Need to merge.



git-svn-id: https://svn.apache.org/repos/asf/incubator/tashi/trunk@1430318 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/zoni/agents/dhcpdns.py b/src/zoni/agents/dhcpdns.py
index 48cc2b7..c2fd500 100644
--- a/src/zoni/agents/dhcpdns.py
+++ b/src/zoni/agents/dhcpdns.py
@@ -131,7 +131,7 @@
 				ipSegments = map(int, ip.split("."))
 				ipSegments.reverse()
 				reverseIpStr = ("%d.%d.%d.%d.in-addr.arpa" % (ipSegments[0], ipSegments[1], ipSegments[2], ipSegments[3]))
-				stdin.write("update add %s %d IN PTR %s.%s.\n" % (reverseIpStr, self.dnsExpire, name, self.dnsDomain))
+				stdin.write("update add %s %d IN PTR %s.\n" % (reverseIpStr, self.dnsExpire, name))
 				stdin.write("\n")
 			stdin.close()
 			output = stdout.read()
@@ -153,7 +153,7 @@
 			(stdin, stdout) = (child.stdin, child.stdout)
 			stdin.write("server %s\n" % (self.dnsServer))
 			stdin.write("key %s %s\n" % (self.dnsKeyName, self.dnsSecretKey))
-			stdin.write("update delete %s.%s A\n" % (name, self.dnsDomain))
+			stdin.write("update delete %s A\n" % (name))
 			stdin.write("\n")
 			if (self.reverseDns):
 				hostInfo = socket.gethostbyaddr(name)
@@ -190,7 +190,7 @@
 			(stdin, stdout) = (child.stdin, child.stdout)
 			stdin.write("server %s\n" % (self.dnsServer))
 			stdin.write("key %s %s\n" % (self.dnsKeyName, self.dnsSecretKey))
-			stdin.write("update add %s.%s %d CNAME %s.%s\n" % (name, self.dnsDomain, self.dnsExpire, hostName, self.dnsDomain))
+			stdin.write("update add %s %d CNAME %s\n" % (name, self.dnsExpire, hostInfo[0]))
 			stdin.write("\n")
 			stdin.close()
 			output = stdout.read()
@@ -211,10 +211,11 @@
 		cmd = "nsupdate"
 		child = subprocess.Popen(args=cmd.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE)
 		try:
+			hostInfo = socket.gethostbyaddr(name)[0]
 			(stdin, stdout) = (child.stdin, child.stdout)
 			stdin.write("server %s\n" % (self.dnsServer))
 			stdin.write("key %s %s\n" % (self.dnsKeyName, self.dnsSecretKey))
-			stdin.write("update delete %s.%s CNAME\n" % (name, self.dnsDomain))
+			stdin.write("update delete %s CNAME\n" % (name))
 			stdin.write("\n")
 			stdin.close()
 			output = stdout.read()
@@ -235,6 +236,18 @@
 		newInstance.nics = instance.nics
 		self.client.vmUpdate(instance.id, newInstance, None)
 
+
+	def getFqdn(self, instance):
+			domainName = self.dnsDomain
+			subDomain = instance.hints.get("subDomain", None)
+			if subDomain != None:
+					domainName = "%s.%s" % (subDomain, self.dnsDomain)
+
+			fqdn = "%s.%s" % (instance.name, domainName)
+
+			return fqdn
+
+
 	def preCreate(self, instance):
 		if (len(instance.nics) < 1):
 			return
@@ -244,8 +257,8 @@
 			nic.ip = ip
 			try:
 				if (i == 0):
-					self.log.info("Adding %s:{%s->%s} to DNS" % (instance.name, instance.name, ip))
-					self.addDns(instance.name, ip)
+					self.log.info("Adding %s:{%s->%s} to DNS" % (instance.name, self.getFqdn(instance), ip))
+					self.addDns(self.getFqdn(instance), ip)
 				if (i == 0):
 					dhcpName = instance.name
 				else:
@@ -277,6 +290,6 @@
 			except Exception, e:
 				self.log.exception("Failed to remove host %s from DHCP" % (instance.name))
 		try:
-			self.removeDns(instance.name)
+			self.removeDns(self.getFqdn(instance))
 		except Exception, e:
 			self.log.exception("Failed to remove host %s from DNS" % (instance.name))
diff --git a/src/zoni/client/zoni-cli.py b/src/zoni/client/zoni-cli.py
index 9ddf52f..709b244 100755
--- a/src/zoni/client/zoni-cli.py
+++ b/src/zoni/client/zoni-cli.py
@@ -46,10 +46,10 @@
 from zoni.data import usermanagement
 from zoni.agents.dhcpdns import DhcpDns
 
-from zoni.extra.util import validIp, validMac 
+from zoni.extra.util import validIp, validMac, getConfig
 from zoni.version import version, revision
 
-from tashi.util import instantiateImplementation, getConfig
+from tashi.util import instantiateImplementation
 #import zoni.data.usermanagement 
 #from usermanagement import UserManagement
 
@@ -65,7 +65,6 @@
 	rev = revision
 
 	(configs, configFiles) = getConfig()
-
 	logging.config.fileConfig(configFiles)
 	#log = logging.getLogger(os.path.basename(__file__))
 	#logit(configs['logFile'], "Starting Zoni client")
diff --git a/src/zoni/data/resourcequerysql.py b/src/zoni/data/resourcequerysql.py
index 1bde24f..700dbd9 100644
--- a/src/zoni/data/resourcequerysql.py
+++ b/src/zoni/data/resourcequerysql.py
@@ -33,7 +33,7 @@
 class ResourceQuerySql(InfoStore):
 	def __init__(self, config, verbose=None):
 		self.config = config
-		self.verbose  = verbose
+		self.verbose = verbose
 		self.host = config['dbHost']
 		self.user = config['dbUser']
 		self.passwd = config['dbPassword']
diff --git a/src/zoni/extensions/m_extensions.py b/src/zoni/extensions/m_extensions.py
index de5c578..4693126 100644
--- a/src/zoni/extensions/m_extensions.py
+++ b/src/zoni/extensions/m_extensions.py
@@ -70,11 +70,11 @@
 		return
 
 	def getDestFile(self, configs, host):
-		therole = ("%s/01-%s" % (configs['tftpImageDir'], (host['mac_addr']).replace(":", "-").lower())
+		therole = ("%s/01-%s" % (configs['tftpImageDir'], (host['mac_addr']).replace(":", "-").lower()))
 		return therole
 
 	def addRoletoNode(self, configs, host, thenode, roletemplate):
-		therole = ("%s/01-%s" % (configs['tftpImageDir'], (host['mac_addr']).replace(":", "-").lower())
+		therole = ("%s/01-%s" % (configs['tftpImageDir'], (host['mac_addr']).replace(":", "-").lower()))
 		self.log.info("Roles: addRole for %s" % thenode)
 		srctpl = "%s/%s" % (configs['tftpTemplateDir'], roletemplate)
 		if os.path.isfile(therole):
@@ -106,7 +106,7 @@
 		return 0
 
 	def removeRolefromNode(self, configs, host, thenode):
-		therole = ("%s/01-%s" % (configs['tftpImageDir'], (host['mac_addr']).replace(":", "-").lower())
+		therole = ("%s/01-%s" % (configs['tftpImageDir'], (host['mac_addr']).replace(":", "-").lower()))
 		self.log.info("Roles: removeRole for %s" % thenode)
 		if not os.path.isfile(therole):
 			mesg = "No Role File for %s! Exiting!" % thenode
diff --git a/src/zoni/install/db/zoniDbSetup.py b/src/zoni/install/db/zoniDbSetup.py
index 5049046..0bb937c 100644
--- a/src/zoni/install/db/zoniDbSetup.py
+++ b/src/zoni/install/db/zoniDbSetup.py
@@ -83,7 +83,7 @@
 
 	try:
 		conn = connectDb(host, port, adminUser, adminPassword)
-	except e:
+	except Exception, e:
 		print "error here ", e
 		exit()
 	createDatabase(conn, adminUser, adminPassword, db)