diff --git a/pvc.py b/pvc.py index 7350d873..5d966d33 100755 --- a/pvc.py +++ b/pvc.py @@ -573,6 +573,20 @@ def search(dom_name, dom_uuid, long_output): pvcf.stopZKConnection(zk) +############################################################################### +# pvc list +############################################################################### +@click.command(name='vlist', short_help='List all VM objects') +def vlist(): + """ + List all virtual machines in the cluster. + """ + + zk = pvcf.startZKConnection(zk_host) + for vm in zk.get_children('/domains'): + print(vm) + + ############################################################################### # pvc init ############################################################################### @@ -643,6 +657,7 @@ vm.add_command(unmigrate_vm) cli.add_command(node) cli.add_command(vm) cli.add_command(search) +cli.add_command(vlist) cli.add_command(init_cluster) # diff --git a/pvcd.py b/pvcd.py index 53e8c152..6b9341cb 100755 --- a/pvcd.py +++ b/pvcd.py @@ -97,18 +97,18 @@ if zk.exists('/nodes/{}'.format(myhostname)): else: print("Node is " + ansiiprint.red() + "absent" + ansiiprint.end() + " in Zookeeper; adding new node") keepalive_time = int(time.time()) - zk.create('/domains/{}'.format(myhostname), 'hypervisor'.encode('ascii')) + zk.create('/nodes/{}'.format(myhostname), 'hypervisor'.encode('ascii')) # Basic state information - zk.create('/domains/{}/state'.format(myhostname), 'stop'.encode('ascii')) - zk.create('/domains/{}/cpucount'.format(myhostname), '0'.encode('ascii')) - zk.create('/domains/{}/memfree'.format(myhostname), '0'.encode('ascii')) - zk.create('/domains/{}/cpuload'.format(myhostname), '0.0'.encode('ascii')) - zk.create('/domains/{}/runningdomains'.format(myhostname), ''.encode('ascii')) + zk.create('/nodes/{}/state'.format(myhostname), 'stop'.encode('ascii')) + zk.create('/nodes/{}/cpucount'.format(myhostname), '0'.encode('ascii')) + zk.create('/nodes/{}/memfree'.format(myhostname), '0'.encode('ascii')) + zk.create('/nodes/{}/cpuload'.format(myhostname), '0.0'.encode('ascii')) + zk.create('/nodes/{}/runningdomains'.format(myhostname), ''.encode('ascii')) # Keepalives and fencing information - zk.create('/domains/{}/keepalive'.format(myhostname), str(keepalive_time).encode('ascii')) - zk.create('/domains/{}/ipmihostname'.format(config['ipmi_hostname']), ''.encode('ascii')) - zk.create('/domains/{}/ipmiusername'.format(config['ipmi_username']), ''.encode('ascii')) - zk.create('/domains/{}/ipmipassword'.format(config['ipmi_password']), ''.encode('ascii')) + zk.create('/nodes/{}/keepalive'.format(myhostname), str(keepalive_time).encode('ascii')) + zk.create('/nodes/{}/ipmihostname'.format(myhostname), config['ipmi_hostname'].encode('ascii')) + zk.create('/nodes/{}/ipmiusername'.format(myhostname), config['ipmi_username'].encode('ascii')) + zk.create('/nodes/{}/ipmipassword'.format(myhostname), config['ipmi_password'].encode('ascii')) t_node = dict() s_domain = dict()