VMware {code} Community
OwainNorth
Contributor
Contributor
Jump to solution

Force Recustomization through API?

So, I'm creating a vApp from a template, like so:

Vapp Vm = NewerVApp.GetChildrenVms()[0];
Vm.Resource.name = Name;
_VCloudManager.WaitForTaskCompletion(Vm.UpdateVapp(Vm.Resource));
// Guest
GuestCustomizationSectionType Guest = Vm.GetGuestCustomizationSection();
Guest.ComputerName = Name;
Guest.ChangeSid = true;
Guest.ChangeSidSpecified = true;
Guest.AdminPassword = "Password1";
Guest.AdminPasswordAuto = false;
Guest.AdminPasswordEnabled = true;
Guest.Enabled = true;
_VCloudManager.WaitForTaskCompletion(Vm.UpdateSection(Guest));
// Deploy VM
_VCloudManager.WaitForTaskCompletion(Vm.Deploy(true, 0));
// Deploy vApp
_VCloudManager.WaitForTaskCompletion(NewVApp.Deploy(true, 0));

However once the machine boots up, it does not run Sysprep but instead I get a logon screen without the new settings.

If I comment out the lines to deploy the vApp and Vm it creates fine, as previously. However I can then choose "Power on and Force Recustomization" through the API, which forces Sysprep to run and changes settings as expected.

Is there no way of performing this forced reconfiguration on poweron through the API? I can find people referring to this limitation in v1.0, but surely this is a common thing for people to require?

Cheers

O.

0 Kudos
1 Solution

Accepted Solutions
rkamal
VMware Employee
VMware Employee
Jump to solution

Hi,

Deploying with force customization option is not available  in vCloud API 1.0.

http://www.vmware.com/pdf/vcd_10_api_guide.pdf - Pg No 175.

Regards,
Rajesh Kamal.

View solution in original post

0 Kudos
5 Replies
rkamal
VMware Employee
VMware Employee
Jump to solution

Hi,

Deploying with force customization option is not available  in vCloud API 1.0.

http://www.vmware.com/pdf/vcd_10_api_guide.pdf - Pg No 175.

Regards,
Rajesh Kamal.
0 Kudos
OwainNorth
Contributor
Contributor
Jump to solution

Excellent, something to be implemented soon enough I hope?

0 Kudos
Todor_Todorov
Hot Shot
Hot Shot
Jump to solution

Hi,

Yes, the 'forceCustomization' attribute was added to the <DeployVAppParams> object in version 1.5 of vCD which was released a couple of weeks ago Smiley Happy

Regards,

Todor Todorov

OwainNorth
Contributor
Contributor
Jump to solution

Ah, perhaps that's the issue I'm having - we currently have a v1.0 setup and someone's currently building me a v1.5 one.

I shall get on with that Smiley Wink

0 Kudos
balajia
Contributor
Contributor
Jump to solution

After several retries and reading i managed to get this working through REST POST method...

string url = vm.Resource.href + @"/action/deploy";

string body = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1.5\" powerOn=" + "\"" + "true" + "\"" + " deploymentLeaseSeconds=" + "\"" + orgLeaseSettings.DeploymentLeaseSeconds.ToString() + "\"" + " forceCustomization=" + "\"" + ForceCustomization.ToString().ToLower() + "\"" + "/>";

string contentType = "application/vnd.vmware.vcloud.deployVAppParams+xml";

Response rp = com.vmware.vcloud.sdk.utility.RestUtil.Post(vCloudSession, url, body, contentType, "UTF-8");

XmlDocument doc = new XmlDocument();

try

{

doc.LoadXml(rp.ResponseXml);

XmlNode task_node = null;

foreach (XmlNode temp in doc.ChildNodes)

{

if (temp.Name == "Task")

{

task_node = temp;

break;

}

}

if (task_node != null)

{

string task_id = task_node.Attributes["id"].Value;

Task t1 = Task.GetTaskById(vCloudSession, task_id);

t1.WaitForTask(timeout);

}

}

catch (Exception e1)

{

retval =

false;

failure_reason =

"RestUtil returned invalid POST response.";

return retval;

}

0 Kudos