-
Benziane Chakib authoredBenziane Chakib authored
api.rst 2.05 KiB
Node library API
Table of contents
Global Interface
Libvirt Wrapper Classes
KVM Interface
Exceptions
Helper Functions
Node Managment
Examples
A basic usage of the node library looks like this:
>>> #import the library
>>> import ccnode
>>> kvm = ccnode.KvmHypervisor()
>>> hand = ccnode.ccnodehandlers.NodeHandler(kvm)
# We can list all vms with None parameter
>>> hand.list_vm(None)
[{'cpu': 88,
'status': 'Running',
'vcpus': 1,
'vm': 'squeeze',
'vmem_avail': 0L,
'vmem_total': 512L,
'vmem_used': 512L},
{'cpu': 47,
'status': 'Running',
'vcpus': 1,
'vm': 'ldap',
'vmem_avail': 0L,
'vmem_total': 512L,
'vmem_used': 512L},
{'cpu': 0,
'status': 'Running',
'vcpus': 1,
'vm': 'lenny',
'vmem_avail': 0L,
'vmem_total': 512L,
'vmem_used': 512L}]
We can give a list of vms to list
>>> hand.list_vm(['squeeze', 'lenny'])
[{'cpu': 51,
'status': 'Running',
'vcpus': 1,
'vm': 'squeeze',
'vmem_avail': 0L,
'vmem_total': 512L,
'vmem_used': 512L},
{'cpu': 0,
'status': 'Running',
'vcpus': 1,
'vm': 'lenny',
'vmem_avail': 0L,
'vmem_total': 512L,
'vmem_used': 512L}]
# And a tags list too
>>> hand.list_vm(['squeeze', 'lenny'], tags=['vmem_used', 'vcpus'])
[{'vcpus': 1, 'vm': 'squeeze', 'vmem_used': 512L},
{'vcpus': 1, 'vm': 'lenny', 'vmem_used': 512L}]