VMware Global Community
zhenmie365
Contributor
Contributor

求帮助,vijava升级到5.5后用模板自定义部署虚拟机错误!

       本来在5.1的时候用customizeVM_task()函数就好困难,因为经常说参数错误。现在更新到5.5就更模糊了!直接一句:customizationFault就了事!想找出问题所在都难。

       本人在模板部署虚拟机时用到CustomizationSpec参数来实现自定义化,但失败了!然后就在一台windows2008R2的虚拟机上用checkCustomizationSpec()函数来检验自定义化,一样失败了,错误代码就是customizationFault。修改了很多参数,例如、user部分的名字、组织等,ip的netmask等,都不成功!困惑啊!

       如有达人对这方面有认识,请指教一下小弟!多谢了!

       代码如下:

CustomizationSpec cspec = new CustomizationSpec();

  CustomizationSpecItem specItem = new CustomizationSpecItem();

{

            CustomizationSpecInfo info = new CustomizationSpecInfo();

            specItem = new CustomizationSpecItem();

            specItem.setInfo(info);

            CustomizationGlobalIPSettings gIP = new CustomizationGlobalIPSettings();

            cspec.setGlobalIPSettings(gIP);

            // This is windows so choose the sysprep

            CustomizationSysprep sprep = new CustomizationSysprep();

            CustomizationGuiUnattended guiUnattended = new CustomizationGuiUnattended();

            guiUnattended.setAutoLogon(false);   // do not autoLogin on reboot for customization.

            guiUnattended.setAutoLogonCount(0);  // do not autologin on reboot..

            guiUnattended.setTimeZone(8);  // set to Eastern time.

            sprep.setGuiUnattended(guiUnattended);

            // add VM to WORKGROUP

            CustomizationIdentification identification = new CustomizationIdentification();

            identification.setJoinWorkgroup("WORKGROUP");

            sprep.setIdentification(identification);

            //String productId = vm.getSummary().getConfig().getGuestId();   // only needed for windows os's

//            if("Windows2003"))  

//            {

                CustomizationLicenseFilePrintData licenseFilePrintData = new CustomizationLicenseFilePrintData();

                licenseFilePrintData.setAutoMode(CustomizationLicenseDataMode.perServer);

                licenseFilePrintData.setAutoUsers(5);

                sprep.setLicenseFilePrintData(licenseFilePrintData);

//            }

            // setup UserData

            CustomizationUserData userData = new CustomizationUserData();

            CustomizationFixedName n = new CustomizationFixedName();

            n.setName(name);

            userData.setComputerName(n);

            userData.setFullName("test");  // This may change in the future

            userData.setOrgName("test");

            userData.setProductId("00486-109-0000007-84958");  // 00486-109-0000007-84958 Product Serial (needed for Windows 2003 and 2008)

            sprep.setUserData(userData);

            cspec.setIdentity(sprep);

           

            // NicSettingMap part

            CustomizationAdapterMapping adaptorMap = new CustomizationAdapterMapping();

            CustomizationIPSettings adapter = new CustomizationIPSettings();

            CustomizationFixedIp fixedIp = new CustomizationFixedIp();

            adapter.setDnsServerList(new String[] {"202.96.128.86"});

            adapter.setGateway(new String[] {"192.168.2.1"});

            fixedIp.setIpAddress("192.168.2.138");

//            CustomizationDhcpIpGenerator dhcpIp = new CustomizationDhcpIpGenerator();

            adapter.setIp(fixedIp);

            adapter.setSubnetMask("255.255.255.0");

            adaptorMap.setAdapter(adapter);

            CustomizationAdapterMapping[] nicSettingMap = new CustomizationAdapterMapping[]{adaptorMap};

            cspec.setNicSettingMap(nicSettingMap);

            CustomizationWinOptions options = new CustomizationWinOptions();

            options.setChangeSID(true);

            options.setDeleteAccounts(false);

            cspec.setOptions(options);

            CustomizationSpecManager manager = si.getCustomizationSpecManager();

            cspec.setEncryptionKey(manager.getEncryptionKey());

            specItem.setSpec(cspec);

}

     //自定义系统

        try{

            vm.checkCustomizationSpec(specItem.getSpec());

            Task task = vm.customizeVM_Task(specItem.getSpec());

                             task.waitForTask();

        }catch(CustomizationFault fault){

        fault.getStackTrace();

        }

Tags (1)
Reply
0 Kudos
1 Reply
zhenmie365
Contributor
Contributor

     在更改了productId为序列号后,checkCustomizationSpec()可以通过了,自定义也成功了!但vm自定义过程中又出现了另外一个错误!

     如下图:

     error3.png

        头晕了,这又是什么东西啊!是不是我设的参数有问题了!?

Reply
0 Kudos