Welcome to the Virtual Iron Forums!
Here you'll find information to help you get the maximum value from your Virtual Iron software.
Community |
Topic Title: Where do I find documentation on the scripting API? Topic Summary: VirtualIron Scripting API Created On: 01/24/2007 05:03 PM |
Linear : Threading : Single : Branch |
- goolj10 | - 01/24/2007 05:03 PM |
- cbarclay | - 01/24/2007 05:10 PM |
- goolj10 | - 01/26/2007 10:06 AM |
- cbarclay | - 01/26/2007 10:33 AM |
Topic Tools
|
01/24/2007 05:03 PM
|
|
I read in the quick start that "The Virtualization Manager has a flexible API that allows customized policies and integration with third party
applications." I found the javadoc in the installation directories, but it was minimal at best. Where do I find scripting howto's (e.g., the "hello world" of VirutalIron scripting)? Is there a way to initiate a script from outside the Virtualization Manager (again, the javadoc seems to indicate it's possible, but no real documentation)?
|
|
|
|
01/24/2007 05:10 PM
|
|
Great questions. We're working on more formal API doc, but right now the Javadoc provides the most comprehensive information. As far as a hello world, here's a sample written in Python to create a virtual data center:
def createVDC (vdcName): vdc = configManager.findObject(VirtualDataCenter, vdcName) if not vdc: job = makeJob() job.begin() command = "Create VDC %s" % (vdcName) vdc = configManager.createObject(VirtualDataCenter, vdcName) dc.addVirtualDataCenter(vdc) job.addOperationDescription('Create VDC %s' % (vdcName), dc, dc, dc) job.commit() configManager = VirtualizationManager.getConfigurationManager() createVDC('TestLab') You can run this remotely by putting this in a file and calling it: ./runner.sh tcp://machinename --inputfile=filename --password=adminpassword Edited: 01/24/2007 at 05:12 PM by cbarclay |
|
|
|
01/26/2007 10:06 AM
|
|
Thanks for the tip. After tinkering around for a day or so with the API everything seems relatively clear. It looks like all managed objects are either created by the user with the ConfigurationManager.{createObject,createJob,createEvent} methods or by the system (e.g., VirtualNetworkInterfaceCard objects are automatically generated by the system) and retrieved via the ConfigurationManager.{findObject,getObject,getObjects,etc.} methods.
Also, there seems to be fairly logical relationships between objects, e.g., you can get a VirtualServer from a Node object, if it's associated to one or from the VirtualDataCenter if it's not. That said, I'm trying to create a virtual server that boots using PXE. It appears that this is implemented by booting from a floppy image on the local filesystem of the virtual server's dom0. This is represented as a FloppyImageDisk object, and there appears to be one of these objects per Node (dom0). My intuition says that I should be able to go the the Node I added the VirtualServer to and say something like 'node.getLocalFloppyImageDisks()' to get the correct FloppyImageDisk for the VirtualServer to boot from, but there is not such method. It looks like the only linkage between a FloppyImageDisk object and the Node it resides on is the naming scheme (e.g., if I have a Node named 'Dell Optiplex (1)', I call cm.findObject(FloppyImageDisk, 'FloppyIMageDisk (pxe.img) in Dell OptiPlex (1)')). Is this correct? Is there a better way to discover which FloppyImageDisk I should be using for a certain VirtualServer? Or does it even matter? Thanks. Edited: 01/26/2007 at 10:09 AM by goolj10 |
|
|
|
01/26/2007 10:33 AM
|
|
Here's some code that might be helpful:
def pxeBootVs(vs): """ Set a VS to PXE-boot. This only works if the VS is associated with a node. The PXE-boot mechanism uses a logical floppy boot device to boot the PXE image. """ # Get the node associated with the VS. node = vs.getAssociatedNode() if not node: raise Exception("pxeBootVs: vs <" + vs + "> has no associated node") # Get the first floppy storage device for the node. floppyDevice = None for card in node.getCards(): if isinstance(card, FloppyAdapter): floppyDevice = card.getPorts()[0].getFloppyDevices()[0] break if not floppyDevice: raise Exception("pxeBootVs: no floppy device found for node <" + node + ">") # Set the VS boot device to the floppy device. vs.setBootStorageDevice(floppyDevice) |
|
|
FORUMS
:
How-tos
:
General Q&A
:
Where do I find documentation on the scr...
|
Topic Tools
|
FuseTalk Standard Edition - © 1999-2007 FuseTalk Inc. All rights reserved.
Copyright © 2003-2007 Virtual Iron Software, Inc. | Privacy Statement | Terms of Use | Site Map