Kensho

June 30, 2010 in citrix, virtualization, xen by admin

Page edited by Jeff Gee

Project Kensho v1.3 Technology Preview

Breaking News

Kensho OVF technology is now available from within XenServer 5.6. We still take feed back and provide limited support for the Project Kensho OVF Tool 1.3's Hyper-V functionality. Bring your issues and comments to the forum. We'd love to hear from you.

Introduction

Simplicity is Power. Simplicity is Project Kensho. Citrix Project Kensho provides users with powerfully simple tools that facilitate the export and import of virtual machines and virtual machine based workloads (virtual appliances) using the Open Virtual Machine Format (OVF) and Common Information Model (CIM) industry standards developed by the Distributed Management Task Force's (DMTF) Virtualization Management Initiative (VMAN).

The Project Kensho OVF Tool utilizes the OVF standard for the creation and consumption of virtual appliance packages. The Open Virtual Machine Format describes the metadata of virtual machine(s) and the behavior of the appliance when consumed by the hypervisor.

Citrix Project Kensho also provides a CIM interface to the XenServer™ API and introduces a WSMAN interface to XenServer™. 


      MyCitrix login required for download

  Resources

  Discuss in Forum

Featured Videos

Installing the Project Kensho OVF Tool

Installing XenServer CIM Interfaces

Using the Project Kensho OVF Tool

Project Kensho OVF Tool Advanced Features

Project Kensho and Hyper-V


Useful Reference

What is OVF?

Kensho OVF Technology


How It Works

Project Kensho consists of the following components:
An OVF Tool , which utilizes the OVF standard for the creation and consumption of virtual appliance packages. This utility removes much of the complexities found in conversion and packaging tools.

A CIM interface to the XenServer™ API, which also adds a WSMAN interface to XenServer™. The Xen-CIM component is required by the Project Kensho OVF Tool and installs directly on the XenServer™. It can also be used as an interface for management of XenServer™ and XenServer™ hosted virtual machines.

What's New?

Project Kensho 1.3 brings a wealth of powerfully simple features to both the Kensho OVF Tool and the CIM interface. These new features enable users to both manage a XenServer™ in new ways as well as reap the benefits of OVF in a XenServer™ and Hyper-V environment.

Kensho OVF Tool

  • Compliant with the DMTF OVF 1.0.0 specification
  • Compatibility with XenConvert 2.0 OVF content
  • Support for importing into and exporting from a user defined XenServer Storage Repository (SR)
  • OVF security features:
    • Encryption
    • Digital signing
  • OVF compression
  • Snapshot support
  • Direct import of VMware OVF content simplifying migration and consumption of VMware content

XenServer-CIM Interface

  • Support for XenServer™ 5.5
  • Storage profile support
  • Networking profile support
  • Snapshot classes

Project Kensho System Requirements

The minimum environment to use the tools consists of: Project Kensho OVF Tool Host, a supported virtual machine host, and a Windows SMB share. Project Kensho requires the following services and software to support the components of the Project Kensho OVF Tool.

Software Description
Project Kensho OVF Tool Host Project Kensho OVF Tool requires a personal computer running Windows XP, Vista or Windows Server 2003 or 2008. Windows 7 and Windows Server 2008 R2 support is experimental.
Citrix XenServer™ Citrix XenServer™ 5.0 or 5.5 is required for creating and consuming OVF based virtual appliances using XenServer™ and management of the XenServer™ environment via the Common Information Model (CIM).

The Project Kensho XenServer™ CIM installation utility provides support for management of the XenServer™ through the standards based CIM interface. It also contains a configuration script to create an ISO storage repository and creates a helper VM template for the Project Kensho OVF Tool.
Windows Server 2008 with Hyper-V The Project Kensho OVF Tool supports Windows Server 2008 with the Hyper-V Role for importing and exporting OVF based virtual appliances.

Communication between the Project Kensho OVF Tool and the Windows Server occurs through WinRM. Windows Server 2008 installs WinRM by default, no additional installation is required.
Windows Server SMB File Share The Project Kensho OVF Tool requires a Windows based UNC share to import and export OVF packages. This is called the Kensho (or OVF) Library.
The share must be accessible from the Project Kensho OVF Tool as well as any virtual machine hosts targeted for import or export.

Prerequisites

Complete the following pre-installation tasks before installing Project Kensho components:

  1. Read through this entire document
  2. Read through the Project Kensho OVF Tool Readme
  3. Setup a Windows file share:
    1. Create a file share from a Windows host
      1. Windows Server 2008 with the File Services Role provides the option of creating SMB or NFS based shares, be sure to select SMB.
      2. Windows Server 2003 and prior create SMB based shares by default.
    2. Obtain a user account and password that has change level access to this share.
  4. Project Kensho OVF Tool Host:
    1. Windows XP, Windows Server 2003, or Windows Vista.
    2. Install .NET Framework version 3.5
    3. Install WinRM
  5. XenServer™ Host:
    1. XenServer™ 5.0 or 5.5
  6. Windows Server 2008 with Hyper-V Host
    1. Add the Hyper-V role

 

Install

XenServer-CIM Interface Installation

To install the XenServer-CIM Interface on XenServer™, complete the following procedure:

Be Careful

The install script creates a hidden ISO Storage Repository and copies two ISOs into it (xenserver-linuxfixup-disk.iso and xenserver-iscsi-target.iso). It also creates a helper VM template called 'iSCSI target' from xenserver-iscsi-target.iso. These are utilized by the Project Kensho OVF Tool. Do not remove, alter or add content to this storage repository.

  1. Copy XenServerCIM-Install.tgz to the XenServer™ host to the path of: /tmp
  2. From the XenServer™ console, execute the following:
    1. cd /tmp
    2. tar - xvzf XenServer-CIM.tgz
    3. cd /XenServer-CIM
    4. Install the XenServer-CIM and WSMAN providers:
      1. bash ./install.sh
      2. Answer the prompt to set the security level of the interface.

Project Kensho OVF Tool Installation

  1. From the computer identified as the Project Kensho OVF Tool computer:
    1. Execute KenshoOVF_x86.msi or KenshoOVF_x64.msi
    2. Follow the prompts
Note

The Project Kensho OVF Tool installer must execute via "run as administrator" option on Vista, Windows Server 2008, Windows 7 and Windows Server 2008 R2.

Windows Server 2008 with Hyper-V Configuration

These steps enable WinRM, modify the Windows Firewall rules and set the appropriate authorization to access WinRM remotely with Kensho OVF Tool.

  1. At the Hyper-V host login as the administrator
  2. Open a command prompt and execute the following commands:
    1. winrm quickconfig
    2. winrm p winrm/config/service @{AllowUnencrypted="true"}
    3. winrm p winrm/config/service/auth @{Basic="true"}
    4. winrm p winrm/config/client @{AllowUnencrypted="true"}
    5. winrm p winrm/config/client/auth @{Basic="true"}

 

Uninstall

XenServer-CIM Interface Uninstall Process

  1. To uninstall the XenServer-CIM and WSMAN providers
    1. bash ./uninstall.sh
      1. If an ISO image is added to the ISO storage repository, answer the prompt to delete the 'XenServer Internal ISO library'
      2. If confirmed, the script deletes the hidden internal ISO storage repository created during install. All ISO images added into this storage repository will be deleted.

Project Kensho OVF Tool Uninstall Process

  1. To uninstall Project Kensho OVF Tool:
    1. Open Add / Remove Programs (or Programs)
    2. Select the Project Kensho OVF Tool
    3. Select Remove

 

Project Kensho Administration

This section covers general administration and use of the XenServer CIM interface for XenServer™ and the Project Kensho OVF Tool.

XenServer-CIM Interface

Once installed, the XenServer-CIM interface requires no administration. Documentation is provided within the distribution that further describes using the interface and its options.

Project Kensho OVF Tool

The Project Kensho OVF Tool is the primary utility to create and consume OVF virtual appliances. When starting the utility, an initialization process occurs. This process gathers all of the library and server information from the systems defined by the user. In some scenarios, initialization may take up to 60 seconds or more to collect all data.


Figure 1 - Initializing Indicator

After completing initialization, the main UI appears


Figure 2 - Project Kensho OVF Tool

Adding virtual machine Host(s) and OVF Library Resources:

To begin using the utility, it is necessary to add at least one virtual machine host and an OVF Library. To add a virtual machine host or Library share:

1.   From the menu bar, select File > Add Server. Alternatively, pressing the hotkey combination Alt +A or clicking the Add Server icon on the toolbar invokes the Add Server configuration window.

2.   Select the platform type from the drop down menu:

  • For a Library :
    1. Enter the server name (or IP address)
    2. Enter the share name (without slashes or subfolders)
    3. Enter the username and password
    4. Click Add .
Figure 3 - Adding a Library Server
  • For a virtual machine host:
    1. Enter the server name (or IP address)
    2. Select the Host server protocol: Unsecure or Secure (HTTP/HTTPS)
    3. Enter the username and password
    4. Click Add
Figure 4 - Adding a XenServer™ Host

3.  The window will stay open after clicking the Add button. Repeat this process for each hypervisor and or library the Project Kensho OVF Tool will manage. Click the Close button when finished adding all servers.

Note

When adding a Hyper V server the account used must be a member of the local Hyper-V host administrators group.

Creating a Virtual Appliance

After configuring a library and virtual machine host(s), the Project Kensho OVF Tool is ready to create a virtual appliance from one or more virtual machines. The virtual appliance will become an OVF package. The virtual appliance is exported from either a XenServer™ or Hyper-V host.

To export a virtual machine as an OVF virtual appliance, follow these easy steps:

1.   Select the Export Tab


Figure 5 - Export Tab

2.   Select the target library share from the Library tree view. This is where the OVF and associated VHD(s) will reside after export.

3.   From the tree view, expand the list of virtual machines under each virtual machine host.

4.   Select a virtual machine with a single click. This will place its qualified name into the Selected vMachine(s) list box. To remove the selection, double click the selection.

Be Aware

There is no limit to the number of virtual machines to select for export. The more virtual machines selected, the longer the export will take and require more storage on the Library server. The amount of time to export per virtual machine is dependent on the virtual disk size, type, and network bandwidth between the virtual machine host and the library server.

5.   Click the Export button to begin. The result will be the OVF virtual appliance package containing the virtual machine(s) selected. It is important to enusre that the OVF package is tested before assuming it is good. The next section describes the import process.

Consuming a Virtual Appliance

The Project Kensho OVF Tool can consume any DMTF compliant OVF file that contains virtual machine disk(s) in the VHD or VMDK format. The virtual appliance is imported into either a XenServer™ or Hyper-V host.

To import an OVF virtual appliance, follow these easy steps:

1.   Select the Import Tab.


*Figure 6 - Import Tab

2.   Select the target virtual machine host or hosts from the respective Host type tree view.

3.   From the Kensho Library tree view, select an OVF virtual appliance.

Note

OVA packages must be converted to OVF prior to Import. Please see: Converting an OVF package to an OVA for more information.

4.   If a virtual machine to host resource mapping is required - it is noted in the Mapping status field as Mapping: Required.

5.   Click the Mapping wizard button in the Tool bar to map virtual machine to host resources.

6.   Click the Import or Force button to begin the import.

Note

The button will display Force if mapping is either incomplete or non-existent.

During a forced import devices are attached in a first found fashion. I.E. if the OVF has a network device defined on the VM an attempt will be made to attach that network to the first virtual network switch listed on the target host.

Advanced Packaging Capabilities

New to the Project Kensho 1.3 OVF Tool is support for a wide range of OVF virtual appliance packaging options. When selecting one or more VMs to export as a virtual appliance, the utility presents the following options:


Figure 7 - Export Options

Each option is unique and may be applied to any virtual appliance export. Selecting a check box enables the feature. Some features, like security options, require user input.

  • Create OVA Package
    Selecting this option allows the user to create an OVA package. An OVA package is an archive containing OVF metadata, virtual disks, manifest and certificates in a single file. This feature is useful for scenarios where a single file containing all the necessary virtual machine components is desired. This option produces a file with an .ova extension. If a file inside of the OVF package is greater than 8 GB, the operation to create the OVA will fail.
  • Compress OVA Package
    Selecting this option allows the user to compress the entire OVA package. To enable this option, the user must select the Create OVA Package option. This option is useful when the user seeks to reduce the overall file size of the of the OVA package. This option produces a file with the .ova.gz extension.
  • Compress OVF Files Individually
    Selecting this option allows the user to compress the individual files within the OVA package. This differs from the option above in that each file within the OVA package is compressed. Selecting this option allows the user to achieve maximum compression of an OVA file. This option produces files within the OVA package with the .gz extension. The OVA package will have the .ova extension.
  • Add Manifest
    Selecting this option instructs the Project Kensho OVF Tool to create a manifest file referencing the OVF files and their checksum. This option is useful when a user seeks improved reliability of the content. This option produces a file with the .mf extension.
  • Encrypt Attached Files
    Selecting this option allows the user to encrypt the OVF related files. When selecting this option, the user must enter a passphrase. This option is useful when protecting appliance content is required.
  • Sign OVF Package
    Selecting this option allows the user to digitally sign the OVF file with a certificate. This option is useful in providing security against unauthorized changes to the OVF file content.
  • Include EULA(s)
    Selecting this option allows the user to create a virtual appliance with an End User License Agreement (EULA). This feature is useful when a virtual appliance requires end user agreement to a EULA before the virtual appliance installs on the target hypervisor. To add a EULA follow these directions:

