Hi
I want to change windows server (2003 - 2008 - 2012 ) IP address
I use VIJava 5.5b and Vcenter 5.5 (on windows)
i use CustomizationSysprep to change IP address according to this
topic : https://sourceforge.net/p/vijava/discussion/826592/thread/5d6ff04c
java code that I use is :
java code
public static void main (String[] args) throws Exception{
CustomizationSysprep sprep = new CustomizationSysprep();
CustomizationSpec cspec = new CustomizationSpec();
CustomizationGlobalIPSettings gIP = new CustomizationGlobalIPSettings();
cspec.setGlobalIPSettings(gIP);
//SetIP
CustomizationFixedIp fixedIp = new CustomizationFixedIp();
fixedIp.setIpAddress(ip);
CustomizationIPSettings adapter = new CustomizationIPSettings();
adapter.setDnsServerList(dns);
adapter.setGateway(gateway);
adapter.setIp(fixedIp);
adapter.setSubnetMask(netmask);
CustomizationAdapterMapping adaptorMap = new CustomizationAdapterMapping();
adaptorMap.setAdapter(adapter);
CustomizationAdapterMapping[] nicSettingMap = new CustomizationAdapterMapping[]{adaptorMap};
cspec.setNicSettingMap(nicSettingMap);
//GuiUnattended
CustomizationGuiUnattended guiUnattended = new CustomizationGuiUnattended();
guiUnattended.setAutoLogon(true);
guiUnattended.setAutoLogonCount(10);
CustomizationPassword pass = new CustomizationPassword();
pass.setPlainText(true);
pass.setValue("Vpsco1256#");
guiUnattended.setPassword(pass);
sprep.setGuiUnattended(guiUnattended);
//set License
CustomizationLicenseFilePrintData licenseFilePrintData ;
licenseFilePrintData = new CustomizationLicenseFilePrintData();
licenseFilePrintData.setAutoMode(CustomizationLicenseDataMode.perSeat);
licenseFilePrintData.setAutoUsers(5);
sprep.setLicenseFilePrintData(licenseFilePrintData);
cspec.setIdentity(sprep);
ServiceInstance si = new ServiceInstance(URL, user , pass, true);
Folder rootFolder = si.getRootFolder();
VirtualMachine vm = (VirtualMachine) new InventoryNavigator(rootFolder).searchManagedEntity("VirtualMachine", vmname);
vm.customizeVM_Task(cspec);
Exception in thread "main" java.rmi.RemoteException: VI SDK invoke exception:com.vmware.vim25.InvalidRequest
at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:122)
at com.vmware.vim25.ws.VimStub.customizeVM_Task(VimStub.java:1950)
at com.vmware.vim25.mo.VirtualMachine.customizeVM_Task(VirtualMachine.java:256)
and I try :
CustomizationIdentitySettings identity = new CustomizationIdentitySettings();
cspec.setIdentity(identity);
instead of cspec.setIdentity(sprep);
it dont give error but it give error in Vmware Vsphere task Viewer :
A specified parameter was not correct. spec.identity
I just want to change only (IP address , Netmask , Gateway , Dns) not anything else like host name or computer name or etc ...
Best regards
Tank you for helping
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I want to change windows server (2003 - 2008 - 2012 ) IP address
I use VIJava 5.5b and Vcenter 5.5 (on windows)
i use CustomizationSysprep to change IP address according to this
topic : https://sourceforge.net/p/vijava/discussion/826592/thread/5d6ff04c
java code that I use is :
public static void main (String[] args) throws Exception{
-----------------------------------------------------------------
but i got this error when I run this code
Exception in thread "main" java.rmi.RemoteException: VI SDK invoke exception:com.vmware.vim25.InvalidRequest
at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:122)
at com.vmware.vim25.ws.VimStub.customizeVM_Task(VimStub.java:1950)
at com.vmware.vim25.mo.VirtualMachine.customizeVM_Task(VirtualMachine.java:256)
and I try :
instead of cspec.setIdentity(sprep);
it dont give error but it give error in Vmware Vsphere task Viewer :
A specified parameter was not correct. spec.identity
I just want to change only (IP address , Netmask , Gateway , Dns) not anything else like host name or computer name or etc ...
Best regards
Tank you for helping
I don't have access to my sourcecode repo right now... but at first glance..
Isn't CustomizationSysprep() object for Windows systems and CustomizationLinuxPrep() linux/unix?
very useful reference for this kinda thing:
https://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/
ignore the above... commented in wrong thread.