incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mry...@apache.org
Subject svn commit: r750130 - /incubator/tashi/trunk/src/tashi/client/tashi-client.py
Date Wed, 04 Mar 2009 19:59:49 GMT
Author: mryan3
Date: Wed Mar  4 19:59:49 2009
New Revision: 750130

URL: http://svn.apache.org/viewvc?rev=750130&view=rev
Log:
tashi-client update to use the network labled "default" if none is given and to generate a
mac address for a NIC if it is missing.


Modified:
    incubator/tashi/trunk/src/tashi/client/tashi-client.py

Modified: incubator/tashi/trunk/src/tashi/client/tashi-client.py
URL: http://svn.apache.org/viewvc/incubator/tashi/trunk/src/tashi/client/tashi-client.py?rev=750130&r1=750129&r2=750130&view=diff
==============================================================================
--- incubator/tashi/trunk/src/tashi/client/tashi-client.py (original)
+++ incubator/tashi/trunk/src/tashi/client/tashi-client.py Wed Mar  4 19:59:49 2009
@@ -30,6 +30,7 @@
 from tashi import vmStates, hostStates, boolean, getConfig, stringPartition, createClient
 
 users = {}
+networks = {}
 
 def fetchUsers():
 	if (users == {}):
@@ -37,6 +38,12 @@
 		for user in _users:
 			users[user.id] = user
 
+def fetchNetworks():
+	if (networks == {}):
+		_networks = client.getNetworks()
+		for network in _networks:
+			networks[network.id] = network
+
 def getUser():
 	fetchUsers()
 	userStr = os.getenv("USER", "unknown")
@@ -70,7 +77,12 @@
 	return ("52:54:00:%2.2x:%2.2x:%2.2x" % (random.randint(0, 255), random.randint(0, 255),
random.randint(0, 255)))
 
 def randomNetwork():
-	return [NetworkConfiguration(d={'mac':randomMac(), 'network':1})]
+	fetchNetworks()
+	networkId = 1
+	for network in networks:
+		if (networks[network].name == "default"):
+			networkId = network
+	return [NetworkConfiguration(d={'mac':randomMac(), 'network':networkId})]
 
 def parseDisks(arg):
 	try:
@@ -96,6 +108,8 @@
 			strNic = strNic.strip()
 			(l, s, r) = stringPartition(strNic, ":")
 			l = int(l)
+			if (r==''):
+				r = randomMac()
 			nic = NetworkConfiguration(d={'mac':r, 'network':l})
 			nics.append(nic)
 		return nics



Mime
View raw message