Allow dumping of VMs
This commit is contained in:
		| @@ -385,6 +385,28 @@ def vm_undefine(domain): | ||||
|     retcode, retmsg = pvc_vm.undefine_vm(zk_conn, domain) | ||||
|     cleanup(retcode, retmsg, zk_conn) | ||||
|  | ||||
| ############################################################################### | ||||
| # pvc vm dump | ||||
| ############################################################################### | ||||
| @click.command(name='dump', short_help='Dump a virtual machine XML to stdout.') | ||||
| @click.argument( | ||||
|     'domain' | ||||
| ) | ||||
| def vm_dump(domain): | ||||
|     """ | ||||
|     Dump the Libvirt XML definition of virtual machine DOMAIN to stdout. DOMAIN may be a UUID or name. | ||||
|     """ | ||||
|  | ||||
|     # Ensure at least one search method is set | ||||
|     if domain == None: | ||||
|         click.echo("ERROR: You must specify either a name or UUID value.") | ||||
|         exit(1) | ||||
|  | ||||
|     # Open a Zookeeper connection | ||||
|     zk_conn = pvc_common.startZKConnection(zk_host) | ||||
|     retcode, retmsg = pvc_vm.dump_vm(zk_conn, domain) | ||||
|     cleanup(retcode, retmsg, zk_conn) | ||||
|  | ||||
| ############################################################################### | ||||
| # pvc vm start | ||||
| ############################################################################### | ||||
| @@ -1280,6 +1302,7 @@ cli_vm.add_command(vm_add) | ||||
| cli_vm.add_command(vm_define) | ||||
| cli_vm.add_command(vm_modify) | ||||
| cli_vm.add_command(vm_undefine) | ||||
| cli_vm.add_command(vm_dump) | ||||
| cli_vm.add_command(vm_start) | ||||
| cli_vm.add_command(vm_restart) | ||||
| cli_vm.add_command(vm_shutdown) | ||||
|   | ||||
| @@ -248,6 +248,17 @@ def modify_vm(zk_conn, domain, restart, new_vm_config): | ||||
|  | ||||
|     return True, '' | ||||
|  | ||||
| def dump_vm(zk_conn, domain): | ||||
|     dom_uuid = getDomainUUID(zk_conn, domain) | ||||
|     if dom_uuid == None: | ||||
|         return False, 'ERROR: Could not find VM "{}" in the cluster!'.format(domain) | ||||
|  | ||||
|     # Gram the domain XML and dump it to stdout | ||||
|     vm_xml = zkhandler.readdata(zk_conn, '/domains/{}/xml'.format(dom_uuid)) | ||||
|     click.echo(vm_xml) | ||||
|  | ||||
|     return True, '' | ||||
|  | ||||
| def undefine_vm(zk_conn, domain): | ||||
|     # Validate and obtain alternate passed value | ||||
|     dom_uuid = getDomainUUID(zk_conn, domain) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user