3 Replies Latest reply on May 24, 2011 3:41 PM by tschoergez

    Change a mac address?

    manfriday Hot Shot



      How would I change a VM's mac address with orchestrator?


      I tried using a scriptable task and doing something like this:


      var configSpec = new VcVirtualMachineConfigSpec();
      var deviceConfigSpecs = new Array();
      deviceConfigSpec = System.getModule("com.vmware.library.vc.vm.spec.config.device").createVirtualEthernetCardNetworkConfigSpec( network1, macAddress1 );
      configSpec.deviceChange = deviceConfigSpecs;
      task = vm.reconfigVM_Task( configSpec );



      When i run it, the task starts, and is successful but no change is made to the mac address.

      IM sure there is something simple I am missing.






        • 1. Re: Change a mac address?
          Hot Shot



          in my opinion, you have to change the mac address additionally...


          if ( macAddress != null  &&  macAddress != "" )  {
              vNetwork.addressType = "Manual";
              vNetwork.macAddress = macAddress;


          best regards


          • 2. Re: Change a mac address?
            tschoergez Master
            vExpertUser ModeratorsVMware Employees


            too late night to give it a try in the lab, but I may saw three possible things:

            1. Do you need a

            devicespec.operation = VcVirtualDeviceConfigSpecOperation.edit;

            to specify that the device should be changed?


            it's already in the createVirtualEthernetCardNetworkConfigSpec()-action...

            ... Do you want to add a new card or change an existing card?



            2. Did you run into the known issue:

            • Adding values to vCenter Server data object properties of type Array is impossible
              When Orchestrator runs scripts, the vCenter Server 4.1 plug-in  converts JavaScript arrays to Java arrays of a fixed size. As a  consequence, you cannot add new values to vCenter Server data objects  that take arrays as property values. You can create an object that takes  an array as a property if you instantiate that object by passing it a  pre-filled array. However, after you have instantiated the object, you  cannot add values to the array.

              For example, the following code does not work:

              var spec = new VcVirtualMachineConfigSpec();
              spec.deviceChange = [];
              spec.deviceChange[0] = new VcVirtualDeviceConfigSpec();

              In the above code, Orchestrator converts the empty spec.deviceChange JavaScript array into the fixed-size Java array VirtualDeviceConfigSpec[] before it calls setDeviceChange(). When calling spec.deviceChange[0] = new VcVirtualDeviceConfigSpec(), Orchestrator calls getDeviceChange() and the array remains a fixed, empty Java array. Calling spec.deviceChange.add() results in the same behavior.

              Workaround: Declare the array as a local variable, as follows:

              var spec = new VcVirtualMachineConfigSpec();
              var deviceSpec = [];
              deviceSpec[0] = new VcVirtualDeviceConfigSpec();
              spec.deviceChange = deviceSpec;




            3. I miss one line where you put deviceConfigSpec to the array, something like






            • 3. Re: Change a mac address?
              manfriday Hot Shot

              Thanks for your input guys.

              A lot (almost all) of that sorta went over my head, as I am pretty new to orchestrator, and trying to bumble my way through it.

              I will digest what you have told me and see where I land on it tomorrow.


              To answer your question, I am trying to EDIT an existing nic cards mac address.


              thanks again!