VMware Cloud Community
yangjianus
Contributor
Contributor

[vRO] How to change custom properties 'Overrideable' to NO and 'Show in Request' to Yes from vRO script

Hi,

I'm trying to migrate Blueprint from tenantA to tenantB, part of that I want to do the following:

1. Add Costum Property,

2. Change 'Overridable' to false,

3. Show in Request' to true.

I did #1 using the following code:

var client = host.createCompositionClient();

var service = client.getCompositionCompositeBlueprintService();

var components = blueprint.getComponents();

for each(key in components.keys) {

  var component = components.get(key);

  if (component.type == "Infrastructure.CatalogItem.Machine.Virtual.vSphere") {

    var propertyDiff = new Properties();

    propertyDiff.put("Costom.Prop1", "SomeValue");

    service.updateBlueprintComponentProperties(blueprint.id, key, propertyDiff);

    break;

}

}

I printed out `component.data`, found out

// Step 1.2, Print it out (Encrypted: N, Overriable: Y, Show in Request: N)

/*

[2016-12-14 22:36:59.777] [I] visibility: false

[2016-12-14 22:36:59.784] [I] fixedValue: SomeValue

[2016-12-14 22:36:59.792] [I] encrypted: false

[2016-12-14 22:36:59.798] [I] mandatory: false

*/

// Step 2.1, Change Encrypted to Y from N

// Step 2.2, Print it out (Encrypted: Y, Overriable: Y, Show in Request: N)

/*

[2016-12-14 22:36:59.777] [I] visibility: false

[2016-12-14 22:36:59.784] [I] fixedValue: SomeValue

[2016-12-14 22:36:59.792] [I] encrypted: true

[2016-12-14 22:36:59.798] [I] mandatory: false

*/

// Step 2.3, Change Overriable to N from Y

// Step 2.4, Print it out (Encrypted: Y, Overriable: N, Show in Request: N)

/*

[2016-12-14 22:36:59.777] [I] visibility: false

[2016-12-14 22:36:59.784] [I] fixedValue: SomeValue

[2016-12-14 22:36:59.792] [I] encrypted: true

[2016-12-14 22:36:59.798] [I] mandatory: false

*/

// Step 2.5, Change Show in Request to Y from N

// Step 2.6, Print it out (Encrypted: Y, Overriable: N, Show in Request: Y)

/*

[2016-12-14 22:36:59.777] [I] visibility: true

[2016-12-14 22:36:59.784] [I] fixedValue: SomeValue

[2016-12-14 22:36:59.792] [I] encrypted: true

[2016-12-14 22:36:59.798] [I] mandatory: true

*/


Which make me think visibility (maybe mandatory) are map to Show in Request. (I maybe wrong 🙂

So, I tried different way to change those two values, but none of them work.

  // Try 3.1

// propertyDiff.put("Costom.Prop1", prop1);

/*

[2016-12-14 23:47:36.884] [E] Error in (Workflow:UpdatePropertyGroup / Scriptable task (item1)#61) Could not write content: No serializer found for class ch.dunes.model.client.LogFactory and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.HashMap["Costom.Prop1"]->ch.dunes.vso.sdk.DynamicWrapper["javaObject"]->com.vmware.vcac.composition.rest.stubs.ComponentFieldValue["facets"]->java.util.Hashtable["visibility"]->ch.dunes.vso.sdk.DynamicWrapper["parentScope"]->ch.dunes.scripting.server.script.MainScriptingObject["factory"]->ch.dunes.ejb.client.VSOServerFactoryClient["logFactory"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class ch.dunes.model.client.LogFactory and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.HashMap["Costom.Prop1"]->ch.dunes.vso.sdk.DynamicWrapper["javaObject"]->com.vmware.vcac.composition.rest.stubs.ComponentFieldValue["facets"]->java.util.Hashtable["visibility"]->ch.dunes.vso.sdk.DynamicWrapper["parentScope"]->ch.dunes.scripting.server.script.MainScriptingObject["factory"]->ch.dunes.ejb.client.VSOServerFactoryClient["logFactory"])

*/

  // Try 3.2

  var newProp2 = new vCACCAFEComponentFieldValue();

  var newProp2Data = newProp2.getData();

  newProp2Data.put("visibility",  vCACCAFEVisibilityConstraint.fromBoolean(true));

  newProp2Data.put("mandatory",  vCACCAFEMandatoryConstraint.fromBoolean(true));

  propertyDiff.put("Costom.Prop2", newProp2);

  // Try 3.3

  var newProp3 = new vCACCAFEComponentFieldValue();

  // Try 3.3.1

  newProp3.addFacetValue("visibility", new vCACCAFEConstantValue(vCACCAFEBooleanLiteral.fromBoolean(true)));

  newProp3.addFacetValue("mandatory",  new vCACCAFEConstantValue(vCACCAFEBooleanLiteral.fromBoolean(true)));

  // Try 3.3.2

  newProp3.addFacetValue("visibility",  vCACCAFEConstantValue.fromBoolean(true));

  newProp3.addFacetValue("mandatory",  vCACCAFEConstantValue.fromBoolean(true));

  propertyDiff.put("Costom.Prop3", newProp3);

  // Try 3.4

  var newProp4 = new vCACCAFEComponentFieldValue();

  var newProp4FacetArray = [new vCACCAFEVisibilityConstraint(true), new vCACCAFEMandatoryConstraint(true)];

  var newProp4Facets = new Properties();

  for each(facet in newProp4FacetArray) {

  newProp4Facets.put(facet.getClass(), facet);

  }

  newProp4.setFacets(newProp4Facets);

  propertyDiff.put("Costom.Prop4", newProp4);

  service.updateBlueprintComponentProperties(blueprint.id, key, propertyDiff);

Also, even I change the value to true, true manually, the code above will change it back to false. Like back to default value.

Is there a way to change those? Or there is a bug on facets changes? I am stuck on this for a whole day, please help 🙂

I'm using vRA 7.1.

0 Kudos
1 Reply
yangjianus
Contributor
Contributor

After more test, it seems like all the Custom Properties updated by service.updateBlueprintComponentProperties function, will reset (Encrypted, Overridable, Show in Request) to (No, Yes, No).

0 Kudos