[one-users] windows vm context

Paul Batchelor pbatchelor at blackberry.com
Wed Oct 30 07:08:50 PDT 2013


One alternative approach I experimented with was casting the template XML directly to a powershell object - e.g.

You include the following line in your template to include the base-64 encoded XML

  TMPL="$TEMPLATE"

Then in the context PS script you can do the following once you have read the base64 encoded XML into a variable:

       [xml]$vmtemplate = [System.Text.Encoding]::Ascii.GetString([System.Convert]::FromBase64String( $base64template ))

You can then directly reference the VM template properties as PS objects -e.g.

       $mydatastore    = $vmtemplate.VM.TEMPLATE.DISK.DATASTORE.'#cdata-section'
       $myinvocationid = $vmtemplate.VM.ID
       $ownername      = $vmtemplate.VM.UNAME


This means you don't need to worry about what the quoting is for the template parameters except for the initial load of the base64 encoded XML.

Cheers

-----Original Message-----
From: users-bounces at lists.opennebula.org [mailto:users-bounces at lists.opennebula.org] On Behalf Of Martin Alfke
Sent: 30 October 2013 07:59
To: hansz
Cc: users
Subject: Re: [one-users] windows vm context


On 30 Oct 2013, at 02:00, hansz <hanshizhunjob at 126.com> wrote:

> hi man,i see you are trying windows vm context?have you make it sucessful? any message? any advice?
> 
Hi Hans,

please keep OpenNebula related mails on the list.

We run Windows 7 and 8 professional as VM managed by OpenNebula.
On the OpenNebula wiki (http://wiki.opennebula.org/) you will find a section called “Images and Stores”.
Within that section you will find a link to a complete documentation:
http://wiki.ieeta.pt/wiki/index.php/OpenNebula#Using_Windows_Images_for_new_Virtual_Machines

We only did one modification to the one-context.ps1 script which allows us to read data properly:

function getContext($file) {
       $context = @{}
       switch -regex -file $file {
               '(.+)="(.+)"’ {            ###### <——— other regexp
                       $name,$value = $matches[1..2]
                       $context[$name] = $value
               }
       }
       return $context
}

hth,

Martin

---------------------------------------------------------------------
Research In Motion UK Limited
Registered in England and Wales. Registered No. 04022422, with registered office at 200 Bath Road, Slough, Berkshire, SL1 3XE, United Kingdom

This transmission (including any attachments) may contain confidential information, privileged material (including material protected by the solicitor-client or other applicable privileges), or constitute non-public information. Any use of this information by anyone other than the intended recipient is prohibited. If you have received this transmission in error, please immediately reply to the sender and delete this information from your system. Use, dissemination, distribution, or reproduction of this transmission by unintended recipients is not authorized and may be unlawful.


More information about the Users mailing list