salt.modules.smartos_vmadm

Module for running vmadm command on SmartOS

salt.modules.smartos_vmadm.create(from_file=None, **kwargs)

Create a new vm

from_file : string
json file to create the vm from -- if present, all other options will be ignored
kwargs : string|int|...
options to set for the vm

CLI 范例:

salt '*' vmadm.create from_file=/tmp/new_vm.json
salt '*' vmadm.create image_uuid='...' alias='...' nics='[{ "nic_tag": "admin", "ip": "198.51.100.123", ...}, {...}]' [...]
salt.modules.smartos_vmadm.create_snapshot(vm, name, key='uuid')

Create snapshot of a vm

vm : string
vm to be targetted
name : string
snapshot name
The snapname must be 64 characters or less and must only contain alphanumeric characters and characters in the set [-_.:%] to comply with ZFS restrictions.
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.create_snapshot 186da9ab-7392-4f55-91a5-b8f1fe770543 baseline
salt '*' vmadm.create_snapshot nacl baseline key=alias
salt.modules.smartos_vmadm.delete(vm, key='uuid')

Delete a vm

vm : string
vm to be deleted
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.delete 186da9ab-7392-4f55-91a5-b8f1fe770543
salt '*' vmadm.delete nacl key=alias
salt.modules.smartos_vmadm.delete_snapshot(vm, name, key='uuid')

Delete snapshot of a vm

vm : string
vm to be targetted
name : string
snapshot name
The snapname must be 64 characters or less and must only contain alphanumeric characters and characters in the set [-_.:%] to comply with ZFS restrictions.
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.delete_snapshot 186da9ab-7392-4f55-91a5-b8f1fe770543 baseline
salt '*' vmadm.delete_snapshot nacl baseline key=alias
salt.modules.smartos_vmadm.get(vm, key='uuid')

Output the JSON object describing a VM

vm : string
vm to be targetted
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.get 186da9ab-7392-4f55-91a5-b8f1fe770543
salt '*' vmadm.get nacl key=alias
salt.modules.smartos_vmadm.info(vm, info_type='all', key='uuid')

Lookup info on running kvm

vm : string
vm to be targetted
info_type : string [all|block|blockstats|chardev|cpus|kvm|pci|spice|version|vnc]
info type to return
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.info 186da9ab-7392-4f55-91a5-b8f1fe770543
salt '*' vmadm.info 186da9ab-7392-4f55-91a5-b8f1fe770543 vnc
salt '*' vmadm.info nacl key=alias
salt '*' vmadm.info nacl vnc key=alias
salt.modules.smartos_vmadm.list(search=None, sort=None, order='uuid, type, ram, state, alias', keyed=True)

Return a list of VMs

search : string
vmadm filter property
sort : string
vmadm sort (-s) property
order : string
vmadm order (-o) property -- Default: uuid,type,ram,state,alias
keyed : boolean
specified if the output should be an array (False) or dict (True)
For a dict the key is the first item from the order parameter. Note: If key is not unique last vm wins.

CLI 范例:

salt '*' vmadm.list
salt '*' vmadm.list order=alias,ram,cpu_cap sort=-ram,-cpu_cap
salt '*' vmadm.list search='type=KVM'
salt.modules.smartos_vmadm.lookup(search=None, order=None, one=False)

Return a list of VMs using lookup

