All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yosuke Iwamatsu <y-iwamatsu@ab.jp.nec.com>
To: xen-devel@lists.xensource.com, xen-api@lists.xensource.com
Subject: [PATCH][3/3] XenAPI: Example Scripts for PCI Assignment
Date: Wed, 02 Jul 2008 20:37:25 +0900	[thread overview]
Message-ID: <486B6875.60802@ab.jp.nec.com> (raw)

[-- 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

                 reply	other threads:[~2008-07-02 11:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=486B6875.60802@ab.jp.nec.com \
    --to=y-iwamatsu@ab.jp.nec.com \
    --cc=xen-api@lists.xensource.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.