mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
All the vms stuff was wrong, so I fixed it, still needs testing
This commit is contained in:
parent
23456cd212
commit
d21aa7a3b5
@ -35,6 +35,13 @@ def __get_conn():
|
|||||||
# all vm layers supported by libvirt
|
# all vm layers supported by libvirt
|
||||||
return libvirt.open("qemu:///system")
|
return libvirt.open("qemu:///system")
|
||||||
|
|
||||||
|
def _get_dom(vm):
|
||||||
|
'''
|
||||||
|
Return a domain object for the named vm
|
||||||
|
'''
|
||||||
|
conn = __get_con()
|
||||||
|
return conn.lookupByName(vm)
|
||||||
|
|
||||||
def list_vms():
|
def list_vms():
|
||||||
'''
|
'''
|
||||||
Return a list of virtual machine names on the minion
|
Return a list of virtual machine names on the minion
|
||||||
@ -120,8 +127,8 @@ def shutdown(vm):
|
|||||||
CLI Example:
|
CLI Example:
|
||||||
salt '*' libvirt.shutdown <vm name>
|
salt '*' libvirt.shutdown <vm name>
|
||||||
'''
|
'''
|
||||||
conn = __get_conn()
|
dom = _get_dom(vm)
|
||||||
conn.shutdown(vm)
|
dom.shutdown()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def pause(vm):
|
def pause(vm):
|
||||||
@ -131,8 +138,8 @@ def pause(vm):
|
|||||||
CLI Example:
|
CLI Example:
|
||||||
salt '*' libvirt.pause <vm name>
|
salt '*' libvirt.pause <vm name>
|
||||||
'''
|
'''
|
||||||
conn = __get_conn()
|
dom = _get_dom(vm)
|
||||||
conn.suspend(vm)
|
dom.suspend()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def unpause(vm):
|
def unpause(vm):
|
||||||
@ -142,8 +149,8 @@ def unpause(vm):
|
|||||||
CLI Example:
|
CLI Example:
|
||||||
salt '*' libvirt.unpause <vm name>
|
salt '*' libvirt.unpause <vm name>
|
||||||
'''
|
'''
|
||||||
conn = __get_conn()
|
dom = _get_dom(vm)
|
||||||
conn.resume(vm)
|
dom.unpause()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def create(vm):
|
def create(vm):
|
||||||
@ -153,8 +160,8 @@ def create(vm):
|
|||||||
CLI Example:
|
CLI Example:
|
||||||
salt '*' libvirt.create <vm name>
|
salt '*' libvirt.create <vm name>
|
||||||
'''
|
'''
|
||||||
conn = __get_conn()
|
dom = _get_dom(vm)
|
||||||
conn.create(vm)
|
dom.create()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def create_xml_str(xml):
|
def create_xml_str(xml):
|
||||||
@ -187,7 +194,19 @@ def destroy(vm):
|
|||||||
CLI Example:
|
CLI Example:
|
||||||
salt '*' libvirt.destroy <vm name>
|
salt '*' libvirt.destroy <vm name>
|
||||||
'''
|
'''
|
||||||
conn = __get_conn()
|
dom = _get_dom(vm)
|
||||||
conn.destroy(vm)
|
dom.destroy()
|
||||||
|
return True
|
||||||
|
|
||||||
|
def undefine(vm):
|
||||||
|
'''
|
||||||
|
Remove a defined vm, this does not purge the virtual machine image, and
|
||||||
|
this only works if the vm is powered down
|
||||||
|
|
||||||
|
CLI Example:
|
||||||
|
salt '*' libvirt.undefine <vm name>
|
||||||
|
'''
|
||||||
|
dom = _get_dom(vm)
|
||||||
|
dom.undefine()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user