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

Adding a Property to a virtual machine

$
0
0

Hello I would like to add a property to a VM in vCAC with vCO so far I am using the code below with the inputs of a virtualMachine, propertyName, propertyValue

 

 

var model = "ManagementModelEntities.svc";

var entitySet = "VirtualMachineProperties";

 

var found = false;

 

var properties = new Properties();

properties.put("VirtualMachineID", virtualMachine.virtualMachineID);

var virtualMachineEntity = vCACEntityManager.readModelEntity(host.id, model, "VirtualMachineProperties", properties, null);

 

//Find property by property name

var virtualMachinePropertiesEntities = virtualMachineEntity.getLink(host, entitySet);

for each (var virtualMachinePropertiesEntity in virtualMachinePropertiesEntities) {

    if (virtualMachinePropertiesEntity.getProperty("PropertyName") == propertyName) {

        found = true;

        break;

    }   

}

 

 

var properties = new Properties();

properties.put("PropertyName", propertyName);

properties.put("PropertyValue", propertyValue);

properties.put("IsHidden", propertyIsHidden);

properties.put("IsRuntime", propertyIsRuntime);

properties.put("IsEncrypted", propertyIsEncrypted);

 

var links = new Properties();

links.put("virtualMachine",virtualMachineEntity);

 

 

if (found == true) {

    if (doNotUpdate == false && propertyValue != "") {

        var entityKey = virtualMachinePropertiesEntity.entityKey;

        var entityKeyId = entityKey.get("Id");

        System.log("Update entity id " + entityKeyId + " with property " + propertyName + " : " + propertyValue + " on virtualMachine entity " + blueprint.displayName);

        }

        else    {

            if (doNotUpdate == true) System.log("doNotUpdate set to true - not updating property " + propertyName);

            if (propertyValue == "") System.log("not updating property " + propertyName + " with empty value");       

        }

}

else {

    System.log("Create property " + propertyName + " : " + propertyValue + " on virtualMachine entity " + blueprint.displayName);

}

 

 

I keep on getting an exception error any help would be apprciated


Viewing all articles
Browse latest Browse all 6251

Trending Articles



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