This post is more than 5 years old
3 Posts
0
165443
February 24th, 2015 04:00
Create a service based on a vApp
I am trying to create a service that contains the servers within a vCloud vApp.
We have a large vCloud environment where we use multiple servers with the same servername/IP and this presents us with the challenge that the only true unique identifier is the VM UUID.
Today we build the Service by manually adding the servers one by one by searching for the UUID but it´s time consuming and as soon as a VM is redeployed or removed the change isn´t reflected in the service.
The goal would be to be able to create a rule-based group that could automatically update the service instead.
Any ideas on how that could be accomplished?
No Events found!
BamseSE
3 Posts
0
June 10th, 2015 08:00
For future references if anyone else ever is going to need the same solution, here is a solution provided by Dell support.
Running this in the script console will create a dynamic service from a vApp defined in the script.
vAppName = 'Insert Your vApp name here'; //vApp Name
serviceName = "VCD_vApp_"+vAppName; //This is the creating service name
toMerge = [];
ts = server.get("TopologyService");
// Create Category
categoryType = ts.getType("FSMCategory"); vCat = ts.getObjectShell(categoryType); vCat.setName("Cloud"); toMerge << vCat;
// Create Service
serviceType = ts.getType("FSMService"); vServ = ts.getObjectShell(serviceType); vServ.setName(serviceName); def domainsProperty = vServ.getType().getProperty("domainAssociationIDs");
vServ.markOverridingProperty(domainsProperty);
def domainsList = vServ.get("domainAssociationIDs") as Set; domainsList << "vcloud"; vServ.setList("domainAssociationIDs", domainsList.toList());
// Add service to category
catDefintion = categoryType.getProperty("definition");
vCat.getList(catDefintion).add(vServ);
toMerge << vServ;
dmcType = ts.getType("FSMDynamicManagedComponent");
// Add all VMs
vmDMC = ts.getObjectShell(dmcType);
vmDMC.setName("VMs");
vmDMC.set("container",vServ);
vmDMC.set("componentQuery","(VMVCloudVApp where name ='"+vAppName+"').virtualMachines");
//Here to retrieve all virtualMachines of the specified vApp toMerge << vmDMC;
vServ.set("definition",[vmDMC]);
ts.mergeData(toMerge);
return;