Add unflush function

This commit is contained in:
Joshua Boniface 2018-06-04 03:09:51 -04:00
parent 4d767d11c0
commit e4b866bda5
1 changed files with 16 additions and 0 deletions

View File

@ -90,6 +90,22 @@ class NodeInstance(threading.Thread):
# Wait 1s between migrations # Wait 1s between migrations
time.sleep(1) time.sleep(1)
def unflush(self):
print('>>> Restoring node %s to active service' % self.name)
for domain in self.s_domain:
former_hypervisor = self.zk.get("/domains/" + domain + '/formerhypervisor').decode('ascii')
if former_hypervisor = self.name:
print(">>> Setting unmigration for %s" % domain)
transaction = self.zk.transaction()
transaction.set_data('/domains/' + domain + '/state', 'migrate'.encode('ascii'))
transaction.set_data('/domains/' + domain + '/hypervisor', self.name.encode('ascii'))
result = transaction.commit()
# Wait 1s between migrations
time.sleep(1)
self.zk.set("/nodes/" + self.name + "/state", 'start'.encode('ascii'))
def run(self): def run(self):
if self.name == socket.gethostname(): if self.name == socket.gethostname():
self.setup_local_node() self.setup_local_node()