VMware {code} Community
bvivek
Contributor
Contributor

vCenter server crashes in CustomizeVM_Task called for customizing ip settings

Hi,

My objective is to customize ip settngs of a windows virtual machine adapter. Following is the code which I have written

CustomizationIPSettings adapter = new CustomizationIPSettings();

adapter.dnsServerList = new String[] { "192.168.172.151"};  

adapter.gateway = new String[] { "192.168.172.1" }; 

CustomizationFixedIp fixedIP = new CustomizationFixedIp();

fixedIP.ipAddress = "192.168.172.113";  

adapter.ip = fixedIP;

adapter.subnetMask = "255.255.252.0";

CustomizationAdapterMapping adapterMap = new CustomizationAdapterMapping();

adapterMap.adapter = adapter;

adapterMap.macAddress = "00:50:56:86:00:00";

CustomizationSpec customsSpec = new CustomizationSpec();

customsSpec.nicSettingMap = new CustomizationAdapterMapping[] { adapterMap };

customsSpec.globalIPSettings = new CustomizationGlobalIPSettings();

CustomizationSysprep identity = new CustomizationSysprep();

identity.guiUnattended = new CustomizationGuiUnattended();

identity.identification = new CustomizationIdentification();

identity.userData = new CustomizationUserData();

identity.userData.fullName = "";

identity.userData.orgName = "";

identity.userData.productId = "";

 

CustomizationFixedName computerName = new CustomizationFixedName();

computerName.name = "test1";

identity.userData.computerName = computerName;

customsSpec.identity = identity;

// vCenter Server Crashes after this call

ManagedObjectReference taskmoref = service.CustomizeVM_Task(vmmoref, customsSpec);

After calling CustomizeVM_Task vCenter server crashes. Can somebody help me find the problem?

I doubt whether customsSpecs is initialized properly. But I do not know exactly whats wrong there.

Thanks,

Vivek.

0 Kudos
1 Reply
bvivek
Contributor
Contributor

vCenter Server did not crash after initializing identity.userData.fullName and identity.userData.orgName to non-empty strings. However as I doubted earlier CustomizationSpec is not initialized properly. Looks like, CustomizeVM_Task with CustomizationSpec may not be a good option to change IP settings of a virtual machine which is already in use. (That is, when the virtual machine is installed properly with all the necessary configurations). This is for two reasons- its slow and we need to provide additional information fore sysprep which is unnecessary and redundant for our task of changing IP settings. VIX apis could be a better option.

Please provide any comments on my understanding and better suggestions if any, for the task.

Thanks,

Vivek.

0 Kudos