search : string
vmadm filter property
order : string
vmadm order (-o) property -- Default: uuid,type,ram,state,alias
one : boolean
return only one result (vmadm's -1)

CLI 范例:

salt '*' vmadm.lookup search='state=running'
salt '*' vmadm.lookup search='state=running' order=uuid,alias,hostname
salt '*' vmadm.lookup search='alias=nacl' one=True
salt.modules.smartos_vmadm.reboot(vm, force=False, key='uuid')

Reboot a vm

vm : string
vm to be rebooted
force : boolean
force reboot of vm if true
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.reboot 186da9ab-7392-4f55-91a5-b8f1fe770543
salt '*' vmadm.reboot 186da9ab-7392-4f55-91a5-b8f1fe770543 True
salt '*' vmadm.reboot vm=nacl key=alias
salt '*' vmadm.reboot vm=nina.example.org key=hostname
salt.modules.smartos_vmadm.receive(uuid, source)

Receive a vm from a directory

uuid : string
uuid of vm to be received
source : string
source directory

CLI 范例:

salt '*' vmadm.receive 186da9ab-7392-4f55-91a5-b8f1fe770543 /opt/backups
salt.modules.smartos_vmadm.reprovision(vm, image, key='uuid')

Reprovision a vm

vm : string
vm to be reprovisioned
image : string
uuid of new image
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.reprovision 186da9ab-7392-4f55-91a5-b8f1fe770543 c02a2044-c1bd-11e4-bd8c-dfc1db8b0182
salt '*' vmadm.reprovision nacl c02a2044-c1bd-11e4-bd8c-dfc1db8b0182 key=alias
salt.modules.smartos_vmadm.rollback_snapshot(vm, name, key='uuid')

Rollback snapshot of a vm

vm : string
vm to be targetted
name : string
snapshot name
The snapname must be 64 characters or less and must only contain alphanumeric characters and characters in the set [-_.:%] to comply with ZFS restrictions.
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.rollback_snapshot 186da9ab-7392-4f55-91a5-b8f1fe770543 baseline
salt '*' vmadm.rollback_snapshot nacl baseline key=alias
salt.modules.smartos_vmadm.send(vm, target, key='uuid')

Send a vm to a directory

vm : string
vm to be sent
target : string
target directory
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.send 186da9ab-7392-4f55-91a5-b8f1fe770543 /opt/backups
salt '*' vmadm.send vm=nacl target=/opt/backups key=alias
salt.modules.smartos_vmadm.start(vm, options=None, key='uuid')

Start a vm

vm : string
vm to be started
options : string
optional additional options
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.start 186da9ab-7392-4f55-91a5-b8f1fe770543
salt '*' vmadm.start 186da9ab-7392-4f55-91a5-b8f1fe770543 'order=c,once=d cdrom=/path/to/image.iso,ide'
salt '*' vmadm.start vm=nacl key=alias
salt '*' vmadm.start vm=nina.example.org key=hostname
salt.modules.smartos_vmadm.stop(vm, force=False, key='uuid')

Stop a vm

vm : string
vm to be stopped
force : boolean
force stop of vm if true
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.stop 186da9ab-7392-4f55-91a5-b8f1fe770543
salt '*' vmadm.stop 186da9ab-7392-4f55-91a5-b8f1fe770543 True
salt '*' vmadm.stop vm=nacl key=alias
salt '*' vmadm.stop vm=nina.example.org key=hostname
salt.modules.smartos_vmadm.sysrq(vm, action='nmi', key='uuid')

Send non-maskable interupt to vm or capture a screenshot

vm : string
vm to be targetted
action : string
nmi or screenshot -- Default: nmi
key : string [uuid|alias|hostname]
value type of 'vm' parameter

CLI 范例:

salt '*' vmadm.sysrq 186da9ab-7392-4f55-91a5-b8f1fe770543 nmi
salt '*' vmadm.sysrq 186da9ab-7392-4f55-91a5-b8f1fe770543 screenshot
salt '*' vmadm.sysrq nacl nmi key=alias
salt.modules.smartos_vmadm.update(vm, from_file=None, key='uuid', **kwargs)

Update a new vm

vm : string
vm to be updated
from_file : string
json file to update the vm with -- if present, all other options will be ignored
key : string [uuid|alias|hostname]
value type of 'vm' parameter
kwargs : string|int|...
options to update for the vm

CLI 范例:

salt '*' vmadm.update vm=186da9ab-7392-4f55-91a5-b8f1fe770543 from_file=/tmp/new_vm.json
salt '*' vmadm.update vm=nacl key=alias from_file=/tmp/new_vm.json
salt '*' vmadm.update vm=186da9ab-7392-4f55-91a5-b8f1fe770543 max_physical_memory=1024