VMware Cloud Community
sandy_1234
Enthusiast
Enthusiast
Jump to solution

Automate configuring VXLAN in NSX using Rest API and vRO - MOID ???

Rest API documentation says we need make a post request with below details"

POST /api/2.0/nwfabric/configure

<nwFabricFeatureConfig>

<featureId>com.vmware.vshield.vsm.vxlan</featureId>

<resourceConfig>

<resourceId>CLUSTER MOID</resourceId>

<configSpec class="clusterMappingSpec">

<switch>

<objectId>DVS MOID</objectId></switch>

<vlanId>0</vlanId>

<vmknicCount>1</vmknicCount>

<ipPoolId>IPADDRESSPOOL ID</ipPoolId>

</configSpec>

</resourceConfig>

<resourceConfig>

<resourceId>DVS MOID</resourceId>

<configSpec class="vdsContext">

<switch>

<objectId>DVS MOID</objectId>

</switch>

<mtu>1600</mtu>

<teaming>ETHER_CHANNEL</teaming>

</configSpec>

</resourceConfig>

</nwFabricFeatureConfig>

There are a couple of XML tags above where we need to submit MOID. The input is intended to provide is the names Say cluster Name, DVS Name, IPAddress pool Name instead of MOID. I need suggestions on how to use these names and convert those to respective MOID.

Thanks

Sandeep

Tags (2)
Reply
0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Sandeep,

There is no 1:1 mapping between object names and object IDs. For example, you can have several clusters with name Cluster1 in different folders, each cluster having different MOID. So you have to somehow resolve this naming conflict and deterministically pick one of these objects.

Usually, vRO workflows does not provide a simple edit box for users to enter managed object name as text. Instead, they provide an input field of a certain type provided by the corresponding plug-in (for cluster example above, the input field would be of type VC:ClusterComputeResource). So, when the users launch the workflow presentation, they won't be required to enter the name Cluster1 but instead will be able to open an object browser, which will allow them to browse vCenter inventory and select particular cluster object. When the object is selected, the users will see the object name in the UI, but in scripting code they will access to the whole scripting object including its MOID (usually, a property named id).

Another option is to implement your own scripting action or workflow to search for objects by name. The drawbacks of this approach are:

  • if you don't limit the scope where to search for an object with such name, the code will likely search the entire vCenter inventory and could return multiple objects with such name, so you need to somehow pick one of them
  • related to the above, depending on how the scripting code is implemented, the search could be slow; in some cases, really really slow

I you still want to try search-by-name approach, take a look at the out of the box workflow 'Get virtual machines by name' and the other workflow it calls. Those could be used as a starting point.

View solution in original post

Reply
0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee
Jump to solution

Hi Sandeep,

There is no 1:1 mapping between object names and object IDs. For example, you can have several clusters with name Cluster1 in different folders, each cluster having different MOID. So you have to somehow resolve this naming conflict and deterministically pick one of these objects.

Usually, vRO workflows does not provide a simple edit box for users to enter managed object name as text. Instead, they provide an input field of a certain type provided by the corresponding plug-in (for cluster example above, the input field would be of type VC:ClusterComputeResource). So, when the users launch the workflow presentation, they won't be required to enter the name Cluster1 but instead will be able to open an object browser, which will allow them to browse vCenter inventory and select particular cluster object. When the object is selected, the users will see the object name in the UI, but in scripting code they will access to the whole scripting object including its MOID (usually, a property named id).

Another option is to implement your own scripting action or workflow to search for objects by name. The drawbacks of this approach are:

  • if you don't limit the scope where to search for an object with such name, the code will likely search the entire vCenter inventory and could return multiple objects with such name, so you need to somehow pick one of them
  • related to the above, depending on how the scripting code is implemented, the search could be slow; in some cases, really really slow

I you still want to try search-by-name approach, take a look at the out of the box workflow 'Get virtual machines by name' and the other workflow it calls. Those could be used as a starting point.

Reply
0 Kudos
sandy_1234
Enthusiast
Enthusiast
Jump to solution

Thanks, illian. Make sense now.  Nicely explained.

Regards

Sandeep

Reply
0 Kudos