VMware Cloud Community
FTVDaniel
Contributor
Contributor

can I use Attributes of type ManageObject to store vswitch and portgroups specs?

Hello

I want to configure stadard portgroups ans vswitchs with VRO

for this the idea is to predefine the specs in configuration elements and attributes

as I have seen, those types of objects (for exemple VcHostVirtuaSwitchSpec) does not exist on the attributes types

my question is, can I use ManageObject type? if yes How can I affect an object of type VcHostVirtuaSwitchSpec to an attribute of type ManagedObject

or is it only possible to use attribute of type Any (but in this case I can not check if the object is not properly defined )

what is best practices for this need?

Reply
0 Kudos
5 Replies
iiliev
VMware Employee
VMware Employee

Hi,

You cannot use attribute of type ManagedObject to store VcHostVirtualSwitchSpec object, which is one of so-called Data Object types (data objects are different than managed objects).

You can use attribute of type Any. Another option is not to store the whole VcHostVirtualSwitchSpec, but only its properties (like numPorts, etc.), and create a new VcHostVirtualSwitchSpec instance using these properties when needed.

Reply
0 Kudos
FTVDaniel
Contributor
Contributor

thanks Ilian

I tried attribute of type Any but when I store this attribute to a configuration Element value,  I can not reuse it.  if I want to read it back I have the error

"Workflow execution stack:

***

item: 'configure réseau nouvel ESX/item5', state: 'failed', business state: 'null', exception: 'Unable to get attribute value : Error getting attribute value '

so could the data object be a solution to save the spec template in configuration elements? and beeing able to reinject it to the host configuration ?

the issue by creating the spec instance is that it is composed of other objects that will need to be created too

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

If possible, could you attach a sample workflow demonstrating the issue? Also, which versions of vRO and vCenter plug-in do you use?

Reply
0 Kudos
FTVDaniel
Contributor
Contributor

trying to simplify the script to post it hear I have resolved the issue but I cannot explain why

no matter I can confirm that

I can store the objects in configurationElements and read them

vSwitchs = hostsystem.configManager.networkSystem.networkInfo.vswitch

vSwitch0 = vSwitchs.filter(function(item){return item.name == "vSwitch0"})

cluster1ElementCategory = NetConfigElemCat.configurationElements.filter(function(item){return item.name == cluster.name})[0]

cluster1ElementCategory.setAttributeWithKey("vSwitch0Spec",vSwitch0)

vSwitch0FromConfElement = cluster1ElementCategory.getAttributeWithKey("vSwitch0Spec").value;

Reply
0 Kudos
FTVDaniel
Contributor
Contributor

so I have the issue again : version of vro is 7.3

when I set a configuration element attribute with a (type any) vswitch object if I reuse it from the same Workflow (can be an other scripting task)

It works I can read the result by a getattribute

but if I do the set attribute in a workflow and the get attribute in an other workflow the get attribute generates a read error

here is an exemple

I set the attribute 'vSwitchsSpecs' (type array of any ) of the 'clusterName' configuration element

clusterName = ESXReference.parent.name;

vSwitchs = ESXReference.configManager.networkSystem.networkInfo.vswitch

clusterConfigurationElement = clusterElementCategory.configurationElements.filter(function(item){return item.name == clusterName})[0]

clusterConfigurationElement.setAttributeWithKey("vSwitchsSpecs",vSwitchs)

in the same workflow I try to read the value  it works

configurationElementValue = clusterConfigurationElement.getAttributeWithKey("vSwitchsSpecs").value;

for each(switch in configurationElementValue){

System.log(switch.spec.mtu);

}

if I launch  the workflow a second time after having comment the line 04 it does not work

so it seems that the value is not persistant in the attribute

Reply
0 Kudos