Fix up creating empty node entry
This commit is contained in:
parent
26a460c438
commit
16613d900e
|
@ -40,7 +40,7 @@ class NodeInstance(threading.Thread):
|
||||||
least_mem = node_freemem
|
least_mem = node_freemem
|
||||||
least_host = node.getname()
|
least_host = node.getname()
|
||||||
|
|
||||||
self.zk.set('/domains/' + domain + '/state', b'migrate')
|
self.zk.set('/domains/' + domain + '/state', 'flush'.encode('ascii'))
|
||||||
self.zk.set('/domains/' + domain + '/hypervisor', least_host.encode('ascii'))
|
self.zk.set('/domains/' + domain + '/hypervisor', least_host.encode('ascii'))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -60,7 +60,7 @@ class NodeInstance(threading.Thread):
|
||||||
# Gather data about hypervisor
|
# Gather data about hypervisor
|
||||||
self.name = conn.getHostname()
|
self.name = conn.getHostname()
|
||||||
self.cpucount = conn.getCPUMap()[0]
|
self.cpucount = conn.getCPUMap()[0]
|
||||||
self.zk.set(self.zkey + '/state', self.name.encode('ascii'))
|
self.zk.set(self.zkey + '/state', 'start'.encode('ascii'))
|
||||||
self.zk.set(self.zkey + '/cpucount', str(self.cpucount).encode('ascii'))
|
self.zk.set(self.zkey + '/cpucount', str(self.cpucount).encode('ascii'))
|
||||||
print("Node hostname: %s" % self.name)
|
print("Node hostname: %s" % self.name)
|
||||||
print("CPUs: %s" % self.cpucount)
|
print("CPUs: %s" % self.cpucount)
|
||||||
|
|
13
pvcd.py
13
pvcd.py
|
@ -48,6 +48,17 @@ def cleanup():
|
||||||
|
|
||||||
atexit.register(cleanup)
|
atexit.register(cleanup)
|
||||||
|
|
||||||
|
# Check if our node exists in Zookeeper, and create it if not
|
||||||
|
mynodestring = '/nodes/%s' % myhostname
|
||||||
|
if not zk.exists('%s' + mynodestring):
|
||||||
|
zk.create('%s' % mynodestring, 'hypervisor'.encode('ascii'))
|
||||||
|
zk.create('%s/state' % mynodestring, 'stop'.encode('ascii'))
|
||||||
|
zk.create('%s/cpucount' % mynodestring, '0'.encode('ascii'))
|
||||||
|
zk.create('%s/memfree' % mynodestring, '0'.encode('ascii'))
|
||||||
|
zk.create('%s/cpuload' % mynodestring, '0.0'.encode('ascii'))
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
node_list = zk.get_children('/nodes')
|
node_list = zk.get_children('/nodes')
|
||||||
print(node_list)
|
print(node_list)
|
||||||
|
|
||||||
|
@ -62,6 +73,8 @@ for node in node_list:
|
||||||
if t_node[node].name == myhostname:
|
if t_node[node].name == myhostname:
|
||||||
t_node[node].start()
|
t_node[node].start()
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
for domain in domain_list:
|
for domain in domain_list:
|
||||||
s_domain[domain] = VMInstance.VMInstance(domain, zk, t_node[myhostname]);
|
s_domain[domain] = VMInstance.VMInstance(domain, zk, t_node[myhostname]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue