Xen toolstack-xen API

Source: Internet
Author: User
Tags xapi

The user space interface is xapi. py.

The procedure of the member API functions of xapi. py is as follows:

1. Call connect and log on to xend through serverproxy RPC

2. Execute and execute func (* ARGs). Among them, func and ARGs are input parameters, and * ARGs indicates variable length parameters.

Xapi. py supports the following API commands:

Commands = {
'Host-info': ('', 'Get xen host info '),
'Host-set-name': ('', 'set host name '),
'Pif-list': ('', 'list all PIFs '),
'Sr-list': ('', 'list all SRS '),
'Vbd-list': ('', 'list all VBDs '),
'Vbd-create': ('<domname> <pycfg> [opts]',
'Create vbd attached to domname '),
'Vdi-create': ('<pycfg> [opts]', 'create a VDI '),
'Vdi-list': ('', 'list all VDI '),
'Vdi-rename': ('<vdi_uuid> <new_name>', 'rename VDI '),
'Vdi-destroy': ('<vdi_uuid>', 'delete VDI '),
'Vif-create': ('<domname> <pycfg>', 'create VIF attached to domname '),
'Vtpm-create': ('<domname> <pycfg>', 'create vtpm attached to domainname '),

'Vm-create': ('<pycfg>', 'create Vm with Python config '),
'Vm-destroy': ('<domname>', 'delete VM '),

'Vm-list': ('[-- long]', 'list all domains .'),
'Vm-name': ('<UUID>', 'name of UUID .'),
'Vm-Shutdown ': (' <Name> [opts] ', 'shutdown Vm with name '),
'Vm-start': ('<Name>', 'start Vm with name '),
'Vm-UUID ': (' <Name> ', 'uuid of a domain by name .'),
'Async'-VM-start': ('<Name>', 'start VM asynchronously '),
}

Let's look at an example.

Def xapi_vm_start (ARGs, async = false ):
If Len (ARGs) <1:
Raise optionerror ("no domain name specified .")

# Connect to xend
Server, session = connect ()

# Convert VM name to VM UUID
Vm_uuid = resolve_vm (server, session, argS [0])
Print 'starting VM % s (% s) '% (ARGs [0], vm_uuid)

# Call VM. Start Function
Success = execute (server, 'vm. start', (Session, vm_uuid, false), async = async)
If async:
Print 'Task started: % s' % success
Else:
Print 'did .'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.