All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][3/3] XenAPI: Example Scripts for PCI Assignment
@ 2008-07-02 11:37 Yosuke Iwamatsu
  0 siblings, 0 replies; only message in thread
From: Yosuke Iwamatsu @ 2008-07-02 11:37 UTC (permalink / raw)
  To: xen-devel, xen-api

[-- Attachment #1: Type: text/plain, Size: 309 bytes --]

These attachments are examples for pci assignment via xen-api.

ppci_get_record.py: demonstrates physical pci information acquisition.
dpci_create.py: adds a pci device to a domain.
dpci_destroy.py: removes a pci device from a domain.

Regards,
-----------------------
Yosuke Iwamatsu
        NEC Corporation

[-- Attachment #2: dpci_create.py --]
[-- Type: text/plain, Size: 1188 bytes --]

#!/usr/bin/python
"""Test program for Xen-API direct PCI device attachment"""

SERVER_URL='http://localhost:9363'
USER='me'
PASSWORD='mypassword'

VM_NAME='mydomain'
PCI_NAME='0000:0c:00.1'

import sys
sys.path.append("/usr/lib/python")

from xen.xm.XenAPI import Session

def main(argv = sys.argv):
    server = Session(SERVER_URL)
    server.login_with_password(USER, PASSWORD)

    # get VM
    vm_refs = server.xenapi.host.get_resident_VMs(
            server.xenapi.session.get_this_host(server.getSession()))
    for vm_ref in vm_refs:
        vm_record = server.xenapi.VM.get_record(vm_ref)
        if vm_record['name_label'] == VM_NAME:
            break

    # get PPCI
    ppci_refs = server.xenapi.host.get_PPCIs(
            server.xenapi.session.get_this_host(server.getSession()))
    for ppci_ref in ppci_refs:
        ppci_record = server.xenapi.PPCI.get_record(ppci_ref)
        if ppci_record['name'] == PCI_NAME:
            break

    # create DPCI
    dpci_record = {
        'VM': vm_ref,
        'PPCI': ppci_ref,
        'hotplug_slot': 0,
        }
    dpci_ref = server.xenapi.DPCI.create(dpci_record)

    server.logout()

if __name__ == "__main__":
    main()

[-- Attachment #3: dpci_destroy.py --]
[-- Type: text/plain, Size: 1068 bytes --]

#!/usr/bin/python
"""Test program for Xen-API direct PCI device detachment"""

SERVER_URL='http://localhost:9363'
USER='me'
PASSWORD='mypassword'

VM_NAME='mydomain'
PCI_NAME='0000:0c:00.1'

import sys
sys.path.append("/usr/lib/python")

from xen.xm.XenAPI import Session

def main(argv = sys.argv):
    server = Session(SERVER_URL)
    server.login_with_password(USER, PASSWORD)

    # get VM
    vm_refs = server.xenapi.host.get_resident_VMs(
            server.xenapi.session.get_this_host(server.getSession()))
    for vm_ref in vm_refs:
        vm_record = server.xenapi.VM.get_record(vm_ref)
        if vm_record['name_label'] == VM_NAME:
            break

    # get DPCI
    dpci_refs = server.xenapi.DPCI.get_all()
    for dpci_ref in dpci_refs:
        dpci_record = server.xenapi.DPCI.get_record(dpci_ref)
        ppci_record = server.xenapi.PPCI.get_record(dpci_record['PPCI'])
        if ppci_record['name'] == PCI_NAME:
            break

    # destroy
    server.xenapi.DPCI.destroy(dpci_ref)

    server.logout()

if __name__ == "__main__":
    main()

[-- Attachment #4: ppci_get_record.py --]
[-- Type: text/plain, Size: 721 bytes --]

#!/usr/bin/python
"""Test program for Xen-API PPCI class"""

SERVER_URL='http://localhost:9363'
USER='me'
PASSWORD='mypassword'

import sys
sys.path.append("/usr/lib/python")

from xen.xm.XenAPI import Session

def main(argv = sys.argv):
    server = Session(SERVER_URL)
    server.login_with_password(USER, PASSWORD)

    print "=== PPCI INFORMATION ==="
    ppci_refs = server.xenapi.host.get_PPCIs(
            server.xenapi.session.get_this_host(server.getSession()))
    print "ppci_refs = %s" % ppci_refs
    for ppci_ref in ppci_refs:
        ppci_record = server.xenapi.PPCI.get_record(ppci_ref)
        print "ppci_record = %s" % ppci_record
    print

    server.logout()

if __name__ == "__main__":
    main()

[-- Attachment #5: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-07-02 11:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-02 11:37 [PATCH][3/3] XenAPI: Example Scripts for PCI Assignment Yosuke Iwamatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.