VMware Cloud Community
riverson
Enthusiast
Enthusiast
Jump to solution

Get datacenter or resource pool by using vRO script

I'm currently building a service blueprint but don't want the user to have to enter resource pool or folder information.

How do I retrieve objects such as a datacenter or resource pool using the vRO scripting language?

I'm currently trying to use var myDatacenters = VcPlugin.getAllDatacenters(); to retrieve a list of datacenters to search through but I am returning zero results.

Are there any tricks to doing this?  Do I need to connect to vCenter first?  Is vCenter perhaps not communicating with vRO?

Any help would be greatly appreciated!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
riverson
Enthusiast
Enthusiast
Jump to solution

I resolved this by running a configuration workflow that exists in vRO which adds a vCenter instance to vRO.

View solution in original post

0 Kudos
4 Replies
DLally
Enthusiast
Enthusiast
Jump to solution

You can pull custom and default properties from a request using the workflow template.  vCAC/vRA should autopopulate and display which ever variables you want to call.

In my example, I have a custom property in vCAC labeled datacenter. This would output the value, which in turn you can output to take action based on what they choose.  

You would need to create an entry for each property you want displayed.

System.log("Workflow started from workflow stub " + externalWFStub + " on vCAC host " + vCACHost.displayName);

System.log("Got vCAC virtual machine " + vCACVm.virtualMachineName);

System.log("Matching virtual machine entity " + virtualMachineEntity.keyString);

var datacenter = vCACVmProperties.get('datacenter');

vmName = vCACVm.virtualMachineName;

  System.log("Got VM " + vmName);

if (vCenterVm != null) {

  System.log("Got vCloud VM " + vCenterVm.name);

}

//Displaying vCAC VM properties

if (vCACVmProperties != null) {

  var log = "";

  log += "vCAC VM properties :\n";

  var array = new Array();

  for each (var key in vCACVmProperties.keys) {

  array.push(key + " : " + vCACVmProperties.get(key));

  }

  array.sort();

  for each (var line in array) {

  log += "\t" + line + "\n";

  }

  System.log(log);

}

0 Kudos
riverson
Enthusiast
Enthusiast
Jump to solution

Thanks for your reply!

I think I know where you're coming from.  I know how to take in arguments when creating a custom Service Blueprint.

My issue has to do with retrieving objects such as a datacenter, resource pool, or vm folder from vCenter/vSphere when those fields are not given by the user.

I'd like to retrieve those objects so that I can in turn modify them or utilize their methods/fields.

0 Kudos
riverson
Enthusiast
Enthusiast
Jump to solution

I resolved this by running a configuration workflow that exists in vRO which adds a vCenter instance to vRO.

0 Kudos
alienmadness
Enthusiast
Enthusiast
Jump to solution

How is this reply even helpful.  it doesnt say why it works, it doesnt say which workflow to run, it's not very helpful

0 Kudos