Fix some bugs
This commit is contained in:
parent
1a72ee6414
commit
c0c84036c3
|
@ -78,6 +78,7 @@ class NodeInstance(threading.Thread):
|
|||
transaction = self.zk.transaction()
|
||||
transaction.set_data('/domains/' + domain + '/state', 'migrate'.encode('ascii'))
|
||||
transaction.set_data('/domains/' + domain + '/hypervisor', least_host.encode('ascii'))
|
||||
transaction.set_data('/domains/' + domain + '/flushedhypervisor', self.name.encode('ascii'))
|
||||
transaction.commit()
|
||||
|
||||
# Wait 1s between migrations
|
||||
|
@ -100,12 +101,18 @@ class NodeInstance(threading.Thread):
|
|||
# Gather data about hypervisor
|
||||
self.name = conn.getHostname()
|
||||
self.cpucount = conn.getCPUMap()[0]
|
||||
self.state = 'start'
|
||||
self.zk.set(self.zkey + '/state', 'start'.encode('ascii'))
|
||||
self.zk.set(self.zkey + '/cpucount', str(self.cpucount).encode('ascii'))
|
||||
print("Node hostname: %s" % self.name)
|
||||
print("CPUs: %s" % self.cpucount)
|
||||
|
||||
# Get past state and update if needed
|
||||
past_state = self.zk.get(self.zkey + '/state')[0].decode('ascii')
|
||||
if past_state != 'flush':
|
||||
self.state = 'start'
|
||||
self.zk.set(self.zkey + '/state', 'start'.encode('ascii'))
|
||||
else:
|
||||
self.state = 'flush'
|
||||
|
||||
while True:
|
||||
# Toggle state management of all VMs
|
||||
for domain, instance in self.s_domain.items():
|
||||
|
@ -152,7 +159,6 @@ class NodeInstance(threading.Thread):
|
|||
active_node_list.append(node_name)
|
||||
elif node_state == 'flush':
|
||||
flushed_node_list.append(node_name)
|
||||
self.flush()
|
||||
else:
|
||||
inactive_node_list.append(node_name)
|
||||
|
||||
|
@ -160,6 +166,12 @@ class NodeInstance(threading.Thread):
|
|||
print('Flushed nodes: %s' % flushed_node_list)
|
||||
print('Inactive nodes: %s' % inactive_node_list)
|
||||
|
||||
# Do any actions my node requires
|
||||
if self.state == 'flush':
|
||||
self.flush()
|
||||
elif self.state == 'unflush':
|
||||
self.unflush()
|
||||
|
||||
# Sleep for 10s but with quick interruptability
|
||||
for x in range(0,100):
|
||||
time.sleep(0.1)
|
||||
|
|
Loading…
Reference in New Issue