Currently if the cluster manager returns an unknown state for hosts or
VMs, the client throws an exception in transformState. Confusingly
(for the user), the client program does not print a list of hosts/VMs,
or an exception message; it just prints "0". This patch for the
client translates all unknown states to the word "Unknown" so the
client can print meaningful output even when the CM is returning bad
states.
I came across this problem when I initialized the database using a
shell script, and gave all of the hosts the state value "0".
diff -r df032a7eba18 trunk/src/tashi/client/tashi-client.py
--- a/trunk/src/tashi/client/tashi-client.py Tue Jul 07 14:01:11
2009 -0400
+++ b/trunk/src/tashi/client/tashi-client.py Tue Jul 07 15:01:36
2009 -0400
@@ -319,7 +319,10 @@
def transformState(obj):
if (type(obj) == Instance):
fetchUsers()
- obj.state = vmStates[obj.state]
+ try:
+ obj.state = vmStates[obj.state]
+ except:
+ obj.state = 'Unknown'
if (obj.userId in users):
obj.user = users[obj.userId].name
else:
@@ -328,7 +331,10 @@
if (obj.disks[0].persistent):
obj.disk += ":True"
elif (type(obj) == Host):
- obj.state = hostStates[obj.state]
+ try:
+ obj.state = hostStates[obj.state]
+ except:
+ obj.state = 'Unknown'
def genKeys(list):
keys = {}