incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rg...@apache.org
Subject svn commit: r1430318 - in /incubator/tashi/trunk/src/zoni: agents/dhcpdns.py client/zoni-cli.py data/resourcequerysql.py extensions/m_extensions.py install/db/zoniDbSetup.py
Date Tue, 08 Jan 2013 15:13:59 GMT
Author: rgass
Date: Tue Jan  8 15:13:59 2013
New Revision: 1430318

URL: http://svn.apache.org/viewvc?rev=1430318&view=rev
Log:
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.


Modified:
    incubator/tashi/trunk/src/zoni/agents/dhcpdns.py
    incubator/tashi/trunk/src/zoni/client/zoni-cli.py
    incubator/tashi/trunk/src/zoni/data/resourcequerysql.py
    incubator/tashi/trunk/src/zoni/extensions/m_extensions.py
    incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py

Modified: incubator/tashi/trunk/src/zoni/agents/dhcpdns.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/agents/dhcpdns.py?rev=1430318&r1=1430317&r2=1430318&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/agents/dhcpdns.py (original)
+++ incubator/tashi/trunk/src/zoni/agents/dhcpdns.py Tue Jan  8 15:13:59 2013
@@ -131,7 +131,7 @@ class DhcpDns():
 				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 @@ class DhcpDns():
 			(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 @@ class DhcpDns():
 			(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 @@ class DhcpDns():
 		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 @@ class DhcpDns():
 		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 @@ class DhcpDns():
 			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 @@ class DhcpDns():
 			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))

Modified: incubator/tashi/trunk/src/zoni/client/zoni-cli.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/client/zoni-cli.py?rev=1430318&r1=1430317&r2=1430318&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/client/zoni-cli.py (original)
+++ incubator/tashi/trunk/src/zoni/client/zoni-cli.py Tue Jan  8 15:13:59 2013
@@ -46,10 +46,10 @@ import zoni.hardware.systemmanagement
 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 @@ def main():
 	rev = revision
 
 	(configs, configFiles) = getConfig()
-
 	logging.config.fileConfig(configFiles)
 	#log = logging.getLogger(os.path.basename(__file__))
 	#logit(configs['logFile'], "Starting Zoni client")

Modified: incubator/tashi/trunk/src/zoni/data/resourcequerysql.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/data/resourcequerysql.py?rev=1430318&r1=1430317&r2=1430318&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/data/resourcequerysql.py (original)
+++ incubator/tashi/trunk/src/zoni/data/resourcequerysql.py Tue Jan  8 15:13:59 2013
@@ -33,7 +33,7 @@ from zoni.extra.util import createKey
 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']

Modified: incubator/tashi/trunk/src/zoni/extensions/m_extensions.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/extensions/m_extensions.py?rev=1430318&r1=1430317&r2=1430318&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/extensions/m_extensions.py (original)
+++ incubator/tashi/trunk/src/zoni/extensions/m_extensions.py Tue Jan  8 15:13:59 2013
@@ -70,11 +70,11 @@ class mimos(InfoStore):
 		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 @@ class mimos(InfoStore):
 		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

Modified: incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py?rev=1430318&r1=1430317&r2=1430318&view=diff
==============================================================================
--- incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py (original)
+++ incubator/tashi/trunk/src/zoni/install/db/zoniDbSetup.py Tue Jan  8 15:13:59 2013
@@ -83,7 +83,7 @@ def CreateZoniDb(config, adminUser, admi
 
 	try:
 		conn = connectDb(host, port, adminUser, adminPassword)
-	except e:
+	except Exception, e:
 		print "error here ", e
 		exit()
 	createDatabase(conn, adminUser, adminPassword, db)



Mime
View raw message