Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Use recommendDatastores with IP cofiguration

$
0
0

Hello everybody,

 

I tried to create a workflow to clone a VM on a storage DRS cluster.

As CloneVM is not possible anymore on Storage DRS, I use the recommendDatastores function.
It almost works, as the machine is deployed, the network card is moved to the right vlan, and the hostname is changed. But there is no IP configuration, the ethX card of th machine has no IP address, and the dns search (/etc/resolv.conf file) is not updated. IT seems to me that the "cusotmization" part  is not taken into account.

 

The source is a template Linux RHEL6 machine, with only one network card.

 

Does anyone managed to do such a thing ?

 

The workflow is in attachment, and the "main" part of the script is here :

 

var managedObject = templateVM.sdkConnection.storageResourceManager;

 

 

// we prepare the specs

var storageSpec = new VcStoragePlacementSpec;

    storageSpec.cloneName = vmname;

    storageSpec.folder = destFolder;

    storageSpec.resourcePool = destResourcePool;

    storageSpec.type = 'clone';

    storageSpec.vm = templateVM;

   

    // sub specs => podSelectionSpec

    var varPodSelectionSpec = new  VcStorageDrsPodSelectionSpec;

        varPodSelectionSpec.storagePod = storage;

    storageSpec.podSelectionSpec = varPodSelectionSpec;

   

    // sub specs => cloneSpec

    var varCloneSpec = new VcVirtualMachineCloneSpec;

        varCloneSpec.powerOn = true;

        varCloneSpec.template = false;

       

        // sub specs => cloneSpec => config

        var varConfig = new VcVirtualMachineConfigSpec;

            varConfig.memoryMB = memMB;

            varConfig.name = vmname;

            varConfig.numCPUs = cpuInt;

            //

            var varChangeDevice = new VcVirtualDeviceConfigSpec;

                varChangeDevice.device = virtualEthernetCard;

                varChangeDevice.operation = VcVirtualDeviceConfigSpecOperation.edit;

            //

            varConfig.deviceChange = [varChangeDevice];

        varCloneSpec.config =     varConfig;

        // END sub specs => cloneSpec => config

       

        // sub specs => cloneSpec => custo

        var varCusto = new VcCustomizationSpec;

            // sub specs => cloneSpec => custo => GlobalIpSettings

            var varGlobalIpSettings = new VcCustomizationGlobalIPSettings;

                varGlobalIpSettings.dnsServerList = varDnsServerList;

                varGlobalIpSettings.dnsSuffixList = domainListe;

            varCusto.globalIPSettings = varGlobalIpSettings;

            // END sub specs => cloneSpec => custo => GlobalIpSettings

            varCusto.identity = varIdentity;

           

            var tempAdapter = new Array();

            tempAdapter[0] = varAdapterMapping;

            varCusto.nicSettingMap = tempAdapter;

       

        varCloneSpec.customization = varCusto;

        // AND sub specs => cloneSpec => custo

       

        // sub specs => cloneSpec => location

        var varVcVirtualMachineRelocateSpec = new VcVirtualMachineRelocateSpec;

            varVcVirtualMachineRelocateSpec.pool = destResourcePool;

        varCloneSpec.location = varVcVirtualMachineRelocateSpec;

       

        // END sub specs => cloneSpec => location

       

 

    storageSpec.cloneSpec = varCloneSpec;

    // END sub specs => cloneSpec

   

   

   

//we get the recommandation

var placementResult = new VcStoragePlacementResult;

placementResult = managedObject.recommendDatastores(storageSpec);

 

var myKey                        = new Array(); 

//System.debug(placementResult.recommendations[0]);

//System.debug(placementResult.recommendations[0].key);

myKey[0] = placementResult.recommendations[0].key 

myVcTask = managedObject.applyStorageDrsRecommendation_Task(myKey); 


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>