oca.virtualmachine

class oca.VirtualMachine(xml, client)

Bases: oca.pool.PoolElement

ACTIVE = 3
DONE = 6
ELEMENT_NAME = 'VM'
FAILED = 7
HOLD = 2
INIT = 0
LCM_STATE = ['LCM_INIT', 'PROLOG', 'BOOT', 'RUNNING', 'MIGRATE', 'SAVE_STOP', 'SAVE_SUSPEND', 'SAVE_MIGRATE', 'PROLOG_MIGRATE', 'PROLOG_RESUME', 'EPILOG_STOP', 'EPILOG', 'SHUTDOWN', 'CANCEL', 'FAILURE', 'DELETE', 'UNKNOWN']
METHODS = {'info': 'vm.info', 'migrate': 'vm.migrate', 'chown': 'vm.chown', 'allocate': 'vm.allocate', 'deploy': 'vm.deploy', 'action': 'vm.action', 'savedisk': 'vm.savedisk', 'update': 'vm.update', 'delete': 'vm.delete'}
MIGRATE_REASON = ['NONE', 'ERROR', 'STOP_RESUME', 'USER', 'CANCEL']
PENDING = 1
SHORT_LCM_STATES = {'SAVE_SUSPEND': 'save', 'PROLOG_MIGRATE': 'migr', 'FAILURE': 'fail', 'MIGRATE': 'migr', 'UNKNOWN': 'unkn', 'BOOT': 'boot', 'EPILOG_STOP': 'epil', 'PROLOG_RESUME': 'prol', 'RUNNING': 'runn', 'SAVE_STOP': 'save', 'SHUTDOWN': 'shut', 'SAVE_MIGRATE': 'save', 'CANCEL': 'shut', 'LCM_INIT': 'init', 'DELETE': 'dele', 'EPILOG': 'epil', 'PROLOG': 'prol'}
SHORT_MIGRATE_REASON = {'USER': 'user', 'CANCEL': 'canc', 'NONE': 'none', 'STOP_RESUME': 'stop', 'ERROR': 'erro'}
SHORT_VM_STATES = {'FAILED': 'fail', 'INIT': 'init', 'STOPPED': 'stop', 'SUSPENDED': 'susp', 'ACTIVE': 'actv', 'DONE': 'done', 'HOLD': 'hold', 'PENDING': 'pend'}
STOPPED = 4
SUSPENDED = 5
VM_STATE = ['INIT', 'PENDING', 'HOLD', 'ACTIVE', 'STOPPED', 'SUSPENDED', 'DONE', 'FAILED']
XML_TYPES = {'uid': <type 'int'>, 'net_tx': <type 'int'>, 'user_template': ['USER_TEMPLATE', <class 'oca.pool.Template'>], 'cpu': <type 'int'>, 'memory': <type 'int'>, 'etime': <type 'int'>, 'history_records': ['HISTORY_RECORDS', <function <lambda> at 0x7f855ed0e1b8>], 'uname': <type 'str'>, 'state': <type 'int'>, 'gid': <type 'int'>, 'net_rx': <type 'int'>, 'stime': <type 'int'>, 'template': ['TEMPLATE', <class 'oca.pool.Template'>, ['NIC', 'DISK']], 'gname': <type 'str'>, 'last_poll': <type 'int'>, 'deploy_id': <type 'str'>, 'lcm_state': <type 'int'>, 'id': <type 'int'>, 'name': <type 'str'>}
static allocate(client, template)

allocates a virtual machine description from the given template string

Arguments

template
a string containing the template of the vm
cancel()

Cancels a running VM

delete()

Deletes current object from the pool

deploy(host_id)

initiates the instance of the given vmid on the target host

Arguments

host_id
the host id (hid) of the target host where the VM will be instantiated.
finalize()

Deletes a VM from the pool and DB

hold()

Sets a VM to hold state, scheduler will not deploy it

info(*args)
live_migrate(dest_host)

live migrates virtual machine to the target host

Arguments

dest_host
the target host id
migrate(dest_host)

migrates virtual machine to the target host

Arguments

dest_host
the target host id
classmethod new_with_id(client, element_id)

Retrives object which id equals `id`.

Arguments

`client`
oca.Client object.
`element_id
object id.
release()

Releases a VM from hold state

restart()

Resubmits the VM after failure

resubmit()

Redeploy the VM.

resume()

Resumes the execution of a saved VM

save_disk(disk_id, dest_disk)

Sets the disk to be saved in the given image

Arguments

disk_id
disk id of the disk we want to save
dest_disk
image id where the disk will be saved.
short_lcm_state

Short string representation of virtual machine LCM state. One of: init, prol, boot, runn, migr, save, save, save, migr, prol, epil, shut, shut, fail, dele, unkn

short_state

Short string representation of virtual machine state. One of: init, pend, hold, actv, stop, susp, done, fail

shutdown()

Shutdowns an already deployed VM

stop()

Stops a running VM

str_lcm_state

String representation of virtual machine LCM state. One of: LCM_INIT, PROLOG, BOOT, RUNNING, MIGRATE, SAVE_STOP, SAVE_SUSPEND, SAVE_MIGRATE, PROLOG_MIGRATE, PROLOG_RESUME, EPILOG_STOP, EPILOG, SHUTDOWN, CANCEL, FAILURE, DELETE, UNKNOWN

str_state

String representation of virtual machine state. One of: INIT, PENDING, HOLD, ACTIVE, STOPPED, SUSPENDED, DONE, FAILED

suspend()

Saves a running VM

update(template, merge=False)

Update the template of this host. If merge is false (default), the existing template is replaced.

class oca.VirtualMachinePool(client)

Bases: oca.pool.Pool

METHODS = {'info': 'vmpool.info'}
info(filter=-3, range_start=-1, range_end=-1, vm_state=-1)

Retrives/Refreshes virtual machine pool information

filter
Filter flag. By defaults retrives only connected user reources.
range_start
Range start ID. -1 for all
range_end
Range end ID. -1 for all

vm_state

VM state to filter by.

  • -2 Any state, including DONE
  • -1 Any state, except DONE (Defualt)
  • 0 INIT
  • 1 PENDING
  • 2 HOLD
  • 3 ACTIVE
  • 4 STOPPED
  • 5 SUSPENDED
  • 6 DONE
  • 7 FAILED

Previous topic

oca.template

This Page