1.   Click the Add EULA button

2.   Browse to the desired text file containing the EULA text.

Note

The EULA must be a plain text file and cannot contain any formatting (such as HTML tags) or special characters.

3.   Select the EULA text file.

4.   Click Open

  • Export Metadata Only
    Selecting this option allows the user to create an OVF without any virtual disk(s). This is useful when the user needs an OVF without virtual disk information.

Advanced Import Capabilities

New to the Project Kensho 1.3 OVF Tool is support for a range of OVF virtual appliance import options. When selecting one or more OVF virtual appliances to import, the utility presents the following options:


Figure 8 - Import Options

  • Verify Digital Signature
    Selecting this option forces the import process to verify the digital signature that was used to sign the OVF during export. If the verification fails, this typically indicates that the OVF has been tampered with.
  • Verify Manifest Content
    Selecting this option forces the import process to verify that the content of the manifest file matches what is in the OVF package. If this verification fails, it typically indicates that files are missing.
  • Validate OVF Package
    Selecting this option forces the import process to validate the selected OVF file against the DMTF OVF 1.0.0 schema. This is useful to determine the compatibility of an OVF file.
  • Import Metadata Only
    Selecting this option imports the metadata only. This is useful if configuration content is all that is needed. The virtual machine content will be created from a template or an existing virtual disk will be attached after import.
  • Run Operating System Fixups
    Selecting this option runs automated scripts against the imported VMware based virtual appliance. This is necessary to ensure the VM boots properly. Select this option for Windows or Linux virtual machines imported from VMware sources. Fixup of virtual machines with more than two virtual disks is unsupported.

VM to Host Resource Mapping Wizard

The Project Kensho OVF Tool allows users to map system, storage, and networking resources defined in the OVF virtual appliance to the resources on the virtual machine host(s). This ensures that prior to import, the proper resources are paired and the virtual machine can power on minimizing administrative tasks.

Mapping is performed by selecting items (one or more) in the left column of the Mapping dialog and then selecting a target device in the right

The padlock icon depicts that a mapping of a VM device to Host resource has been set. Individual mappings may be cleared by selecting and clearing the lock icon.

An existing OVF to Host resource mapping may be cleared by clicking the Clear button on the Import tab.

1.   Begin the resource mapping process by Clicking the Mapping button in the Tool bar

2.   The mapping wizard launches and presents the Systems tab (this is the target Host for a VM workload).


Figure 9 - Unmapped VM CPU and memory workload

3.  Select the desired host resource in the right pane

4.  Select a VM resource(s) in the left pane


8Figure 10 - VM CPU and memory workload mapped Host*

5.  Click the Next button to map the Network resources.


*Figure 11 - Mapped VM Network Device to Hypervisor Network Device

6.   Select the desired host resource in the right pane

7.   Select a VM resource(s) in the left pane

8.   Click the Next button to map the Storage resources


Figure 12 - Mapped VM Storage to Hypervisor Storage

9.    Select the desired host resource in the right pane

10.   Select a VM resource(s) in the left pane

11.   Click Done to complete the wizard, save the mapping, and return to the Import screen.

Converting an OVF package to an OVA and vice versa

The Project Kensho OVF Tool facilitates the conversion of any DMTF compliant OVF export to a single OVA file.

To convert an OVF with the Project Kensho OVF Tool:

1.   Select the Import Tab


Figure 13 - OVA Menu

2.   From the Kensho Library, select an OVF.

3.   Right click the OVF and Select 'Convert to OVA'

4.   The reverse process is used to convert an OVA into an OVF.

Note

The OVF icon depicts a folder that includes the OVF package configuration and associated file.
The OVA icon indicates an OVF package that has been compressed, using tar format, into a single file with the extension .OVA
The X icon indicates an OVF package that is not compliant with the DMTF Standards.

Environment Tab

The environment tab is a read-only view of the virtual machine host resources and environment.

Figure 14 - Environment Tab

VMware OVF Support

The Project Kensho OVF Tool facilitates importing VMware derived OVF content directly into a XenServer Storage Repository in the same manner as importing a XenConvert or Project Kensho produced OVF.

It is important to note that not all VMware OVF content is equal. VMware OVF content produced through the latest VMware utilities will result in a higher degree of import success. The following VMware OVF content has been successfully tested:

  • vSphere 4
  • Virtual Infrastructure 3
  • VMware OVF Tool 0.9
  • VMware OVF Tool 1.0
  • VMware Studio 1.0
  • VMware Workstation 6.5.3
  • VMware Converter 4.0.x
  • VMware Converter 3.0.3

Snapshot Support

The Project Kensho OVF Tool now supports creating virtual appliances from virtual machines with snapshots. Both XenServer 5.5 and Hyper-V support virtual machine snapshots.

When creating an OVF virtual appliance from a virtual machine with a snapshot, the current running state of the virtual machine is what the tool creates as a virtual appliance. This can also be described as the state that is experienced when the virtual machine is powered on.

If a virtual machine contains multiple snapshots, only the current running state of the virtual machine is exported. No snapshot history or detail is exported as part of the virtual appliance

