WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH][3/3] XenAPI: Example Scripts for PCI Assignment

To: xen-devel@xxxxxxxxxxxxxxxxxxx, xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH][3/3] XenAPI: Example Scripts for PCI Assignment
From: Yosuke Iwamatsu <y-iwamatsu@xxxxxxxxxxxxx>
Date: Wed, 02 Jul 2008 20:37:25 +0900
Cc:
Delivery-date: Wed, 02 Jul 2008 04:39:11 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)
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
#!/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()
#!/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()
#!/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()
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH][3/3] XenAPI: Example Scripts for PCI Assignment, Yosuke Iwamatsu <=