7 Replies Latest reply on Jul 7, 2008 6:17 AM by njain

    Can you configure or set  IP addrees for Virtual Machine?

    Manoj.Shingare Novice

      Hi,

       

       

      While creation of virtual machine , can we set IP address for it?

       

      Any sample code in c# would be appreciated .

       

      Thnks in advance for help.

       

      Manoj

        • 1. Re: Can you configure or set  IP addrees for Virtual Machine?
          njain Expert
          VMware Employees

           

          Hi Manoj,

           

           

          You cannot set the IP address for a VM while its creation.

          You can later customize the guest OS of the VM using the "CustomizeVM_Task" method. In the "CustomizationSpec", you can use the nicSettingMap.adapter.ip property to set the IP address.

           

           

          Hope the above information resolves your query.

           

           

          Regards,

          Neha

           

           

          1 person found this helpful
          • 2. Re: Can you configure or set  IP addrees for Virtual Machine?
            Manoj.Shingare Novice

            Hi Neha.

             

             

            Thanks for reply .

             

             

            As you said i can assign IP address to virtual machine using  nicSettingMap.adapter.ip property of CustomizationSpec .

             

            But the type of this property is   CustomizationCustomIpGenerator  and it again has three properties as 'argument','dynamicProperty' and 'dynamicType'

             

            Could you tell me , how to set IP in the string format to' nicSettingMap.adapter.ip property' .

             

             

            Thanks ,

            Manoj

            • 3. Re: Can you configure or set  IP addrees for Virtual Machine?
              njain Expert
              VMware Employees

              As you would see in the API reference, the CustomizationIpGenerator data object is further extended by four data objects. Thus, you would be required to implement one of these. Based on your comments I infer that you want to assign a static IP to your VM. Thus, you can use the "ipAddress" property of the "CustomizationFixedIp" data object to set the static IP address.

              • 4. Re: Can you configure or set  IP addrees for Virtual Machine?
                Manoj.Shingare Novice

                Hi Neha ,

                 

                Thanks for the reply.

                My requirement is to assign static IP address to the Virtual Machine .

                 

                As per your suggestions , I used "CustomizationFixedIp" Data Object to assign the Static Ip Address.

                 

                          public void AssignIpToVm(string vmUuid, string ipAddress)

                        {

                            ManagedObjectReference vmRef = service.FindByUuid(sic.searchIndex, null, vmUuid, true);

                            CustomizationSpec customsSpec = new CustomizationSpec();

                            CustomizationAdapterMapping adapterMap = new CustomizationAdapterMapping();

                            CustomizationIPSettings adapter = new CustomizationIPSettings();

                            //CustomizationCustomIpGenerator  obj =new CustomizationCustomIpGenerator();

                            CustomizationFixedIp fixedIP = new CustomizationFixedIp();

                            fixedIP.ipAddress = ipAddress;

                            adapterMap.adapter = adapter;

                            adapterMap.adapter.ip = fixedIP;

                 

                            customsSpec.nicSettingMap = new CustomizationAdapterMapping[] { adapterMap };

                 

                            CustomizationIdentitySettings idSettings = new CustomizationIdentitySettings();

                            customsSpec.identity = idSettings;

                 

                            CustomizationGlobalIPSettings gloIpSettings = new CustomizationGlobalIPSettings();

                            customsSpec.globalIPSettings = gloIpSettings;

                            service.CustomizeVMTask(vmRef, customsSpec);

                 

                        }

                 

                "CustomizationIdentitySettings" and "CustomizationGlobalIPSettings" are also implemented , because without its implementation CustomizeVM_Task

                does not work .

                 

                Now the above method executes successfully and does not throws any exceptions. But it does not sets the new static IP address to Virtual Machine.

                On server side , its shows the status as "A specified parameter is not correct. spec.identity" .

                 

                Could you tell me , which derive class of CustomizationIdentitySettings  is need to be implemented here and which parameters of it need to be set.

                 

                Thanks for help and support.

                 

                 

                Thanks and Regards,

                 

                Manoj V. Shingare

                • 5. Re: Can you configure or set  IP addrees for Virtual Machine?
                  njain Expert
                  VMware Employees

                   

                  Hi Manoj,

                   

                   

                  If you are setting the static IP for a Windows machine, then you can implement "CustomizationSysprep". Once you provide all the mandatory information for Sysprep, you should be able to customize guest OS of the VM.

                   

                   

                  Regards,

                  Neha

                   

                   

                  • 6. Re: Can you configure or set  IP addrees for Virtual Machine?
                    Manoj.Shingare Novice

                    Hi Neha,

                     

                    In my case,

                    I am creating virtual machine from existing template.Template used for cloning already has OS installed .

                    I think , information related to subnet mask , default gate way and dns servers is only required to assign static IP address .

                     

                    It seems from reference guide , to implement the "CustomizationSysprep" data object , information related to operating system like product key , computer name etc also need to be provided , other wise it is giving runtime exception.

                     

                    Could you tell me, how to assign static Ip address in above case.

                     

                    Thanks and Regards,

                     

                    Manoj V. Shingare

                    • 7. Re: Can you configure or set  IP addrees for Virtual Machine?
                      njain Expert
                      VMware Employees

                       

                      Hi Manoj,

                       

                       

                      While deploying a virtual machine from a template, it is advisable to customize guest operating systems. Without guest customization, the virtual machine uses the settings of the template as it is. This situation can create network conflicts when you deploy more than one virtual machine created from the same template at the same time.

                       

                       

                      During customization, VirtualCenter searches for the Sysprep package corresponding to your guest operating system. If all the relevant details are not provided, the Windows virtual machine customization does not proceed.

                       

                       

                      Thus, as per the reference guide, in order to implement the "CustomizationSysprep" data object, you need to provide all the relevant information related to operating system like product key, computer name etc.

                       

                       

                      Hope the above information is useful.

                       

                       

                      Regards,

                      Neha