deepakmits
Contributor
Contributor

Not able to customize guest os( network configuration ) of existing windows VM.

I am trying to update network configuration of existing windows VM through using customization spec and code goes like this -

//mor of vm to be customized.

ManagedObjectReference vmMor = getVMMorByName(vmName);

     

         

        CustomizationSpec cu = new CustomizationSpec();

     

        CustomizationAdapterMapping caMapping = new CustomizationAdapterMapping();

        CustomizationIPSettings cIPSettings = new CustomizationIPSettings();

     

        CustomizationGlobalIPSettings cgIP = new CustomizationGlobalIPSettings();

        cgIP.getDnsSuffixList().addAll(dnsSuffixList);

        cgIP.getDnsServerList().addAll(dnsServerList);

     

        //CustomizationGuiUnattended cgu = new CustomizationGuiUnattended();

          //cgu.setAutoLogon(true);

          //cgu.setAutoLogonCount(10);

          //cgu.setTimeZone(210);

          //CustomizationPassword cp = new CustomizationPassword();

          //cp.setPlainText(true);

          //cp.setValue("cloupia");

         // cgu.setPassword(cp);

     

    

          CustomizationIdentification custIdentification = new CustomizationIdentification();

          custIdentification.setJoinWorkgroup(workgroupName);

         // CustomizationUserData cud = new CustomizationUserData();

         // CustomizationPrefixName cpName = new CustomizationPrefixName();

          //cpName.setBase("MyCustomBaseWinName");

         // cud.setComputerName(cpName);

         // cud.setFullName("MyNewWindowsClone");

          //cud.setOrgName("MyNewCompanyName");

         // cud.setProductId("C4HH9-J98JF-WDWQW-4GTDW-49XWG");

         // CustomizationLicenseFilePrintData lfpData = new CustomizationLicenseFilePrintData();

          //lfpData.setAutoMode(CustomizationLicenseDataMode.PER_SERVER);

         // lfpData.setAutoUsers(Integer.valueOf(10));

        //  CustomizationWinOptions cwOptions = new CustomizationWinOptions();

         // cwOptions.setChangeSID(true);

        //  cu.setOptions(cwOptions);

          CustomizationSysprep sysprep = new CustomizationSysprep();

          //sysprep.setGuiUnattended(cgu);

          sysprep.setIdentification(custIdentification);

          //sysprep.setUserData(cud);

          //sysprep.setLicenseFilePrintData(lfpData);

          cu.setIdentity(sysprep);

       

       

          if ((ipAddress != null) && (ipAddress.length() > 0)) {

              CustomizationFixedIp cFixedIP = new CustomizationFixedIp();

              cFixedIP.setIpAddress(ipAddress);

              cIPSettings.setIp(cFixedIP);

            } else {

              CustomizationDhcpIpGenerator cDhcpIPGen = new CustomizationDhcpIpGenerator();

              cIPSettings.setIp(cDhcpIPGen);

            }

            cIPSettings.getGateway().addAll(gateway);

            cIPSettings.setSubnetMask(subnetMask);

            cIPSettings.setDnsDomain(dnsDomain);

            cIPSettings.getDnsServerList().addAll(dnsServerList);

            caMapping.setAdapter(cIPSettings);

            List<CustomizationAdapterMapping> caMappingList = new ArrayList<CustomizationAdapterMapping>();

            caMappingList.add(caMapping);

            //cu.setGlobalIPSettings(cgIP);

            cu.getNicSettingMap().addAll(caMappingList);

                  

         

            boolean vmCustomized = false;

            try

            {

           

              ManagedObjectReference taskmor = vimPort.customizeVMTask(vmMor,cu);

              if (getTaskResultAfterDone(taskmor)) {

                  System.out.println("Customizing The Virtual Machine ..........Done");

                 vmCustomized = true;

                taskmor =

                        (ManagedObjectReference) getEntityProps(taskmor,

                              new String[] { "info.result" }).get("info.result");

                  logger.print(logger.INFO, logger.AGENT, subModule,

                          "VM customized with mor value :"+vmMor.getValue());

               

               } else {

                   logger.print(logger.INFO, logger.AGENT, subModule,

                              "VM could not be customized , some exception occured ");

                  vmCustomized = false;

               }

            } catch (CustomizationFaultFaultMsg e) {

                // TODO Auto-generated catch block

                e.printStackTrace();

            } catch (RuntimeFaultFaultMsg e) {

                // TODO Auto-generated catch block

                e.printStackTrace();

            } catch (InvalidPropertyFaultMsg e) {

                // TODO Auto-generated catch block

                e.printStackTrace();

            }finally{

                disconnect();

            }

but I am getting -

java.lang.ExceptionInInitializerError

    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:107)

    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)

    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:129)

    at com.sun.proxy.$Proxy35.customizeVMTask(Unknown Source)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

    at java.lang.reflect.Method.invoke(Method.java:606)

    at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)

    at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)

    at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)

    at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)

    at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)

    at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)

    at org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)

    at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)

    at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)

    at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)

    at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)

    at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)

    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)

    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by: java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.internal.bind.api.JAXBRIContext

    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.<clinit>(SOAPFaultBuilder.java:550)

    ... 28 more

I tried looking for examples related to this but I have found out that guest os customization is being done during clone / deploy of VM . but for me windows VM is already existing and I want to customize its network. So, I was wondering if this is at all possible for windows VM ? and if yes then what I am doing wrong in above code.

Thanks in advance.

-Deep

0 Kudos
0 Replies