0 Replies Latest reply on May 7, 2019 5:45 AM by andya881010

    why CustomizationIPSettings not setNicSettingMap method?

    andya881010 Lurker

      vsphere web service sdk 6.7 

      public static CustomizationSpec createCustomizations(){

              CustomizationSpec spec=new CustomizationSpec();

              

              //创建文件类型windows

              CustomizationWinOptions options = new CustomizationWinOptions();

              options.setChangeSID(true);

              options.setDeleteAccounts(false);

              

              spec.setOptions(options);

              //创建应答文件

              CustomizationSysprep sysprep=new CustomizationSysprep();

              //

              

              

              CustomizationGuiUnattended unattended=new CustomizationGuiUnattended();

              unattended.setTimeZone(4);

              unattended.setAutoLogon(false);

              unattended.setAutoLogonCount(0);

              sysprep.setGuiUnattended(unattended);

       

              CustomizationUserData userData=new CustomizationUserData();

              userData.setFullName("viuxan.com");

              userData.setOrgName("vixuan.com");

              

              CustomizationVirtualMachineName virtualMachineName=new CustomizationVirtualMachineName();

              userData.setComputerName(virtualMachineName);

              userData.setProductId("HWRFF-2FFYX-XFXP2-DYFC3-BX3B7");

              sysprep.setUserData(userData);

       

              CustomizationIdentification identification=new CustomizationIdentification();

              identification.setJoinWorkgroup("WORKGROUP");

              sysprep.setIdentification(identification);

       

              spec.setIdentity(sysprep);

       

              CustomizationGlobalIPSettings globalIPSettings=new CustomizationGlobalIPSettings();

              spec.setGlobalIPSettings(globalIPSettings);

       

              //设置IP地址

              CustomizationAdapterMapping[] adapterMappings =new  CustomizationAdapterMapping[1];

              CustomizationIPSettings ipSetting=new CustomizationIPSettings();

              //重新设置自定义规范 IP 地址

              //设置dns

              String[] dnss=new String[1];

              dnss[0]="8.8.8.8";

              //ipSetting.setDnsServerList(dnss);

              //设置gateway

              String[] gateways=new String[1];

              gateways[0]="192.168.0.1";

              ipSetting.setGateway(gateways);

              

              //设置子网掩码

              String subnetMask="255.255.255.0";

              ipSetting.setSubnetMask(subnetMask);

              // 设置IP地址

              CustomizationFixedIp ip=new CustomizationFixedIp();

              ip.setIpAddress("192.168.0.111");

          

              ipSetting.setIp(ip);

       

              CustomizationAdapterMapping adapter=new CustomizationAdapterMapping();

              adapter.setAdapter(ipSetting);

              adapterMappings[0]=adapter;

       

              spec.setNicSettingMap(adapterMappings);

              

              CustomizationSpecItem customizationSpecItem=new CustomizationSpecItem();

              customizationSpecItem.setSpec(spec);

              CustomizationSpecInfo info=new CustomizationSpecInfo();

              info.setName("123456");

              info.setDescription("123456");

              customizationSpecItem.setInfo(info);

              

       

       

              return spec;

          }

       

      error:

      The method setNicSettingMap(CustomizationAdapterMapping[]) is undefined for the type CustomizationSpec!

      public static CustomizationSpec createCustomizations(){
              CustomizationSpec spec=new CustomizationSpec();
              
              //创建文件类型windows
              CustomizationWinOptions options = new CustomizationWinOptions();
              options.setChangeSID(true);
              options.setDeleteAccounts(false);
              
              spec.setOptions(options);
              //创建应答文件
              CustomizationSysprep sysprep=new CustomizationSysprep();
              //
              
              
              CustomizationGuiUnattended unattended=new CustomizationGuiUnattended();
              unattended.setTimeZone(4);
              unattended.setAutoLogon(false);
              unattended.setAutoLogonCount(0);
              sysprep.setGuiUnattended(unattended);
       
              CustomizationUserData userData=new CustomizationUserData();
              userData.setFullName("viuxan.com");
              userData.setOrgName("vixuan.com");
              
              CustomizationVirtualMachineName virtualMachineName=new CustomizationVirtualMachineName();
              userData.setComputerName(virtualMachineName);
              userData.setProductId("HWRFF-2FFYX-XFXP2-DYFC3-BX3B7");
              sysprep.setUserData(userData);
       
              CustomizationIdentification identification=new CustomizationIdentification();
              identification.setJoinWorkgroup("WORKGROUP");
              sysprep.setIdentification(identification);
       
              spec.setIdentity(sysprep);
       
              CustomizationGlobalIPSettings globalIPSettings=new CustomizationGlobalIPSettings();
              spec.setGlobalIPSettings(globalIPSettings);
       
              //设置IP地址
              CustomizationAdapterMapping[] adapterMappings =new  CustomizationAdapterMapping[1];
              CustomizationIPSettings ipSetting=new CustomizationIPSettings();
              //重新设置自定义规范 IP 地址
              //设置dns
              String[] dnss=new String[1];
              dnss[0]="8.8.8.8";
              //ipSetting.setDnsServerList(dnss);
              //设置gateway
              String[] gateways=new String[1];
              gateways[0]="192.168.0.1";
              ipSetting.setGateway(gateways);
              
              //设置子网掩码
              String subnetMask="255.255.255.0";
              ipSetting.setSubnetMask(subnetMask);
              // 设置IP地址
              CustomizationFixedIp ip=new CustomizationFixedIp();
              ip.setIpAddress("192.168.0.111");
          
              ipSetting.setIp(ip);
       
              CustomizationAdapterMapping adapter=new CustomizationAdapterMapping();
              adapter.setAdapter(ipSetting);
              adapterMappings[0]=adapter;
       
              spec.setNicSettingMap(adapterMappings);
              
              CustomizationSpecItem customizationSpecItem=new CustomizationSpecItem();
              customizationSpecItem.setSpec(spec);
              CustomizationSpecInfo info=new CustomizationSpecInfo();
              info.setName("123456");
              info.setDescription("123456");
              customizationSpecItem.setInfo(info);
              
       
       
              return spec;
          }