[Users] Cloud-init for Windows

Omer Frenkel ofrenkel at redhat.com
Tue Apr 8 03:02:30 EDT 2014



----- Original Message -----
> From: "Tejesh M" <tejeshmk at gmail.com>
> To: "Itamar Heim" <iheim at redhat.com>
> Cc: "users at oVirt.org" <users at ovirt.org>
> Sent: Monday, April 7, 2014 4:59:16 PM
> Subject: Re: [Users] Cloud-init for Windows
> 
> Hi,
> 
> I tried as you suggested, but floppy is not getting attached it seems. below
> is the code
> 
> 
> 
> Steps followed:
> 
> I. Create windows VM
> II. installed host agent
> III. To seal a Windows virtual machine with sysprep
> 
> 
>     1. In the Windows virtual machine to be used as a template, open a
>     command line terminal and type regedit .
>     2. The Registry Editor window displays. On the left pane, expand
>     HKEY_LOCAL_MACHINE → SYSTEM → SETUP .
>     3. On the main window, right click to add a new string value using New →
>     String Value . Right click on the string value file and select Modify .
>     When the Edit String dialog box displays, fill in the provided text
>     boxes:
> 
> 
>         * Value name: UnattendFile
>         * Value data: a:\sysprep.xml
>     4. Launch sysprep from C:\Windows\System32\sysprep\sysprep.exe
> 
> 
>         * Under System Cleanup Action , select Enter System
>         Out-of-Box-Experience (OOBE) .
>         * Tick the Generalize checkbox if you need to change the computer's
>         system identification number (SID).
>         * Under Shutdown Options , select Shutdown .
> 
> 
> Click OK . The virtual machine will now go through the sealing process and
> shut down automatically.
> 
> 
> 
> 
> 
> 
> 
> IV.
> 
> 
> org.ovirt.engine.sdk.decorators.VM vm1 = api.getVMs().get(vmName);
> Payloads payloads = new Payloads();
> Payload payload = new Payload();
> payload.setType("floppy");
> Files payloadFiles = new Files();
> File payloadFile = new File();
> payloadFile.setName("sysprep.xml");
> payloadFile.setContent("<?xml version=\"1.0\" encoding=\"utf-8\"?> <unattend
> xmlns=\"urn:schemas-microsoft-com:unattend\"> FILE CONTENT "</unattend>");
> payloadFiles.getFiles().add(payloadFile);
> payload.setFiles(payloadFiles);
> vm1.setPayloads(payloads);
> Action action = new Action();
> vm1.start(action);
> 
> 

i guess you need to use CDATA tags in order to pass xml content.
im not sure about CLI, but if you use curl it should look like this:
(credit to James W. Mills for providing this info)

1)  Create a payload file - Mine looked like this (payload.dat):

<vm>
  <payloads>
    <payload type='floppy'>
    <files>
      <file>
        <name>sysprep.inf</name>
        <content><![CDATA[
<THE RAW SYSPREP XML>
]]>
        </content>
<type>BASE64</type>
      </file>
      </files>
    </payload>
  </payloads>
</vm>

Where I have "<THE RAW SYSPREP XML>", I just dumped a full sysprep XML file.  Just make sure it is in between the CDATA tags so it is escaped properly.

2) Upload the payload into the VM:

# curl -X PUT -H "Accept: application/xml" -H "Content-Type: application/xml" -k -u admin at internal:<pass> -d @payload.dat  https://<server>/api/vms/<vm-id>

The URL is simply the full path of the VM, which I obtained by parsing "api/vms"

3)  Boot the machine - Assuming the sysprep information is correct, all the sysprep settings will be applied.

> 
> On Thu, Mar 27, 2014 at 3:52 PM, Itamar Heim < iheim at redhat.com > wrote:
> 
> 
> On 03/27/2014 06:18 AM, Tejesh M wrote:
> 
> 
> Can you guide me on sysprep with sample code & sysprep file?
> 
> 
> just launch a windows VM, look at the generated sysprep file we pass to the
> VM via the floppy disk.
> then pass it as a payload as-is.
> then try to change what you want.
> 
> 
> 
> 
> On Thu, Mar 27, 2014 at 3:16 PM, Itamar Heim < iheim at redhat.com
> <mailto: iheim at redhat.com >> wrote:
> 
> On 03/27/2014 05:33 AM, Tejesh M wrote:
> 
> Hi All,
> 
> I was doing google to see if i can set Hostname,Password & IP
> details
> for Windows server from RHEV-M. I got to know that we can create VM
> Payload & send that to Windows VM (installed with Cloud-init)
> 
> Refer this link
> http://www.cloudbase.it/cloud- __init-for-windows-instances/# __comment-9411
> < http://www.cloudbase.it/ cloud-init-for-windows- instances/#comment-9411 >
> 
> Cloud-init expects Meta-data & User-Data file to be sent either via
> Config Drive or via HTTP. I'm trying to achive this via ConfigDrive
> (created using VM Payload).
> 
> 
> note you can also just pass the full sysprep file as a payload
> yourself via the API, and set all these items in it.
> 
> 
> But i'm wondering what should be the format of this two files
> (Meta-data
> & User-data). Have any1 tried this? If yes, would request to share
> sample for both the files with setting Hostname, Password & IP
> details.
> 
> 
> just launch a linux VM and check the file we create?
> 
> 
> Java code:
> 
> org.ovirt.engine.sdk.__ decorators.VM vm1 =
> api.getVMs().get(vmName);
> Payloads payloads = new Payloads();
> Payload payload = new Payload();
> payload.setType("cdrom");
> 
> Files payloadFiles = new Files();
> File payloadFile = new File();
> payloadFile.setName("meta-__ data.txt");
> payloadFile.setContent("__ hostname:"+vmName);
> payloadFiles.getFiles().add(__ payloadFile);
> payload.setFiles(payloadFiles) __;
> vm1.setPayloads(payloads);
> Action action = new Action();
> vm1.start(action);
> 
> --
> Thanks & Regards
> Tejesh
> 
> 
> 
> 
> 
> --
> Thanks & Regards
> Tejesh
> 
> 
> 
> 
> --
> Thanks & Regards
> Tejesh
> 
> _______________________________________________
> Users mailing list
> Users at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
> 


More information about the Users mailing list