Changes between revision 89 and revision 90:

 h1. Project Kensho v1.3 Technology Preview
  
 {anchor:OLE_LINK1} {anchor:OLE_LINK2}
 {section}
 {column:width=67%}
  
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  h3. {color:#00549f}Breaking News{color}
 {div}
 Kensho OVF technology is now available from within XenServer 5.6. We still take feed back and provide limited support for the Project Kensho OVF Tool 1.3's Hyper-V functionality. Bring your issues and comments to the forum. We'd love to hear from you.
  
  
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
 h3. {color:#00549f}Introduction{color}
 {div}
 Simplicity is Power. Simplicity is Project Kensho. Citrix Project Kensho provides users with powerfully simple tools that facilitate the export and import of virtual machines and virtual machine based workloads (virtual appliances) using the Open Virtual Machine Format (OVF) and Common Information Model (CIM) industry standards developed by the Distributed Management Task Force's (DMTF) Virtualization Management Initiative (VMAN).
  
 The Project Kensho OVF Tool utilizes the OVF standard for the creation and consumption of virtual appliance packages. The Open Virtual Machine Format describes the metadata of virtual machine(s) and the behavior of the appliance when consumed by the hypervisor.
  
 Citrix Project Kensho also provides a CIM interface to the XenServer™ API and introduces a WSMAN interface to XenServer™. 
  
 {column}
 {column} [!button3.png!|http://download.citrix.com/English/ss/downloads/details.asp?downloadId=1682855&productId=683148]
       *MyCitrix login required for download*
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  
 h4. *  Resources*
  
   [!btn_search.png! *Discuss in Forum*|http://forums.citrix.com/forum.jspa?forumID=780]
  
 {div}
 {column}
 {section}
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  
 h3. {color:#00549f}Featured Videos{color}
 {div}
 {section}
 {column}
 [!Kensho.png|align=centre,width=100,heigh=72!|http://www.citrix.com/tv/#video/956]
 {align:center}*Installing the Project Kensho OVF Tool*
 {align}
 {column}
 {column}
 [!cim.png|align=centre,width=100,heigh=72!|http://www.citrix.com/tv/#video/963]
 {align:center}*Installing XenServer CIM Interfaces*
 {align}
 {column}
 {column}
 [!cim.jpg|align=centre,width=100,heigh=72!|http://www.citrix.com/tv/#video/965]
 {align:center}*Using the Project Kensho OVF Tool*
 {align}
 {column}
 {column}
 [!image13.jpg|align=centre,width=100,heigh=60!|http://www.citrix.com/tv/#video/1006]
 {align:center}*Project Kensho OVF Tool Advanced Features*
 {align}
 {column}
 {column}
 [!image14.jpg|align=centre,width=100,heigh=60!|http://www.citrix.com/tv/#video/971]
 {align:center}*Project Kensho and Hyper-V*
 {align}
 {column}
 {section}
 \\
  
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  
 h3. {color:#00549f}Useful Reference{color}
 {div}
  
 {section}
 {column}
 [!ProjectKensho.gif|align=centre,width=80,heigh=40!|http://community.citrix.com/download/attachments/45810048/WhatisOVF.pdf]
 {align:center}*What is OVF?*
 {align}
 {column}
 {column}
 [!ProjectKensho.gif|align=centre,width=80,heigh=40!|http://community.citrix.com/download/attachments/45810048/Kensho+OVF+Technology.pdf]
 {align:center}*Kensho OVF Technology*
 {align}
 {align}
 {column}
 {section}
 \\
  
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  
 h3. {color:#00549f}How It Works{color}
 {div}
 Project Kensho consists of the following components:
 An *OVF Tool* , which utilizes the OVF standard for the creation and consumption of virtual appliance packages. This utility removes much of the complexities found in conversion and packaging tools.
  
 A *CIM interface* to the XenServer™ API, which also adds a WSMAN interface to XenServer™. *The Xen-CIM component is required by the Project Kensho OVF Tool* and installs directly on the XenServer™. It can also be used as an interface for management of XenServer™ and XenServer™ hosted virtual machines.
  
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  
 h3. {color:#00549f}What's New?{color}
  
 {div}
 Project Kensho 1.3 brings a wealth of powerfully simple features to both the Kensho OVF Tool and the CIM interface. These new features enable users to both manage a XenServer™ in new ways as well as reap the benefits of OVF in a XenServer™ and Hyper-V environment.
  
 h4. Kensho OVF Tool
 * Compliant with the DMTF OVF 1.0.0 specification
 * Compatibility with XenConvert 2.0 OVF content
 * Support for importing into and exporting from a user defined XenServer Storage Repository (SR)
 * OVF security features:
  ** Encryption
  ** Digital signing
 * OVF compression
 * Snapshot support
 * Direct import of VMware OVF content simplifying migration and consumption of VMware content
  
 h4. XenServer-CIM Interface
 * Support for XenServer™ 5.5
 * Storage profile support
 * Networking profile support
 * Snapshot classes
  
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  
 h3. {color:#00549f}Project Kensho System Requirements{color}
  
 {div}
  
 The minimum environment to use the tools consists of: Project Kensho OVF Tool Host, a supported virtual machine host, and a Windows SMB share. Project Kensho requires the following services and software to support the components of the Project Kensho OVF Tool.
 || *Software* || *Description* ||
 | Project Kensho OVF Tool Host | Project Kensho OVF Tool requires a personal computer running Windows XP, Vista or Windows Server 2003 or 2008. Windows 7 and Windows Server 2008 R2 support is experimental. |
 | Citrix XenServer™ | Citrix XenServer™ 5.0 or 5.5 is required for creating and consuming OVF based virtual appliances using XenServer™ and management of the XenServer™ environment via the Common Information Model (CIM). \\
 \\
 The Project Kensho XenServer™ CIM installation utility provides support for management of the XenServer™ through the standards based CIM interface. It also contains a configuration script to create an ISO storage repository and creates a helper VM template for the Project Kensho OVF Tool.|
 | Windows Server 2008 with Hyper-V | The Project Kensho OVF Tool supports Windows Server 2008 with the Hyper-V Role for importing and exporting OVF based virtual appliances. \\
 \\
 Communication between the Project Kensho OVF Tool and the Windows Server occurs through WinRM. Windows Server 2008 installs WinRM by default, no additional installation is required. \\
 | Windows Server SMB File Share | The Project Kensho OVF Tool requires a Windows based UNC share to import and export OVF packages. This is called the Kensho (or OVF) Library. \\
 The share must be accessible from the Project Kensho OVF Tool as well as any virtual machine hosts targeted for import or export. |
  
 h4. {color:#00549f}Prerequisites{color}
  
 Complete the following pre-installation tasks before installing Project Kensho components:
 # Read through this entire document
 # Read through the Project Kensho OVF Tool Readme
 # Setup a Windows file share:
 ## Create a file share from a Windows host
 ### Windows Server 2008 with the File Services Role provides the option of creating SMB or NFS based shares, be sure to select SMB.
 ### Windows Server 2003 and prior create SMB based shares by default.
 ## Obtain a user account and password that has change level access to this share.
 # Project Kensho OVF Tool Host:
 ## Windows XP, Windows Server 2003, or Windows Vista.
 ## Install .NET Framework version 3.5
 ## Install WinRM
 # XenServer™ Host:
 ## XenServer™ 5.0 or 5.5
 # Windows Server 2008 with Hyper-V Host
 ## Add the Hyper-V role
  
 h2.  
  
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  
 h3. {color:#00549f}Install{color}
  
 {div}
  
 h4. *XenServer-CIM Interface Installation*
  
 To install the XenServer-CIM Interface on XenServer™, complete the following procedure:
 {note:title=Be Careful}
 The install script creates a hidden ISO Storage Repository and copies two ISOs into it (xenserver-linuxfixup-disk.iso and xenserver-iscsi-target.iso). It also creates a helper VM template called 'iSCSI target' from xenserver-iscsi-target.iso. These are utilized by the Project Kensho OVF Tool. Do not remove, alter or add content to this storage repository.
 {note}
  
 # Copy XenServerCIM-Install.tgz to the XenServer™ host to the path of: /tmp
 # From the XenServer™ console, execute the following:
 ## *cd /tmp*
 ## *tar \- xvzf XenServer-CIM.tgz*
 ## *cd /XenServer-CIM*
 ## Install the XenServer-CIM and WSMAN providers:
 ### *bash ./install.sh*
 ### Answer the prompt to set the security level of the interface.
  
 h4. *Project Kensho OVF Tool Installation*
  
 # From the computer identified as the Project Kensho OVF Tool computer:
 ## Execute *KenshoOVF_x86.msi* or *KenshoOVF_x64.msi*
 ## Follow the prompts
  
 {info:title=Note}
 The Project Kensho OVF Tool installer must execute via "run as administrator" option on Vista, Windows Server 2008, Windows 7 and Windows Server 2008 R2.
 {info}
  
 h4. *Windows Server 2008 with* *Hyper-V Configuration*
 These steps enable WinRM, modify the Windows Firewall rules and set the appropriate authorization to access WinRM remotely with Kensho OVF Tool.
 # At the Hyper-V host login as the administrator
 # Open a command prompt and execute the following commands:
 ## *winrm quickconfig*
 ## *winrm p winrm/config/service @\{AllowUnencrypted="true"\}*
 ## *winrm p winrm/config/service/auth @\{Basic="true"\}*
 ## *winrm p winrm/config/client @\{AllowUnencrypted="true"\}*
 ## *winrm p winrm/config/client/auth @\{Basic="true"\}*
  
  
 h3.  
  
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  
 h3. {color:#00549f}Uninstall{color}
  
 {div}
  
 h4. *XenServer-CIM Interface Uninstall Process*
  
 # To uninstall the XenServer-CIM and WSMAN providers
 ## *bash ./uninstall.sh*
 ### If an ISO image is added to the ISO storage repository, answer the prompt to delete the 'XenServer Internal ISO library'
 ### If confirmed, the script deletes the hidden internal ISO storage repository created during install. All ISO images added into this storage repository will be deleted.
  
 h4. *Project Kensho OVF Tool Uninstall Process*
  
 # To uninstall Project Kensho OVF Tool:
 ## Open Add / Remove Programs (or Programs)
 ## Select the Project Kensho OVF Tool
 ## Select Remove
  
 h3.  
  
 {div:style=padding:3px;background-color:#EEEEEE; layer-background-color:#EEEEEE}
  
 h3. {color:#00549f}Project Kensho Administration{color}
  
 {div}
 This section covers general administration and use of the XenServer CIM interface for XenServer™ and the Project Kensho OVF Tool.
  
 h4. *XenServer-CIM Interface*
  
 Once installed, the XenServer-CIM interface requires no administration. Documentation is provided within the distribution that further describes using the interface and its options.
  
 h4. *Project Kensho OVF Tool*
  
 The Project Kensho OVF Tool is the primary utility to create and consume OVF virtual appliances. When starting the utility, an initialization process occurs. This process gathers all of the library and server information from the systems defined by the user. In some scenarios, initialization may take up to 60 seconds or more to collect all data.
  
 !image1.jpg!
 {color:#4f81bd}*Figure 1 \- Initializing Indicator*{color}
  
 After completing initialization, the main UI appears
  
 !image2.jpg!
 {color:#4f81bd}*Figure 2 \- Project Kensho OVF Tool*{color}
  
 h4. *Adding virtual machine Host(s) and OVF Library Resources:*
 To begin using the utility, it is necessary to add at least one virtual machine host and an OVF Library. To add a virtual machine host or Library share:
  
 1.   From the menu bar, select *File > Add Server*. Alternatively, pressing the hotkey combination *Alt \+A* or clicking the Add Server icon !addhost_16.jpg! on the toolbar invokes the Add Server configuration window.
  
 2.   Select the platform type from the drop down menu:
  
 | !image3.jpg! | * *For a Library* :
 *# Enter the server name (or IP address)
 *# Enter the share name (without slashes or subfolders)
 *# Enter the username and password
 *# Click *Add* . |
 | {color:#4f81bd}*Figure 3 \- Adding a Library Server*{color} |
 | !image4.jpg! | * *For a virtual machine host:*
 *# Enter the server name (or IP address)
 *# Select the Host server protocol: Unsecure or Secure (HTTP/HTTPS)
 *# Enter the username and password
 *# Click *Add* |
 | {color:#4f81bd}*Figure 4 \- Adding a XenServer™ Host*{color} |
  
 3.  The window will stay open after clicking the *Add* button. Repeat this process for each hypervisor and or library the Project Kensho OVF Tool will manage. Click the *Close* button when finished adding all servers.
 {info:title=Note}
 When adding a Hyper V server the account used must be a member of the local Hyper-V host administrators group.
 {info}
  
 h4. *Creating a Virtual Appliance*
 After configuring a library and virtual machine host(s), the Project Kensho OVF Tool is ready to create a virtual appliance from one or more virtual machines. The virtual appliance will become an OVF package. The virtual appliance is exported from either a XenServer™ or Hyper-V host.
  
 To export a virtual machine as an OVF virtual appliance, follow these easy steps:
  
 1.   Select the Export Tab
  
 !image5.jpg!
 {color:#4f81bd}*Figure 5 \- Export Tab*{color}
  
 2.   Select the target library share from the Library tree view. This is where the OVF and associated VHD(s) will reside after export.
  
 3.   From the tree view, expand the list of virtual machines under each virtual machine host.
  
 4.   Select a virtual machine with a single click. This will place its qualified name into the _Selected vMachine(s)_ list box. To remove the selection, double click the selection.
 {note:title=Be Aware}
 There is no limit to the number of virtual machines to select for export. The more virtual machines selected, the longer the export will take and require more storage on the Library server. The amount of time to export per virtual machine is dependent on the virtual disk size, type, and network bandwidth between the virtual machine host and the library server.
 {note}
 5.   Click the Export button to begin. The result will be the OVF virtual appliance package containing the virtual machine(s) selected. It is important to enusre that the OVF package is tested before assuming it is good. The next section describes the import process.
  
  
 h4. *Consuming a Virtual Appliance*
 The Project Kensho OVF Tool can consume any DMTF compliant OVF file that contains virtual machine disk(s) in the VHD or VMDK format. The virtual appliance is imported into either a XenServer™ or Hyper-V host.
  
 To import an OVF virtual appliance, follow these easy steps:
  
 1.   Select the Import Tab.
  
 !image6.jpg!
 {color:#4f81bd}*Figure 6 \- Import Tab{color}
  
 2.   Select the target virtual machine host or hosts from the respective Host type tree view.
  
 3.   From the Kensho Library tree view, select an OVF virtual appliance.
 {info:title=Note}
 OVA packages must be converted to OVF prior to Import. Please see: Converting an OVF package to an OVA for more information.
 {info}
  
 4.   If a virtual machine to host resource mapping is required - it is noted in the Mapping status field as Mapping: Required.
  
 5.   Click the Mapping wizard button !newvirtualnetwork_32.jpg! in the Tool bar to map virtual machine to host resources.
  
 6.   Click the *Import* or *Force* button to begin the import.
 {info:title=Note}
 The button will display *Force* if mapping is either incomplete or non-existent.
 {info}
 During a forced import devices are attached in a first found fashion. I.E. if the OVF has a network device defined on the VM an attempt will be made to attach that network to the first virtual network switch listed on the target host.
  
  
 h4. *Advanced Packaging Capabilities*
 New to the Project Kensho 1.3 OVF Tool is support for a wide range of OVF virtual appliance packaging options. When selecting one or more VMs to export as a virtual appliance, the utility presents the following options:
  
 !image7.jpg!
 {color:#4f81bd}*Figure 7 \- Export Options*{color}
  
 Each option is unique and may be applied to any virtual appliance export. Selecting a check box enables the feature. Some features, like security options, require user input.
  
 * *Create OVA Package*
 Selecting this option allows the user to create an OVA package. An OVA package is an archive containing OVF metadata, virtual disks, manifest and certificates in a single file. This feature is useful for scenarios where a single file containing all the necessary virtual machine components is desired. This option produces a file with an .ova extension. If a file inside of the OVF package is greater than 8 GB, the operation to create the OVA will fail.
  
 * *Compress OVA Package*
 Selecting this option allows the user to compress the entire OVA package. To enable this option, the user must select the Create OVA Package option. This option is useful when the user seeks to reduce the overall file size of the of the OVA package. This option produces a file with the .ova.gz extension.
  
 * *Compress OVF Files Individually*
 Selecting this option allows the user to compress the individual files within the OVA package. This differs from the option above in that each file within the OVA package is compressed. Selecting this option allows the user to achieve maximum compression of an OVA file. This option produces files within the OVA package with the .gz extension. The OVA package will have the .ova extension.
  
 * *Add Manifest*
 Selecting this option instructs the Project Kensho OVF Tool to create a manifest file referencing the OVF files and their checksum. This option is useful when a user seeks improved reliability of the content. This option produces a file with the .mf extension.
  
 * *Encrypt Attached Files*
 Selecting this option allows the user to encrypt the OVF related files. When selecting this option, the user must enter a passphrase. This option is useful when protecting appliance content is required.
  
 * *Sign OVF Package*
 Selecting this option allows the user to digitally sign the OVF file with a certificate. This option is useful in providing security against unauthorized changes to the OVF file content.
  
 * *Include EULA(s)*
 Selecting this option allows the user to create a virtual appliance with an End User License Agreement (EULA). This feature is useful when a virtual appliance requires end user agreement to a EULA before the virtual appliance installs on the target hypervisor. To add a EULA follow these directions:
  
 1.   Click the Add EULA button
  
 2.   Browse to the desired text file containing the EULA text.
  
 {info:title=Note}
 The EULA must be a plain text file and cannot contain any formatting (such as HTML tags) or special characters.
 {info}
  
 3.   Select the EULA text file.
  
 4.   Click Open
  
 * *Export Metadata Only*
 Selecting this option allows the user to create an OVF without any virtual disk(s). This is useful when the user needs an OVF without virtual disk information.
  
  
 h4. *Advanced Import Capabilities*
 New to the Project Kensho 1.3 OVF Tool is support for a range of OVF virtual appliance import options. When selecting one or more OVF virtual appliances to import, the utility presents the following options:
  
 !image8.jpg!
 {color:#4f81bd}*Figure 8 \- Import Options*{color}
  
 * *Verify Digital Signature*
 Selecting this option forces the import process to verify the digital signature that was used to sign the OVF during export. If the verification fails, this typically indicates that the OVF has been tampered with.
  
 * *Verify Manifest Content*
 Selecting this option forces the import process to verify that the content of the manifest file matches what is in the OVF package. If this verification fails, it typically indicates that files are missing.
  
 * *Validate OVF Package*
 Selecting this option forces the import process to validate the selected OVF file against the DMTF OVF 1.0.0 schema. This is useful to determine the compatibility of an OVF file.
  
 * *Import Metadata Only*
 Selecting this option imports the metadata only. This is useful if configuration content is all that is needed. The virtual machine content will be created from a template or an existing virtual disk will be attached after import.
  
 * *Run Operating System Fixups*
 Selecting this option runs automated scripts against the imported VMware based virtual appliance. This is necessary to ensure the VM boots properly. Select this option for Windows or Linux virtual machines imported from VMware sources. Fixup of virtual machines with more than two virtual disks is unsupported.
  
  
 h4. *VM to Host Resource Mapping Wizard*
  
 The Project Kensho OVF Tool allows users to map system, storage, and networking resources defined in the OVF virtual appliance to the resources on the virtual machine host(s). This ensures that prior to import, the proper resources are paired and the virtual machine can power on minimizing administrative tasks.
  
 Mapping is performed by selecting items (one or more) in the left column of the Mapping dialog and then selecting a target device in the right
  
 The padlock icon !image007.jpg! depicts that a mapping of a VM device to Host resource has been set. Individual mappings may be cleared by selecting and clearing the lock icon.
  
 An existing OVF to Host resource mapping may be cleared by clicking the *Clear* button on the Import tab.
  
 1.   Begin the resource mapping process by Clicking the Mapping button !newvirtualnetwork_32.jpg! in the Tool bar
  
 2.   The mapping wizard launches and presents the Systems tab (this is the target Host for a VM workload).
  
 !image9.jpg!
 {color:#4f81bd}*Figure 9 \- Unmapped VM CPU and memory workload*{color}
  
 3.  Select the desired host resource in the right pane
  
 4.  Select a VM resource(s) in the left pane
  
 !image10.jpg!
 {color:#4f81bd}8Figure 10 \- VM CPU and memory workload mapped Host*{color}
  
 5.  Click the *Next* button to map the Network resources.
  
 !image11.jpg!
 {color:#4f81bd}*Figure 11 \- Mapped VM Network Device to Hypervisor Network Device{color}
  
 6.   Select the desired host resource in the right pane
  
 7.   Select a VM resource(s) in the left pane
  
 8.   Click the *Next* button to map the Storage resources
  
 !image12.jpg!
 {color:#4f81bd}*Figure 12 \- Mapped VM Storage to Hypervisor Storage*{color}
  
 9.    Select the desired host resource in the right pane
  
 10.   Select a VM resource(s) in the left pane
  
 11.   Click *Done* to complete the wizard, save the mapping, and return to the Import screen.
  
 h4. *Converting an OVF package to an OVA and vice versa*
 The Project Kensho OVF Tool facilitates the conversion of any DMTF compliant OVF export to a single OVA file.
  
 To convert an OVF with the Project Kensho OVF Tool:
  
 1.   Select the Import Tab
  
 !image13.jpg!
 {color:#4f81bd}*Figure 13 \- OVA Menu*{color}
  
 2.   From the Kensho Library, select an OVF.
  
 3.   Right click the OVF and Select 'Convert to OVA'
  
 4.   The reverse process is used to convert an OVA into an OVF.
  
 {info:title=Note}
 The OVF icon !image013.jpg|width=26,height=26! depicts a folder that includes the OVF package configuration and associated file.
 The OVA icon !image014.jpg|width=26,height=26! indicates an OVF package that has been compressed, using tar format, into a single file with the extension .OVA
 The X icon !error_16.jpg|width=22,height=22! indicates an OVF package that is not compliant with the DMTF Standards.
 {info}
  
 h4. *Environment Tab*
 The environment tab is a read-only view of the virtual machine host resources and environment.
 !image14.jpg!
 {color:#4f81bd}*Figure 14 \- Environment Tab*{color}
  
 h3. {color:#00549f}VMware OVF Support{color}
  
 The Project Kensho OVF Tool facilitates importing VMware derived OVF content directly into a XenServer Storage Repository in the same manner as importing a XenConvert or Project Kensho produced OVF.
  
 It is important to note that not all VMware OVF content is equal. VMware OVF content produced through the latest VMware utilities will result in a higher degree of import success. The following VMware OVF content has been successfully tested:
  
 * vSphere 4
 * Virtual Infrastructure 3
 * VMware OVF Tool 0.9
 * VMware OVF Tool 1.0
 * VMware Studio 1.0
 * VMware Workstation 6.5.3
 * VMware Converter 4.0.x
 * VMware Converter 3.0.3
  
  
 h3.{color:#00549f}Snapshot Support{color}
  
 The Project Kensho OVF Tool now supports creating virtual appliances from virtual machines with snapshots. Both XenServer 5.5 and Hyper-V support virtual machine snapshots.
  
 When creating an OVF virtual appliance from a virtual machine with a snapshot, the current running state of the virtual machine is what the tool creates as a virtual appliance. This can also be described as the state that is experienced when the virtual machine is powered on.
  
 If a virtual machine contains multiple snapshots, only the current running state of the virtual machine is exported. No snapshot history or detail is exported as part of the virtual appliance
  
  

Configuring Debian (Lenny) 64-bit (v5.04) on XenServer 5.5

June 29, 2010 in citrix, virtualization, xen by admin

Page edited by Stephen Turner

This page provides details on how to install Debian Lenny 5.03 and 5.04 64-bit but should be repeatable for other Linux distributions and has been tested on XenServer 5.5 and XenServer 5.6 RC3.

Please note the following supportability disclaimer: Only OSs listed in the XenServer Virtual Machine Installation Guide is supported by Citrix Technical Support. The OS within this and related pages are not supported and are installed at the users own risk.

One prerequisite for this procedure is the VM be installed into an environment with working DHCP, DNS and internet access. This is due to DomU kernel updates will need to be downloaded from the internet.

Listed below is an outline of the overall process:
Installation Mode 2 (HVM mode, but can be switched into PV mode by installing/enabling PV kernel mode)

  • Create a VM is HMV mode by using the "Other install media" VM template
  • Performance a installation of the Linux guest OS,( in this case Lenny 5.04 64-bit)
  • Generate the Paravirtualised kernel and drivers
  • Use nano or vi text editor to amend "/etc/inittab"
  • Use nano or vi text editor to amend "/etc/fstab"
  • Use nano or vi text editor to amend "/boot/grub/menu.lst"
  • Shutdown VM
  • Identify <uuid> for newly created Linux guest VM
  • Execute "xe" commands to modify VM parameters for PV mode and boot.
  • Start-up VM in PV mode
  • Install XenTools

The ISO file for this distribution media can be obtained from http://cdimage.debian.org. The specific links for the 5.04 distribution is located at Debian Lenny amd64 5.04.

Procedure for Debian Lenny 5.04 64-bit

  1. Create a VM using the "Other install media" VM template.

  2. Give the new VM a name.

  3. Select the debain-504-amd64-DVD-1.iso or debain-503-amd64-DVD-1 media

  4. Select automatic placement of home server for VM is possible.

  5. Select required CPU and Memory settings for VM, (this example uses the default settings.

  6. Add virtual disk storage, ( this example uses the default 5GB settings)

  7. Select the required virtual network interface, ( this example uses the default single NIC settings)

  8. Finish VM creation and ensure VM is set to start automatically.

  9. Select "Install" from the Lenny amd64 installer boot menu.

  10. Select the required language.

  11. Select the required keyboard.

  12. Select the required country.

  13. Enter hostname.

  14. Accepted or enter DNS settings.

  15. Select the guided partition method that uses the entire disk.

  16. Select the disk partition displayed, this will reflect to disk size chosen back at step 6.

  17. Select the required disk partitioning scheme, (this example used "All files in one partition").

  18. Select "Finish partitioning and write changes to disk".

  19. Select yes to write the changes to disk.

  20. Enter a root password and confirm.

  21. Enter a new user name.

  22. Enter a password for the new user and confirm.

  23. Select "No" to scanning for another CD or DVD.

  24. Select "No" to use a network mirror (although if the VM has a working internet connection at this point, "Yes" can also be selected).

  25. Select "No" to participate in package usage survey.

  26. Use the spacebar to select or de-select the required software to install, (this example selected a standard system).

  27. Select "yes" to install the grub boot loader to master boot record, (MBR).

  28. Select "Continue" to complete Lenny Guest installation that will reboot the VM.

  29. Once the VM has booted the newly install Lenny amd64 guest operating system, login as root.

  30. Execute the command
    aptitude install linux-image-xen-amd64

    or when using Lenny 5.04

    aptitude install linux-image-2.6.26-2-xen-amd64

    should work but if in doubt execute

    aptitude search xen

    and select the latest DomU amd64 kernel image starting with linux-image.



  31. Press "y" to download the required kernel update from the internet.

  32. When the kernel has been installed and packaged be sure not to reboot the VM until three files have been edited. Use nano to edit /etc/inittab.

  33. Add the following new line at line 53
    co:2345:respawn:/sbin/getty 38400 hvc0


  34. Use nano to edit /etc/fstab switch from /dev/hd* to /dev/xvd*.

  35. Use nano to edit /boot/grub/menu.lst and change the line
    #kopt=root=/dev/hda1 ro

    to

    #kopt=root=/dev/xvda1 ro console=hvc0


  36. Also change the first two Debian GNU/Linux, kernel 2.6.26-2-xen-amd64 kernel boot lines to
    /boot/vmlinuz-2.6.26-2-xen-amd64 /root=/dev/xvda1 ro console=hvc0$

  37. Once all three files have been edited execute
    shutdown -h now

    to shutdown the VM then within XenCenter switch to the console tab of the XenServer host. At the host console, execute

    xe vm-list

    to obtain the uuid of the newly created VM.



  38. Identify the uuid for the newly created Linux guest VM then use your mouse to highlight it and right-click and select paste and copy to a text file.

  39. Execute
    xe vm-param-clear uuid=<uuid> param-name=HVM-boot-policy

    using the uuid pasted from step 38.


  40. Execute
    xe vm-param-set uuid=<uuid> PV-bootloader=pygrub

    using the uuid pasted from step 38.


  41. Execute
    xe vm-disk-list uuid=<uuid>

    using the uuid pasted from step 38.



  42. Identify the uuid for Disk 0 of the newly created Linux guest VM then use your mouse to highlight it and right-click and select paste and copy to a text file.

  43. Execute
    xe vbd-param-set uuid=<uuid> bootable=true

    using the disk uuid pasted from step 42.



  44. Start the Linux guest VM and login as root. (Please ensure that there is no CD/DVD connected or the VM may not start. Also note that if you experience any issue with the keyboard, exit and restart XenCenter).

  45. In XenCenter under the Storage tab for the VM, change the DVD drive to xs-tools.iso which is the XenTools media.

  46. Execute
    mount/dev/xvdd /mnt

    and then

    /mnt/Linux/install.sh

    When prompted to continue press "y".



  47. When the XenTools installation scripted has successfully completed you will the following message, "You should now reboot this Virtual Machine."

  48. When the VM has rebooted check the Virtualisation state in the general tab of the VM in XenCenter and if the state is "Optimised (version 5.5 installed)" then the procedure is completed.

Changes between revision 6 and revision 7:

 This page provides details on how to install Debian Lenny 5.03 and 5.04 64-bit but should be repeatable for other Linux distributions and has been tested on XenServer 5.5 and XenServer 5.6 RC3.
  
 {info}
 Please note the following supportability disclaimer: Only OSs listed in the XenServer Virtual Machine Installation Guide is supported by Citrix Technical Support. The OS within this and related pages are not supported and are installed at the users own risk.
 {info}
  
 One prerequisite for this procedure is the VM be installed into an environment with working DHCP, DNS and internet access. This is due to DomU kernel updates will need to be downloaded from the internet.
  
 Listed below is an outline of the overall process:
 Installation Mode 2 (HVM mode, but can be switched into PV mode by installing/enabling PV kernel mode)
 - Create a VM is HMV mode by using the "Other install media" VM template
 - Performance a installation of the Linux guest OS,( in this case Lenny 5.04 64-bit)
 - Generate the Paravirtualised kernel and drivers
 - Use nano or vi text editor to amend "/etc/inittab"
 - Use nano or vi text editor to amend "/etc/fstab"
 - Use nano or vi text editor to amend "/boot/grub/menu.lst"
 - Shutdown VM
 - Identify <uuid> for newly created Linux guest VM
 - Execute "xe" commands to modify VM parameters for PV mode and boot.
 - Start-up VM in PV mode
 - Install XenTools
  
 The ISO file for this distribution media can be obtained from [http://cdimage.debian.org|http://cdimage.debian.org]. The specific links for the 5.04 distribution is located at [Debian Lenny amd64 5.04|http://cdimage.debian.org/debian-cd/5.0.4/amd64/iso-dvd/].
  
 h2. Procedure for Debian Lenny 5.04 64-bit
  
 # Create a VM using the "Other install media" VM template.
 \\ !1.jpg|align=centre!\\
 # Give the new VM a name.
 \\ !2.jpg|align=centre!\\
 # Select the debain-504-amd64-DVD-1.iso or debain-503-amd64-DVD-1 media
 \\ !3.jpg|align=centre!\\
 # Select automatic placement of home server for VM is possible.
 \\ !4.jpg|align=centre!\\
 # Select required CPU and Memory settings for VM, (this example uses the default settings.
 \\ !5.jpg|align=centre!\\
 # Add virtual disk storage, ( this example uses the default 5GB settings)
 \\ !6.jpg|align=centre!\\
 # Select the required virtual network interface, ( this example uses the default single NIC settings)
 \\ !7.jpg|align=centre!\\
 # Finish VM creation and ensure VM is set to start automatically.
 \\ !8.jpg|align=centre!\\
 # Select "Install" from the Lenny amd64 installer boot menu.
 \\ !9.jpg|align=centre!\\
 # Select the required language.
 \\ !10.jpg|align=centre!\\
 # Select the required keyboard.
 \\ !11.jpg|align=centre!\\
 # Select the required country.
 \\ !12.jpg|align=centre!\\
 # Enter hostname.
 \\ !13.jpg|align=centre!\\
 # Accepted or enter DNS settings.
 \\ !14.jpg|align=centre!\\
 # Select the guided partition method that uses the entire disk.
 \\ !15.jpg|align=centre!\\
 # Select the disk partition displayed, this will reflect to disk size chosen back at step 6. !16.jpg|align=centre!\\
 # Select the required disk partitioning scheme, (this example used "All files in one partition"). !17.jpg|align=centre!\\
 # Select "Finish partitioning and write changes to disk". !18.jpg|align=centre!\\
 # Select yes to write the changes to disk. !19.jpg|align=centre!\\
 # Enter a root password and confirm. !20.jpg|align=centre!\\
 # Enter a new user name. !21.jpg|align=centre!\\
 # Enter a password for the new user and confirm. !22.jpg|align=centre!\\
 # Select "No" to scanning for another CD or DVD. !23.jpg|align=centre!\\
 # Select "No" to use a network mirror (although if the VM has a working internet connection at this point, "Yes" can also be selected). !24.jpg|align=centre!\\
 # Select "No" to participate in package usage survey. !25.jpg|align=centre!\\
 # Use the spacebar to select or de-select the required software to install, (this example selected a standard system). !26.jpg|align=centre!\\
 # Select "yes" to install the grub boot loader to master boot record, (MBR). !27.jpg|align=centre!\\
 # Select "Continue" to complete Lenny Guest installation that will reboot the VM. !28.jpg|align=centre!\\
 # Once the VM has booted the newly install Lenny amd64 guest operating system, login as root. !29.jpg|align=centre!\\
 # Execute the command
 {code}
 aptitude install linux-image-xen-amd64
 {code}
 or when using Lenny 5.04
 {code}
 aptitude install linux-image-2.6.26-2-xen-amd64
 {code}
 should work but if in doubt execute
 {code}
 aptitude search xen
 {code}
 and select the latest DomU amd64 kernel image starting with _linux-image_. !30.jpg|align=centre!\\
 \\
 # Press "y" to download the required kernel update from the internet. !31.jpg|align=centre!\\
 # When the kernel has been installed and packaged be sure not to reboot the VM until three files have been edited. Use nano to edit _/etc/inittab_. !32.jpg|align=centre!\\
 # Add the following new line at line 53
 {code}
 co:2345:respawn:/sbin/getty 38400 hvc0
 {code}
 !32b.jpg|align=centre!\\
 # Use nano to edit _/etc/fstab_ switch from _/dev/hd\*_ to _/dev/xvd\*_. !33.jpg|align=centre!\\
 # Use nano to edit _/boot/grub/menu.lst_ and change the line
 {code}
 #kopt=root=/dev/hda1 ro
 {code}
 to
 {code}
 #kopt=root=/dev/xvda1 ro console=hvc0
 {code} !34.jpg|align=centre!\\
 \\
 # Also change the first two _Debian GNU/Linux, kernel 2.6.26-2-xen-amd64_ kernel boot lines to
 {code}
  /boot/vmliuz-2.6.26-2-xen-amd64 /root=/dev/xvda1 ro console=hvc0$
  /boot/vmlinuz-2.6.26-2-xen-amd64 /root=/dev/xvda1 ro console=hvc0$
 {code} !35.jpg|align=centre!\\
 # Once all three files have been edited execute
 {code}
 shutdown -h now
 {code}
 to shutdown the VM then within XenCenter switch to the console tab of the XenServer host. At the host console, execute
 {code}
 xe vm-list
 {code}
 to obtain the uuid of the newly created VM. !36.jpg|align=centre!\\
 \\
 # Identify the uuid for the newly created Linux guest VM then use your mouse to highlight it and right-click and select paste and copy to a text file.
 !37.jpg|align=centre!\\
 # Execute
 {code}
 xe vm-param-clear uuid=<uuid> param-name=HVM-boot-policy
 {code}
 using the uuid pasted from step 38. !38.jpg|align=centre!\\
 # Execute
 {code}
 xe vm-param-set uuid=<uuid> PV-bootloader=pygrub
 {code}
 using the uuid pasted from step 38. !39.jpg|align=centre!\\
 # Execute
 {code}
 xe vm-disk-list uuid=<uuid>
 {code}
 using the uuid pasted from step 38. !40.jpg|align=centre!\\
 \\
 # Identify the uuid for Disk 0 of the newly created Linux guest VM then use your mouse to highlight it and right-click and select paste and copy to a text file. !41.jpg|align=centre!\\
 # Execute
 {code}
 xe vbd-param-set uuid=<uuid> bootable=true
 {code}
 using the disk uuid pasted from step 42. !42.jpg|align=centre!\\
 \\
 # Start the Linux guest VM and login as root. (Please ensure that there is no CD/DVD connected or the VM may not start. Also note that if you experience any issue with the keyboard, exit and restart XenCenter). !44.jpg|align=centre!\\
 # In XenCenter under the Storage tab for the VM, change the DVD drive to xs-tools.iso which is the XenTools media. !43.jpg|align=centre!\\
 # Execute
 {code}
 mount/dev/xvdd /mnt
 {code}
 and then
 {code}
 /mnt/Linux/install.sh
 {code}
 When prompted to continue press "y". !45.jpg|align=centre!\\
 \\
 # When the XenTools installation scripted has successfully completed you will the following message, "You should now reboot this Virtual Machine." !46.jpg|align=centre!\\
 # When the VM has rebooted check the Virtualisation state in the general tab of the VM in XenCenter and if the state is "Optimised (version 5.5 installed)" then the procedure is completed. !47.jpg|align=centre!\\

HelloWorld Example – C Sharp

June 28, 2010 in citrix, virtualization, xen by admin

Page edited by Stephen Turner

Introduction

In this example we will run through how to create a C# version of the HelloWorld powershell example.

It is assumed that you have read through that example for an understanding of the plugin objectives and how to package/resource your plugin.

This example will concentrate on writing a C# console app which provides the same behaviour as the PowerShell example. It also covers how to deal with the parameters which are passed into executables rather than a PowerShell script.

Requirements

The first step is to install the following requirements:

Requirement
Download Location
Microsoft Visual Studio 2008 express http://www.microsoft.com/express/downloads/
Citrix XenCenter v5.6
http://www.citrix.com/xenserver/download
XenServer C# Bindings v5.6
http://community.citrix.com/display/xs/Download+SDKs

You will also need the pre-requisites of the HelloWorld powershell example if you wish to package up the plugin as described in that example. Please refer to the other example for an explaination of how to do this.

XCPlugin file

The plugin configuration file we will be using here is similar to that in the HelloWorld powershell example, except we will be using a Shell command rather than a PowerShell command. The Shell command can target any type of executable file and passes information as parameters rather than by defining variables as the PowerShell command does.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE XenCenterPlugin PUBLIC "-//XENCENTERPLUGIN//DTD XENCENTERPLUGIN1//EN" "xencenter-1.dtd">
<XenCenterPlugin
	xmlns="http://www.citrix.com/XenCenter/Plugins/schema"
	version="1">
	<MenuItem
		name="hello-menu-item"
		menu="view"
		serialized="none">
		<Shell
			filename="Plugins\Citrix\HelloWorld\HelloWorld.exe"
			window="true"
		/>
	</MenuItem>
</XenCenterPlugin>

Notice that we are using the window parameter set to true in this example, as we will be showing the plugin output on the console window.

C# Code

We are going to write this example in C# and compile it into an executable to target from our plugin MenuItem. Create a C# Console Application project in Visual Studio and reference in the XenServer library from the v5.6 SDK.

We can now begin editing the Program.cs file in your project. The way we handle parameters when using a Shell command is slightly different to the PowerShell Commands. Recall that each parameter set from XenCenter consists of four parameters and describes a selection in the XenCenter resource list. The first thing we do is to read off these parameters from the executable arguaments in groups of four to get each parameter set:

static void Main(string[] args)
{
   List<ParameterSet> ParamSets;
   SeparateParams(args, out ParamSets);
}

private static void SeparateParams(string[] args, out List<ParameterSet> ParamSets)
{
   ParamSets = new List<ParameterSet>();
   for (int i = 0; i < args.Length; i += 4)
   {
      ParamSets.Add(new ParameterSet(args[i], args[i + 1], args[i + 2], args[i + 3]));
   }
}

public class ParameterSet
{
   public string ServerURL = "";
   public string SessionRef = "";
   public string SelectedObjectClass = "";
   public string SelectedObjectUuid = "";

   public ParameterSet(string ServerURL, string SessionRef, string SelectedObjectClass, string SelectedObjectUuid)
   {
      this.ServerURL = ServerURL;
      this.SessionRef = SessionRef;
      this.SelectedObjectClass = SelectedObjectClass;
      this.SelectedObjectUuid = SelectedObjectUuid;
   }
}

We can now use some of same logic that we did in the PowerShell example, going through each parameter set at a time and taking a list of selected object names - also noting if the XenCenter node is selected.

bool XenCenterNodeSelected = false;
List<string> names = new List<string>();
foreach (ParameterSet pset in ParamSets)
{
	if (pset.SelectedObjectClass == "blank")
	{
		// Selecting the XenCenter node adds a parameter set per connected server, with the obj params set to "blank"
		if (XenCenterNodeSelected)
			continue;

		names.Add("XenCenter");
		XenCenterNodeSelected = true;
	}
	else if (pset.SessionRef == "null")
	{
		// Disconnected servers have no session information, and everything apart from the objects class is marked as "null"
		names.Add("a disconnected server");
	}
	else
	{
		// Use the session ref passedin by XenCenter. This means we don't have to log in or out.
		Session session = new Session(pset.ServerURL, pset.SessionRef);
		string name = "";
		// Note: Alternatively you could use reflection here to construct and execute the correct methods
		switch (pset.SelectedObjectClass.ToLowerInvariant())
		{
			case "pool":
				name = Pool.get_record(session, Pool.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
				break;
			case "vm":
				name = VM.get_record(session, VM.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
				break;
			case "host":
				name = Host.get_record(session, Host.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
				break;
			case "sr":
				name = SR.get_record(session, SR.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
				break;
			case "network":
				name = Network.get_record(session, Network.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
				break;
			case "vdi":
				name = VDI.get_record(session, VDI.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
				break;
			default:
				name = "an unknown object";
				break;
		}
		names.Add(name);
	}
}

You can see here that we switch on the class of the parameter set, collect the reference to the server object using get_by_uuid and then using that reference to get the object itself. You could remove the need to do an exhaustive switch such as this by using reflection if you desired.

Finally we output our greeting using this list of names to the console, using a sentence construct similar to the PowerShell version:

string outputString = string.Format("Hello from {0}", names[0]);
	if (names.Count > 1)
	{
		outputString += PrettySentence(names.GetRange(1, names.Count - 1));
	}
	System.Console.WriteLine(outputString);
}

private static string PrettySentence(List<string> items)
{
	string output = "";
	//we are aiming for "string_1, string_1, string_1...string_n-1 and string_n"
	for (int i = 0; i < items.Count - 1; i++)
	{
		output += string.Format(", {0}", items[i]);
	}
	output += string.Format(" and {0}", items[items.Count - 1]);
	return output;
}

If you try and execute this code you will be blocked by security failures. As part of using the SDK it is required that you define a policy for handling certificate validation.

System.Net.ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;

For the purposes of this simple example you could use the following method, but you should strongly consider implementing some validation before releasing a plugin.

// Ignore all cert validation (not recommended)
internal static bool ValidateServerCertificate(
	object sender,
	X509Certificate certificate,
	X509Chain chain,
	SslPolicyErrors sslPolicyErrors)
{
	return true;
}

The complete code, including some error handling can be found here.

Deployment

See the HelloWorld powershell example for details of how to produce your resources dll and package your files up into an installer.

Summary

This example covered the C# code you would need to write to communicate with XenServer and produce similar results to the PowerShell HelloWorld example.

  • Compile a console application using Program.cs and referencing XenServer.dll from the XenServer C# Bindings to get your executable
  • Use the HelloWorld.xcplugin.xml as your plugin configuration file
  • HelloWorld.png is an image file you can us for your icon

Put the compiled executable, the configuration file, the icon image file, and XenServer.dll and CookComputing.XmlRpcV2.dll from the XenServer C# Bindings in <XenCenterInstallDirectory>\Plugins\Citrix\HelloWorld\ and start XenCenter to see the new menu item.

Screenshots

Changes between revision 7 and revision 8:

 h2. Introduction
  
 In this example we will run through how to create a C# version of the HelloWorld [powershell example|xs:HelloWorld Example - PowerShell].
  
 It is assumed that you have read through that example for an understanding of the plugin objectives and how to package/resource your plugin.
  
 This example will concentrate on writing a C# console app which provides the same behaviour as the PowerShell example. It also covers how to deal with the parameters which are passed into executables rather than a PowerShell script.
  
 h2. Requirements
  
 The first step is to install the following requirements:
 || Requirement \\ || Download Location \\ ||
 | Microsoft Visual Studio 2008 express | [http://www.microsoft.com/express/downloads/] |
 | Citrix {nl:XenCenter} v5.6 \\ | [http://www.citrix.com/xenserver/download] |
 | XenServer C# Bindings v5.6 \\ | [http://community.citrix.com/display/xs/Download+SDKs] |
 You will also need the pre-requisites of the HelloWorld [powershell example|xs:HelloWorld Example - PowerShell] if you wish to package up the plugin as described in that example. Please refer to the other example for an explaination of how to do this.
  
 h2. XCPlugin file
  
 The plugin configuration file we will be using here is similar to that in the HelloWorld [powershell example|xs:HelloWorld Example - PowerShell], except we will be using a Shell command rather than a PowerShell command. The Shell command can target any type of executable file and passes information as parameters rather than by defining variables as the PowerShell command does.
 {code}
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE XenCenterPlugin PUBLIC "-//XENCENTERPLUGIN//DTD XENCENTERPLUGIN1//EN" "xencenter-1.dtd">
 <XenCenterPlugin
  xmlns="http://www.citrix.com/XenCenter/Plugins/schema"
  version="1">
  <MenuItem
  name="hello-menu-item"
  menu="view"
  serialized="none">
  <Shell
  filename="Plugins\Citrix\HelloWorld\HelloWorld.exe"
  window="true"
  />
  </MenuItem>
 </XenCenterPlugin>
 {code}
 Notice that we are using the window parameter set to true in this example, as we will be showing the plugin output on the console window.
  
 h2. C# Code
  
 We are going to write this example in C# and compile it into an executable to target from our plugin MenuItem. Create a C# Console Application project in Visual Studio and reference in the XenServer library from the v5.6 SDK.
  
 We can now begin editing the Program.cs file in your project. The way we handle parameters when using a Shell command is slightly different to the PowerShell Commands. Recall that each parameter set from XenCenter consists of four parameters and describes a selection in the XenCenter resource list. The first thing we do is to read off these parameters from the executable arguaments in groups of four to get each parameter set:
 {code}
 static void Main(string[] args)
 {
  List<ParameterSet> ParamSets;
  SeparateParams(args, out ParamSets);
 }
  
 private static void SeparateParams(string[] args, out List<ParameterSet> ParamSets)
 {
  ParamSets = new List<ParameterSet>();
  for (int i = 0; i < args.Length; i += 4)
  {
  ParamSets.Add(new ParameterSet(args[i], args[i + 1], args[i + 2], args[i + 3]));
  }
 }
  
 public class ParameterSet
 {
  public string ServerURL = "";
  public string SessionRef = "";
  public string SelectedObjectClass = "";
  public string SelectedObjectUuid = "";
  
  public ParameterSet(string ServerURL, string SessionRef, string SelectedObjectClass, string SelectedObjectUuid)
  {
  this.ServerURL = ServerURL;
  this.SessionRef = SessionRef;
  this.SelectedObjectClass = SelectedObjectClass;
  this.SelectedObjectUuid = SelectedObjectUuid;
  }
 }
 {code}
 We can now use some of same logic that we did in the PowerShell example, going through each parameter set at a time and taking a list of selected object names - also noting if the XenCenter node is selected.
 {code}
 bool XenCenterNodeSelected = false;
 List<string> names = new List<string>();
 foreach (ParameterSet pset in ParamSets)
 {
  if (pset.SelectedObjectClass == "blank")
  {
  // Selecting the XenCenter node adds a parameter set per connected server, with the obj params set to "blank"
  if (XenCenterNodeSelected)
  continue;
  
  names.Add("XenCenter");
  XenCenterNodeSelected = true;
  }
  else if (pset.SessionRef == "null")
  {
  // Disconnected servers have no session information, and everything apart from the objects class is marked as "null"
  names.Add("a disconnected server");
  }
  else
  {
  // Use the session ref passedin by XenCenter. This means we don't have to log in or out.
  Session session = new Session(pset.ServerURL, pset.SessionRef);
  string name = "";
  // Note: Alternatively you could use reflection here to construct and execute the correct methods
  switch (pset.SelectedObjectClass.ToLowerInvariant())
  {
  case "pool":
  name = Pool.get_record(session, Pool.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
  break;
  case "vm":
  name = VM.get_record(session, VM.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
  break;
  case "host":
  name = Host.get_record(session, Host.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
  break;
  case "sr":
  name = SR.get_record(session, SR.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
  break;
  case "network":
  name = Network.get_record(session, Network.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
  break;
  case "vdi":
  name = VDI.get_record(session, VDI.get_by_uuid(session, pset.SelectedObjectUuid)).name_label;
  break;
  default:
  name = "an unknown object";
  break;
  }
  names.Add(name);
  }
 }
 {code}
 You can see here that we switch on the class of the parameter set, collect the reference to the server object using _get_by_uuid_ and then using that reference to get the object itself. You could remove the need to do an exhaustive switch such as this by using reflection if you desired.
  
 Finally we output our greeting using this list of names to the console, using a sentence construct similar to the PowerShell version:
 {code}
 string outputString = string.Format("Hello from {0}", names[0]);
  if (names.Count > 1)
  {
  outputString += PrettySentence(names.GetRange(1, names.Count - 1));
  }
  System.Console.WriteLine(outputString);
 }
  
 private static string PrettySentence(List<string> items)
 {
  string output = "";
  //we are aiming for "string_1, string_1, string_1...string_n-1 and string_n"
  for (int i = 0; i < items.Count - 1; i++)
  {
  output += string.Format(", {0}", items[i]);
  }
  output += string.Format(" and {0}", items[items.Count - 1]);
  return output;
 }
 {code}
 If you try and execute this code you will be blocked by security failures. As part of using the SDK it is required that you define a policy for handling certificate validation.
 {code}
 System.Net.ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate;
 {code}
 For the purposes of this simple example you could use the following method, but you should strongly consider implementing some validation before releasing a plugin.
 {code}
 // Ignore all cert validation (not recommended)
 internal static bool ValidateServerCertificate(
  object sender,
  X509Certificate certificate,
  X509Chain chain,
  SslPolicyErrors sslPolicyErrors)
 {
  return true;
 }
 {code}\\
 The complete code, including some error handling can be found [here|^Program.cs].
 \\
 h2. Deployment
  
 See the HelloWorld [powershell example|xs:HelloWorld Example - PowerShell] for details of how to produce your resources dll and package your files up into an installer.
  
 h2. Summary
  
 This example covered the C# code you would need to write to communicate with XenServer and produce similar results to the PowerShell HelloWorld example.
  
 - Compile a project using [Program.cs|^Program.cs] to get your executable
  - Compile a console application using [Program.cs|^Program.cs] and referencing XenServer.dll from the XenServer C# Bindings to get your executable
 - Use the [HelloWorld.xcplugin.xml|^HelloWorld.xcplugin.xml] as your plugin configuration file
 - [^HelloWorld.png] is an image file you can us for your icon
  
 Put the compiled executable, the configuration file and the icon image file in <XenCenterInstallDirectory>\Plugins\Citrix\HelloWorld\ and start XenCenter to see the new menu item.
  Put the compiled executable, the configuration file, the icon image file, and XenServer.dll and CookComputing.XmlRpcV2.dll from the XenServer C# Bindings in <XenCenterInstallDirectory>\Plugins\Citrix\HelloWorld\ and start XenCenter to see the new menu item.
  
  
 h2. Screenshots
 !HelloWorldCSharpPrompt.png|align=centre!

HelloWorld Example – PowerShell

in citrix, virtualization, xen by admin

Page edited by Stephen Turner

Introduction

Here is a short example which will guide you through the creation of a XenCenter plugin.

Objective: We would like a new menu item in XenCenter which says "hello from ..." followed by the names of whichever objects are selected in the XenCenter resource list (treeview).

In this example we shall be using the XenServerPSSnapIn PowerShell bindings to communicate with the servers listed in XenCenter.

Requirements

The first step is to install the following requirements:

Requirement
Download Location
.Net Framework v2.0
http://msdn.microsoft.com/en-us/netframework/aa731542.aspx
.Net Framework v2.0 SDK
http://msdn.microsoft.com/en-us/netframework/aa731542.aspx
Microsoft PowerShell v1.0 http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx
Citrix XenCenter v5.6
http://www.citrix.com/xenserver/download
Citrix XenServerPSSnapIn v5.6
http://community.citrix.com/cdn/xs/sdks
Create-PluginInstaller.ps1
Create-PluginInstaller.ps1

Also create the XenServerPSSnapIn directory as described on the XenCenter Plugins page.

XCPlugin file

To add a menu item into XenCenter and call our PowerShell script we need to create a plugin configuration file.

We start with the XenCenterPlugin node with the following attributes:

  • xmlns - Specifies the schema of the XML file.
  • version - The XenCenter Plugins version, we are using version 1.
<XenCenterPlugin xmlns="http://www.citrix.com/XenCenter/Plugins/schema"
 version="1">

To create a menu item we add a MenuItem node under the XenCenterPlugin node. We give this three attributes:

  • name - For identfying the menu item.
  • menu - The name of the menu under which the menu item should appear. Let's use the 'View' menu.
  • serialized - Decides if copies of the plugin running simutaneously are allowed for the same object. Here we do not limit this so we set to "none".
<MenuItem name="hello-menu-item" menu="view" serialized="none">

Next we add the XenServerPowerShell tag which points to a PowerShell script to run:

  • filename - The filepath of our target PowerShell script, relative to the install directory of the XenCenter executable.
  • window - Whether to show the console window which runs the script. We don't want this, lets turn it off.
<XenServerPowerShell filename="Plugins\Citrix\HelloWorld\HelloWorld.ps1" window="false" />

Close off all the tags and save as HelloWorld.xcplugin.xml. The name of this file must be the same name as the name of the plugin directory in which it resides.

Resources

The next step is to add some resources which provide strings and image paths for the plugin. These are stored in DLLs so that the correct language (if other cultures are provided) can be loaded at run-time.

First we need to create the resx file. This can be done using Visual Studio. Add strings for the menu-item labels, copyright statements, filepaths to icons etc. The names of the resources strings should be <name>.<property>, where <name> is the name given to the tag and <property> is one of the properties found in the specification. Here is the resources table for this plugin.

Name
Value
HelloWorld.description XenServer PowerShell plugin example.
HelloWorld.copyright © Citrix Systems Inc. 2009
HelloWorld.link http://community.citrix.com/xencenter
hello-menu-item.label Hello World!
hello-menu-item.description Displays 'Hello World' from the selected object.
hello-menu-item.icon Plugins\Citrix\HelloWorld\HelloWorld.png

 The final step is to convert this .resx into a DLL. We do this with two tools:

  1. ResGen.exe - Creates a .resources file from the resx. This can be found in the .NET framework SDK.
  2. Al.exe - Embeds the .resources file into a DLL. We specify we want to create a library, the file we wish to embed, that we need the invariant culture and the name of the DLL file. Al.exe is in the .NET framework directory.
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ResGen.exe HelloWorld.resx
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\al.exe /t:lib /embed:HelloWorld.resources
 /culture:0x007F /out:HelloWorld.resources.dll

Attachments: HelloWorld.resx, HelloWorld.resources.dll, HelloWorld.png

The PowerShell script

We now need to write the script, which will compile a list of names from the selected objects in the resource list and show a message box with our "Hello from ..." in it.

XenCenter will pass in parameter sets to your plugin to let you know what is selected in the resource list, and to enable you to communicate with your connected servers. PowerShell plugins can access these parameter sets from the $ObjInfoArray variable which XenCenter populates before running your script.

$ObjInfoArray

This handy variable is an array of hashmaps. Each map represents a parameter set with the following keys - for each $map in $ObjInfoArray:

  • $map["url"] - The URL of the server which owns the object selected in the tree view
  • $map["sessionRef"] - An authenticated session reference for the server (allows the script to log into the server)
  • $map["class"] - The type of the object selected: Server, VM etc
  • $map["objUuid"] - The UUID for the selected object.

You will get:

  • One parameter set per object selected in the resource list.
  • One parameter set per object in a folder if a folder is selected.
  • One parameter set per connected server if the user has the XenCenter node selected. These are provided to allow you to communicate with any server if launched from the XenCenter node, however the "class" and "objUuid" keys will be marked as blank.

Here is an example of how to use this array:

$SelectedObjectNames=@();
$XenCenterNodeSelected = 0;
#the object info array contains hashmaps, each of which represent a parameter set and describe a target in the XenCenter resource list
foreach($parameterSet in $ObjInfoArray)
{
	if ($parameterSet["class"] -eq "blank")
	{
		#When the XenCenter node is selected a parameter set is created for each of your connected servers with the class and objUuid keys marked as blank
		if ($XenCenterNodeSelected)
		{
			continue
		}
		$XenCenterNodeSelected = 1;
		$SelectedObjectNames += "XenCenter"
	}
	elseif ($parameterSet["sessionRef"] -eq "null")
	{
		#When a disconnected server is selected there is no session information, we get null for everything except class
		$SelectedObjectNames += "a disconnected server"
	}
	else
	{
		Connect-XenServer -url $parameterSet["url"] -opaqueref $parameterSet["sessionRef"]
		#Use $class to determine which server objects to get
		#-properties allows us to filter the results to just include the selected object
		$exp = "Get-XenServer:{0} -properties @{{uuid='{1}'}}" -f $parameterSet["class"], $parameterSet["objUuid"]
		$obj = Invoke-Expression $exp
		$SelectedObjectNames += $obj.name_label;
	}
}

Looking at that final else block you can see that before any server commands can be used we need to connect to the server. We use the sessionRef from the existing connection in XenCenter which means we don't need to provide any new credentials.

Connect-XenServer -url $parameterSet["url"] -opaqueref $parameterSet["sessionRef"]

Then when we use XenServer commands they automatically use the session from the last Connect-XenServer call. We construct an expression using the class and uuid information we were given which will retrieve the object selected in the resource list.

$exp = "Get-XenServer:{0} -properties @{{uuid='{1}'}}" -f $parameterSet["class"], $parameterSet["objUuid"]
$obj = Invoke-Expression $exp

Because being pretty is important the following bit of code constructs a nice sentence out of our list of names, but equally you could just string join your name array at this point.

$NameString = "Hello from {0}" -f $SelectedObjectNames[0];
if ($SelectedObjectNames.length -gt 1)
{
	#we are aiming for "name_1, name_2, name_3...name_n-1 and name_n"
	for ($i=1; $i -lt $SelectedObjectNames.length - 1; $i++)
	{
		$NameString += ", {0}" -f $SelectedObjectNames[$i]
	}
	$NameString += " and {0}" -f $SelectedObjectNames[$SelectedObjectNames.length - 1]
}

Finally we use .NET Windows Forms to create an alert box by loading the correct DLL.

[Reflection.Assembly]::loadwithpartialname('system.windows.forms')
[system.Windows.Forms.MessageBox]::show($NameString, "Hello World")

The full PowerShell script is HelloWorld.ps1

Deployment

The best way to distribute your XenCenter plugin is to package your plugin into a single MSI (Windows Installer) file.

Using a Windows Installer allows you to make sure the plugin is being installed into the correct place (by checking the XenCenter InstallDir registry key) and it gives versioning. A newer version will automatically uninstall the old version and then install the new one.

You can use the Create-PluginInstaller.ps1 PowerShell script to do this. The script requires WiX 2.0 and should be executed from your XenCenter install directory. The following command was used to makean msi for this plugin:

 .\Create-PluginInstaller.ps1 -out HelloWorld.msi -title "XenCenter Hello World Plugin"
 -description "Sample plugin for XenCenter" -manufacturer Citrix -upgrade_code $([System.Guid]::NewGuid().ToString())

Summary

This exampled covered all the basics of producing a MenuItem plugin for XenCenter using PowerShell. It also introduced how to resource and deploy your plugin.

Here are all the files you need to run the plugin again:

Extract them to <XenCenterInstallDirectory>\Plugins\Citrix\HelloWorld\ and launch XenCenter to see the new menu item.

Screenshots








Changes between revision 10 and revision 11:

 h2. Introduction
  
 Here is a short example which will guide you through the creation of a {nl:XenCenter} plugin.
  
 *Objective:* We would like a new menu item in {nl:XenCenter} which says "hello from ..." followed by the names of whichever objects are selected in the {nl:XenCenter} resource list (treeview).
  
 In this example we shall be using the {nl:XenServerPSSnapIn} {nl:PowerShell} bindings to communicate with the servers listed in {nl:XenCenter}.
  
 h2. *Requirements*
  
 The first step is to install the following requirements:
 || Requirement \\ || Download Location \\ ||
 | .Net Framework v2.0 \\ | [http://msdn.microsoft.com/en-us/netframework/aa731542.aspx] |
 | .Net Framework v2.0 SDK \\ | [http://msdn.microsoft.com/en-us/netframework/aa731542.aspx] |
 | Microsoft {nl:PowerShell} v1.0 | [http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx] |
 | Citrix {nl:XenCenter} v5.6 \\ | [http://www.citrix.com/xenserver/download] |
 | Citrix {nl:XenServerPSSnapIn} v5.6 \\ | [http://community.citrix.com/cdn/xs/sdks] |
 | Create\-{nl:PluginInstaller}.ps1 \\ | [HelloWorld Example - PowerShell^Create-PluginInstaller.ps1] |
  
  Also create the XenServerPSSnapIn directory as described on the [XenCenter Plugins] page.
  
 h2. XCPlugin file
  
 To add a menu item into {nl:XenCenter} and call our PowerShell script we need to create a plugin configuration file.
  
 We start with the {nl:XenCenterPlugin} node with the following attributes:
 * xmlns - Specifies the schema of the XML file.
 * version - The {nl:XenCenter} Plugins version, we are using version 1.
  
 {code:xml}
 <XenCenterPlugin xmlns="http://www.citrix.com/XenCenter/Plugins/schema"
  version="1">
 {code}
 To create a menu item we add a {nl:MenuItem} node under the {nl:XenCenterPlugin} node. We give this three attributes:
 * name - For identfying the menu item.
 * menu - The name of the menu under which the menu item should appear. Let's use the 'View' menu.
 * serialized - Decides if copies of the plugin running simutaneously are allowed for the same object. Here we do not limit this so we set to "none".
  
 {code:xml}
 <MenuItem name="hello-menu-item" menu="view" serialized="none">
 {code}
 Next we add the {nl:XenServerPowerShell} tag which points to a {nl:PowerShell} script to run:
 * filename - The filepath of our target {nl:PowerShell} script, relative to the install directory of the {nl:XenCenter} executable.
 * window - Whether to show the console window which runs the script. We don't want this, lets turn it off.
  
 {code:xml}
 <XenServerPowerShell filename="Plugins\Citrix\HelloWorld\HelloWorld.ps1" window="false" />
 {code}
 Close off all the tags and save as [HelloWorld Example - PowerShell^HelloWorld.xcplugin.xml]. The name of this file must be the same name as the name of the plugin directory in which it resides.
  
 h2. Resources
  
 The next step is to add some resources which provide strings and image paths for the plugin. These are stored in DLLs so that the correct language (if other cultures are provided) can be loaded at run-time.
  
 First we need to create the resx file. This can be done using Visual Studio. Add strings for the menu-item labels, copyright statements, filepaths to icons etc. The names of the resources strings should be _<name>.<property>_, where _<name>_ is the name given to the tag and _<property>_ is one of the properties found in the [specification|XenCenter Plugins^xc_plugins.pdf]. Here is the resources table for this plugin.
 || Name \\ || Value \\ ||
 | {nl:HelloWorld}.description | {nl:XenServer} {nl:PowerShell} plugin example. \\ |
 | {nl:HelloWorld}.copyright | © Citrix Systems Inc. 2009 |
 | {nl:HelloWorld}.link | [http://community.citrix.com/xencenter] |
 | hello-menu-item.label | Hello World\! |
 | hello-menu-item.description | Displays 'Hello World' from the selected object. |
 | hello-menu-item.icon | Plugins\Citrix\HelloWorld\HelloWorld.png |
 &nbsp;The final step is to convert this .resx into a DLL. We do this with two tools:
 # {nl:ResGen}.exe - Creates a .resources file from the resx. This can be found in the .NET framework SDK.
 # Al.exe - Embeds the .resources file into a DLL. We specify we want to create a _library_, the file we wish to _embed_, that we need the _invariant culture_ and the name of the DLL file. Al.exe is in the .NET framework directory.
  
 {noformat}
 C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\ResGen.exe HelloWorld.resx
 C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\al.exe /t:lib /embed:HelloWorld.resources
  /culture:0x007F /out:HelloWorld.resources.dll
 {noformat}
 Attachments: [HelloWorld Example - PowerShell^HelloWorld.resx], [HelloWorld Example - PowerShell^HelloWorld.resources.dll], [^HelloWorld.png]
  
 h2. The {nl:PowerShell} script
  
 We now need to write the script, which will compile a list of names from the selected objects in the resource list and show a message box with our "Hello from ..." in it.
  
 {nl:XenCenter} will pass in parameter sets to your plugin to let you know what is selected in the resource list, and to enable you to communicate with your connected servers. {nl:PowerShell} plugins can access these parameter sets from the $ObjInfoArray variable which {nl:XenCenter} populates before running your script.
  
 h3. $ObjInfoArray
  
 This handy variable is an array of hashmaps. Each map represents a parameter set with the following keys - for each $map in $ObjInfoArray:
 * *$map{*}{nl:["url"]} \- The URL of the server which owns the object selected in the tree view
 * *$map{*}{nl:["sessionRef"]} \- An authenticated session reference for the server (allows the script to log into the server)
 * *$map{*}{nl:["class"]} \- The type of the object selected: Server, VM etc
 * *$map{*}{nl:["objUuid"]} \- The UUID for the selected object.
  
 You will get:
 * One parameter set per object selected in the resource list.
 * One parameter set per object in a folder if a folder is selected.
 * One parameter set per connected server if the user has the {nl:XenCenter} node selected. These are provided to allow you to communicate with any server if launched from the {nl:XenCenter} node, however the "class" and "objUuid" keys will be marked as blank.
  
 Here is an example of how to use this array:
 {code}
 $SelectedObjectNames=@();
 $XenCenterNodeSelected = 0;
 #the object info array contains hashmaps, each of which represent a parameter set and describe a target in the XenCenter resource list
 foreach($parameterSet in $ObjInfoArray)
 {
  if ($parameterSet["class"] -eq "blank")
  {
  #When the XenCenter node is selected a parameter set is created for each of your connected servers with the class and objUuid keys marked as blank
  if ($XenCenterNodeSelected)
  {
  continue
  }
  $XenCenterNodeSelected = 1;
  $SelectedObjectNames += "XenCenter"
  }
  elseif ($parameterSet["sessionRef"] -eq "null")
  {
  #When a disconnected server is selected there is no session information, we get null for everything except class
  $SelectedObjectNames += "a disconnected server"
  }
  else
  {
  Connect-XenServer -url $parameterSet["url"] -opaqueref $parameterSet["sessionRef"]
  #Use $class to determine which server objects to get
  #-properties allows us to filter the results to just include the selected object
  $exp = "Get-XenServer:{0} -properties @{{uuid='{1}'}}" -f $parameterSet["class"], $parameterSet["objUuid"]
  $obj = Invoke-Expression $exp
  $SelectedObjectNames += $obj.name_label;
  }
 }
 {code}
 Looking at that final else block you can see that before any server commands can be used we need to connect to the server. We use the sessionRef from the existing connection in {nl:XenCenter} which means we don't need to provide any new credentials.
 {code}
 Connect-XenServer -url $parameterSet["url"] -opaqueref $parameterSet["sessionRef"]
 {code}
 Then when we use {nl:XenServer} commands they automatically use the session from the last Connect-XenServer call. We construct an expression using the class and uuid information we were given which will retrieve the object selected in the resource list.
 {code}
 $exp = "Get-XenServer:{0} -properties @{{uuid='{1}'}}" -f $parameterSet["class"], $parameterSet["objUuid"]
 $obj = Invoke-Expression $exp
 {code}
 Because being pretty is important the following bit of code constructs a nice sentence out of our list of names, but equally you could just string join your name array at this point.
 {code}
 $NameString = "Hello from {0}" -f $SelectedObjectNames[0];
 if ($SelectedObjectNames.length -gt 1)
 {
  #we are aiming for "name_1, name_2, name_3...name_n-1 and name_n"
  for ($i=1; $i -lt $SelectedObjectNames.length - 1; $i++)
  {
  $NameString += ", {0}" -f $SelectedObjectNames[$i]
  }
  $NameString += " and {0}" -f $SelectedObjectNames[$SelectedObjectNames.length - 1]
 }
 {code}
 Finally we use .NET Windows Forms to create an alert box by loading the correct DLL.
 {code}
 [Reflection.Assembly]::loadwithpartialname('system.windows.forms')
 [system.Windows.Forms.MessageBox]::show($NameString, "Hello World")
 {code}
 The full {nl:PowerShell} script is [HelloWorld Example - PowerShell^HelloWorld.ps1]
  
 h2. Deployment
  
 The best way to distribute your {nl:XenCenter} plugin is to package your plugin into a single MSI (Windows Installer) file.
  
 Using a Windows Installer allows you to make sure the plugin is being installed into the correct place (by checking the {nl:XenCenter} {nl:InstallDir} registry key) and it gives versioning. A newer version will automatically uninstall the old version and then install the new one.
  
 You can use the [HelloWorld Example - PowerShell^Create-PluginInstaller.ps1] {nl:PowerShell} script to do this. The script requires WiX 2.0 and should be executed from your XenCenter install directory. The following command was used to makean msi for this plugin:
 \\
 {noformat}
  .\Create-PluginInstaller.ps1 -out HelloWorld.msi -title "XenCenter Hello World Plugin"
  -description "Sample plugin for XenCenter" -manufacturer Citrix -upgrade_code $([System.Guid]::NewGuid().ToString())
 {noformat}
  
 h2. Summary
  
 This exampled covered all the basics of producing a MenuItem plugin for XenCenter using PowerShell. It also introduced how to resource and deploy your plugin.
  
 Here are all the files you need to run the plugin again:
 - [HelloWorld Example - PowerShell^HelloWorld.xcplugin.xml]
 - [HelloWorld Example - PowerShell^HelloWorld.resources.dll],
 - [^HelloWorld.png]
 - [HelloWorld Example - PowerShell^HelloWorld.ps1]
  
 Extract them to <XenCenterInstallDirectory>\Plugins\Citrix\HelloWorld\ and launch XenCenter to see the new menu item.
  
 h2. Screenshots
  
 \\ !PluginDialog.png|align=center!\\ !MenuItemScreen.png|align=center!\\ !HelloPromptScreen.png|align=center!\\
 \\
 \\
 \\

XenServer Final Backup Script with or without snapshot

June 21, 2010 in citrix, virtualization, xen by admin

Page edited by Filippo Zanardo

Description

Ok guys,
Xenserver 5.6 is out now, and i enhance my backup script i rewrite some part and add some more features/controls, that i will explain later.

You can donwload the script 

http://xenbackup.googlecode.com/files/xenbackup2.1.zip 

Fixed a minor bug in 2.1 for the check aviable space part.

It's simple to set up just modify config.txt and than you can run the script with this simple command line:
perl /path/to/backup.pl /path/to/config.txt

For comment, bug , feature etc etc comment here or better on my blog:

http://pipposan.wordpress.com

Download


http://xenbackup.googlecode.com/files/xenbackup2.1.zip 

Code Snippet

Now i will explain what you can configure and the features:

- @skip: this variable contain the uuid of the machine to skip in the backup you can get with the command 'xe vm-list', add more uuid separeted by ','

- usesnapshot: if set to true backup script try to make a snapshot of the vm, else he shutdown the machine, export and power on the machine

- removable: if set to true the script detach the removable storage, else snapshot fail, and then reattached in the correct order, just remember to set up the variable removableuuid with your removable uuid you can get with command 'xe sr-list'

- mailNotification: if set to true script send email to and from the email specified in the config file, i remove the script used before now script use ssmtp that is already installed in xenserver, just configure the file /etc/ssmtp/ssmtp.conf with your data and remember to uncomment this line FromLineOverride=YES

- subfolder: Set to true to create a subfolder in the store for each backup based on vm name

- versioning: Set to true to let the script manage to delete the backup older than a certain day or number or hours specified in the $delnumber variable

- logging: if set to true the script write all the message with data into one log/file specified in the variable $logfile

- automount: if set to true script try to mount the backupdir specified in mountcommand at start and umount at end, else no action taken and u have to mount dir manually

- checkspace: if set to true the script check the avaiable space on the backup dir and if less than $spacerequired quit with a message, size is in MB

i add also some check to verify that the correct file is been written on the backup folder, if not backup error is notified.

That's all i hope i explain well and you like the script, comment or post for bugs, feature etc etc.

Cheers!

Disclaimer

These software applications are provided to you as is with no representations, warranties or conditions of any kind. You may use and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software application may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the software application fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the software application. In no event should the code be used to support of ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SOFTWARE APPLICATION, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the code.

Changes between revision 5 and revision 6:

 h2. Description
  
 Ok guys,
 Xenserver 5.6 is out now, and i enhance my backup script i rewrite some part and add some more features/controls, that i will explain later.
  
 You can donwload the script&nbsp;\\
  You can donwload the script&nbsp;
 \\
  
 [http://xenbackup.googlecode.com/files/xenbackup2.1.zip]&nbsp;
  
 *Fixed a minor bug in 2.1 for the check aviable space part.*
  
 It's simple to set up just modify config.txt and than you can run the script with this simple command line:
 *perl /path/to/backup.pl /path/to/config.txt*
 \\
  
 For comment, bug , feature etc etc comment here or better on my [blog|http://pipposan.wordpress.com]:
  
 [http://pipposan.wordpress.com]
  
 h2. Download
\\
  
 [http://code.google.com/p/xenbackup/downloads/detail?name=xenbackup2.zip&amp;can=2&amp;q=]
  [http://xenbackup.googlecode.com/files/xenbackup2.1.zip]&nbsp;
  
 h2. Code Snippet
  
 Now i will explain what you can configure and the features:
  
 \- *@skip:* this variable contain the uuid of the machine to skip in the backup you can get with the command 'xe vm-list', add more uuid separeted by ','
  
 \- *usesnapshot:* if set to true backup script try to make a snapshot of the vm, else he shutdown the machine, export and power on the machine
  
 \- *removable:* if set to true the script detach the removable storage, else snapshot fail, and then reattached in the correct order, just remember to set up the variable *removableuuid* with your removable uuid you can get with command 'xe sr-list'
  
 \- *mailNotification:* if set to true script send email to and from the email specified in the config file, i remove the script used before now script use *ssmtp* that is already installed in xenserver, just configure the file /etc/ssmtp/ssmtp.conf with your data and remember to uncomment this line _FromLineOverride=YES_
  
 \- *subfolder:* Set to true to create a subfolder in the store for each backup based on vm name
  
 \- *versioning:* Set to true to let the script manage to delete the backup older than a certain day or number or hours specified in the $delnumber variable
  
 \- *logging:* if set to true the script write all the message with data into one log/file specified in the variable $logfile
  
 \- *automount:* if set to true script try to mount the backupdir specified in mountcommand at start and umount at end, else no action taken and u have to mount dir manually
  
 \- *checkspace:* if set to true the script check the avaiable space on the backup dir and if less than $spacerequired quit with a message, size is in MB
  
 i add also some check to verify that the correct file is been written on the backup folder, if not backup error is notified.
  
 That's all i hope i explain well and you like the script, comment or post for bugs, feature etc etc.
  
 Cheers\!
  
 h2. Disclaimer
  
 These software applications are provided to you as is with no representations, warranties or conditions of any kind. You may use and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software application may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the software application fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the software application. In no event should the code be used to support of ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SOFTWARE APPLICATION, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the code.

Quick Batch Actions from the XenServer CLI

June 4, 2010 in citrix, virtualization, xen by admin

Page edited by Kevin Bacon

Description

This CLI command template allows XenServer administrators to quickly make a batch of actions based on a given criteria.  For example, an administrator may want to quickly suspend every machine in the pool, or eject the CD from every VM on a host.  This can be quickly and easily modified for a wide range of purposes and does not require the creation of a script.

Download

Download is not necessary.  The commands can be entered directly into the CLI by using the console tab in XenCenter or SSHing to the server.

Code Snippet

Template: 

[root@XS ~]# IFS=,
[root@XS ~]# UUIDs=$(xe <object>-list <parameter>=<condition> --minimal)
[root@XS ~]# for UUID in $UUIDs; do xe <object>-<action> uuid=$UUID; done

Example 1 (suspend all running VMs in a pool):

[root@XS ~]# IFS=,
[root@XS ~]# UUIDs=$(xe vm-list power-state=running --minimal)
[root@XS ~]# for UUID in $UUIDs; do xe vm-suspend uuid=$UUID; done

Example 2 (eject CD from every VM in a pool):

[root@XS ~]# IFS=,
[root@XS ~]# UUIDs=$(xe vbd-list type=CD empty=false params=vm-uuid --minimal)
[root@XS ~]# for UUID in $UUIDs; do xe vm-cd-eject uuid=$UUID; done

Note: The "IFS=," command only needs to be executed once per session.  This command identifies the comma as the field separator given that the "<object>-list" command with "--minimal" returns a string of UUIDs separated by commas.

Disclaimer

These software applications are provided to you as is with no representations, warranties or conditions of any kind. You may use and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software application may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the software application fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the software application. In no event should the code be used to support of ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SOFTWARE APPLICATION, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the code.

Changes between revision 1 and revision 2:

 h2. Description
  
 This CLI command template allows XenServer administrators to quickly make a batch of actions based on a given criteria.&nbsp; For example, an administrator may want to quickly suspend every machine in the pool, or eject the CD from every VM on a host.&nbsp; This can be quickly and easily modified for a wide range of purposes and does not require the creation of a script.
  
 h2. Download
  
 Download is not necessary.&nbsp; The commands can be entered directly into the CLI by using the console tab in XenCenter or SSHing to the server.
  
 h2. Code Snippet
  
 Template:&nbsp;
 {code}
 [root@XS ~]# IFS=,
 [root@XS ~]# UUIDs=$(xe <object>-list <parameter>=<condition> --minimal)
 [root@XS ~]# for UUID in $UUIDs; do xe <object>-<action> uuid=$UUID; done
 {code}
 Example (suspend all running VMs in a pool):
  Example 1 (suspend all running VMs in a pool):
 {code}
 [root@XS ~]# IFS=,
 [root@XS ~]# UUIDs=$(xe vm-list power-state=running --minimal)
 [root@XS ~]# for UUID in $UUIDs; do xe vm-suspend uuid=$UUID; done
 {code}
 Example 2 (eject CD from every VM in a pool):
 {code}
 [root@XS ~]# IFS=,
 [root@XS ~]# UUIDs=$(xe vbd-list type=CD empty=false params=vm-uuid --minimal)
 [root@XS ~]# for UUID in $UUIDs; do xe vm-cd-eject uuid=$UUID; done
 {code}
 Note: The "IFS=," command only needs to be executed once per session.&nbsp; This command identifies the comma as the field separator&nbsp;given that the "<object>\-list" command with "\-\-minimal" returns a string of UUIDs separated by commas.
  
 h2. Disclaimer
  
 These software applications are provided to you as is with no representations, warranties or conditions of any kind. You may use and distribute it at your own risk. CITRIX DISCLAIMS ALL WARRANTIES WHATSOEVER, EXPRESS, IMPLIED, WRITTEN, ORAL OR STATUTORY, INCLUDING WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NONINFRINGEMENT. Without limiting the generality of the foregoing, you acknowledge and agree that (a) the software application may exhibit errors, design flaws or other problems, possibly resulting in loss of data or damage to property; (b) it may not be possible to make the software application fully functional; and (c) Citrix may, without notice or liability to you, cease to make available the current version and/or any future versions of the software application. In no event should the code be used to support of ultra-hazardous activities, including but not limited to life support or blasting activities. NEITHER CITRIX NOR ITS AFFILIATES OR AGENTS WILL BE LIABLE, UNDER BREACH OF CONTRACT OR ANY OTHER THEORY OF LIABILITY, FOR ANY DAMAGES WHATSOEVER ARISING FROM USE OF THE SOFTWARE APPLICATION, INCLUDING WITHOUT LIMITATION DIRECT, SPECIAL, INCIDENTAL, PUNITIVE, CONSEQUENTIAL OR OTHER DAMAGES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. You agree to indemnify and defend Citrix against any and all claims arising from your use, modification or distribution of the code.