VMware Cloud Community
blsmithjr
Contributor
Contributor
Jump to solution

Workflow to create vCAC reservation

Hello,


We need to be able to created multi-machine VMs on demand.  We need to isolate access to the VMs, and our current approach is to have a distinct business
group/reservation for each multi-machine VM.  We do not want to have a large number of pre-defined reservations.  Is there a way that we can create a vCAC
reservation as part of a workflow?  If not, is there another suggested method to be able to have several multi-machine VMs while still limiting access
to each one?


Thank you!

1 Solution

Accepted Solutions
dcornwell
Enthusiast
Enthusiast
Jump to solution

Sorry, grabbed the wrong file.  Here is the action to create a reservation:

/***************************************
* Create a Reservation
* Input parameters:
* String businessGroupName
* vCAC:vCACHost iaasHost
* String eSXIHostName
* String reservationName
* Integer memorySize
* Integer storageSize
*
****************************************
*/

// Name of model being used
var modelName = "ManagementModelEntities.svc";

// links to other tables / objects
var links = null;

// no headers needed
var headers = null;

//Get the Business Group Entity
// Entity set that maps to Business Group is called ProvisioningGroups
var entitySetName = "ProvisioningGroups";

// Create property object that contains input value: businessGroup
var properties = {GroupName:businessGroupName };

// Read/retrieve the existing Business Group entity; there should be exactly one
var businessGroupEntities =  vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, properties, null);

if (businessGroupEntities.length <= 0 ) {
System.error("Business Group: " + businessGroupName + " not found.");
  errorCode = businessGroupName + "does not exist";
  throw businessGroupName + "does not exist";
}

System.debug("Business Group");
System.debug(businessGroupEntities[0].keyString);
System.debug(businessGroupEntities[0].getProperty('GroupName'));
System.debug(businessGroupEntities[0].getProperty('GroupID'));

//Get the eSXI Host entity
entitySetName = "Hosts";

// Create property object that contains input value: eSXIHostName
var properties = {HostName:eSXIHostName };

// Retrieve the existing Business Group entity; there should be exactly one
var eSXIHostEntities =  vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, properties, null);

if (eSXIHostEntities.length <= 0 ) {
System.error("eSIX Host: " + eSXIHostName + " not found.");
  errorCode = eSXIHostName + "does not exist";
  throw "No eSXI Host";
}

System.debug("eSXIHost");
System.debug(eSXIHostEntities[0].keyString);
System.debug(eSXIHostEntities[0].getProperty('HostID'));
System.debug(eSXIHostEntities[0].getProperty('HostName'));


if (businessGroupEntities.length > 1 ) {
System.error("Business Group: " + businessGroupName + " found " + businessGroupEntities.length + " has duplicates, can't link to reservation");
  errorCode = businessGroupName + " has duplicates, can't link to reservation";
  throw ("Business Group: " + businessGroupName + " found " + businessGroupEntities.length + " ambigious, can't link to reservation");
}

System.debug("Found Business Group: " + businessGroupEntities[0].getProperty('GroupName'));

System.debug("Found eSXI Host: ", eSXIHostEntities[0].getProperty('HostID'));

//Create Reservation
entitySetName = "HostReservations";

links = {ProvisioningGroup:businessGroupEntities[0], Host:eSXIHostEntities[0] };
var headers = null;

var testResProperties = {
  HostReservationName:reservationName,
  };

//Verify that no reservation exists with the same name for this business group
var existsRes = vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, testResProperties, null);
if (existsRes.length > 0 ) {
  System.error("Reservation : " + reservationName + " already exists; cannot create duplicate");
  throw ("Reservation : " + reservationName + " already exists; cannot create duplicate");
  }

// hard-coded for testing; should become input fields
var reservationProperties = {
  HostReservationName:reservationName,
  Enabled:true,
  ReservationMemorySizeMB:memorySize,
  ReservationStorageSizeGB:storageSize,
  MaxVMsPowerOn:99,
  ReservationPriority:1
  };

// create the Reservation
var resEntity = vCACEntityManager.createModelEntity(iaasHost.id, modelName, entitySetName, reservationProperties, links, headers);

// check Reservation entity created
if (resEntity == null ) {
  System.error("ERROR: Reservation Entity " + reservationName + " not created");
  throw("Create reservation " + reservationName + " failed");
  }
//Verify reservation by retrieving entity
var testRes = vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, reservationProperties, null);

if (testRes.length < 1 )
  System.error("ERROR: Reservation Entity " + reservationName + " not found");
 

//Return the new Reservation
System.log("Created Reservation: " + reservationName);
return (resEntity);

View solution in original post

0 Kudos
17 Replies
GrantOrchardVMw
Commander
Commander
Jump to solution

When you say "isolate", just how far are you talking? By default, only the requester and the Business Group manager (and Support Users if defined) have access to provisioned objects.

Grant

Grant http://grantorchard.com
0 Kudos
blsmithjr
Contributor
Contributor
Jump to solution

Hello,

Thank you for the response.  We want complete isolation as you describe above.  We currently have the users that will request multi-machine VMs in the same business group, as they will need to be able to have permissions to create the VMs.  We need to determine how best to use reservations.  If we cannot create reservations on demand, is there a way to change the business group associated with a reservation after VMs have been provisioned?

Thank you again!

Regards,

Bill

0 Kudos
GrantOrchardVMw
Commander
Commander
Jump to solution

Hi Bill,

Sounds like a design question Smiley Happy

Ideally what you need to do is identify how many concurrent workloads will be run at a given time, and then the total resources that will be consumed. You *could* point a given vCAC Reservation to a vSphere Resource Pool and apply a limit.

Once a workload has been provisioned, you can change the vCAC Reservation that it's associated with.

Sorry if this isn't clear, I'm still trying to figure out the end result you're driving towards.

Grant

Grant http://grantorchard.com
0 Kudos
JonKozik
Contributor
Contributor
Jump to solution



Sorry for replying to a pretty stale thread, but I've also been trying to figure out how to build a vCO workflow that will create a vCAC 6 reservation.  Ideally, I'd like to copy an existing reservation to a new reservation and change only the network and resource pool assigned. Any ideas?

0 Kudos
pizzle85
Expert
Expert
Jump to solution

I figured id post here as well.

Were looking to do automation of business group creation. We have a workflow that creates business groups, entitlements, and the works. The last part im trying to get working is the creation of a compute resource reservation. I dont see any methods in vCO that permit this. Has anyone gotten this process to work from vCO or is this just going to be a REST only thing?

0 Kudos
JonKozik
Contributor
Contributor
Jump to solution

Pizzle85, if you have been able to create reservations via REST calls, can you please post the code for that?  I've been trying to capture the calls with Firebug but it they always appear garbled like they have been encrypted.  In the meantime, I have mapped the relationships between the tables in the vCAC database and am trying to write code to directly modify the database in my spare time.  Obviously, that will not be supported by VMware, but until a programmatic way of creating reservations is provided, we have to do what we can.  Please post the syntax of the REST calls if you have it and I'll post my code if I can manage to get a reservation properly created via direct commands to the database.

0 Kudos
dcornwell
Enthusiast
Enthusiast
Jump to solution

There are no vcaccafe calls to create a reservation, you have to use the IaaS entities:

/***************************************
* Create a Reservation
* Input parameters:
* String businessGroup
* vCAC:vCACHost iaasHost
* String eSXIHostName
* String reservationName
* Integer memorySize
* Integer storageSize
*
****************************************
*/


var modelName = "ManagementModelEntities.svc";
var links = null;
var headers = null;
var entitySetName = "ProvisioningGroups";

var properties = {GroupName:businessGroupName };

// Read/retrieve the existing Business Group entity; there should be exactly one
var businessGroupEntities =  vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, properties, null);

if (businessGroupEntities.length <= 0 ) {
System.error("Business Group: " + businessGroupName + " not found.");
  errorCode = businessGroupName + "does not exist";
  throw businessGroupName + "does not exist";
}

//Get the eSXI Host entity
entitySetName = "Hosts";

// Create property object that contains input value: eSXIHostName
var properties = {HostName:eSXIHostName };

// Retrieve the existing Business Group entity; there should be exactly one
var eSXIHostEntities =  vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, properties, null);

if (eSXIHostEntities.length <= 0 ) {
System.error("eSXI Host: " + eSXIHostName + " not found.");
  errorCode = eSXIHostName + "does not exist";
  throw "No eSXI Host";
}

if (businessGroupEntities.length == 1 ) {

//Create Reservation
entitySetName = "HostReservations";
links = {ProvisioningGroup:businessGroupEntities[0], Host:eSXIHostEntities[0] };
var headers = null;

var reservationProperties = {
  HostReservationName:reservationName,
  Enabled:true,
  ReservationMemorySizeMB:memorySize,
  ReservationStorageSizeGB:storageSize,
  MaxVMsPowerOn:99,
  ReservationPriority:1
  };

// create the Reservation
var resEntity = vCACEntityManager.createModelEntity(iaasHost.id, modelName, entitySetName, reservationProperties, links, headers);

0 Kudos
pizzle85
Expert
Expert
Jump to solution

Thanks for the reply, this is great! Im not sure if there is more to your script or not. It looks like you create a variable to create a new model entity then it cuts off. I know its missing a closing bracket. is there perhaps more to the script than was was pasted in the reply? Thanks again for posting this script!!

0 Kudos
pizzle85
Expert
Expert
Jump to solution

I was able to get this working and packaged it up in an action and have attached it to this reply. For my use case i didn't need the logic checking because this will only be run at initial business group creation and we know there will only ever be one. If there is an error it will roll back the entire business group creation process and throw an error.

dcornwell, I would like to know how you knew which properties and links to use. Do you have any links to documentation or blogs on how to work with model entities. Ive gone back through the 5.1 and 5.2 docs but dont see anything that was very helpful. I would like to have this process add a portgroup and set disk allocations for a range of disks or SDRS clusters.

I found this page http://www.clearascloud.com/2013/01/vmware-vcloud-automation-center-odata.html and was able to track down a manually created reservation using the query:

from res in HostReservations

.Expand("HostNicToReservations")

.Expand("HostReservationProperties")

.Expand("HostReservationToStorages")

where res.HostReservationName == "Lab-Res-1"

select res

I see in there three "HostReservationToStorages" which is what i want, a reservation to our Gold, Silver and Bronze disk offerings. I also see a single entry in there under "HostNicToReservation" which is also what i want as it points to our "VM Guest" port group.

I was able to track down those entity sets(??) using the tool from the link above using the queries:

from nic in HostNicToReservations

select nic

from disk in HostReservationToStorages

select disk

I had hoped that i would see more detailed information about the properites, links, etc in those views but the columns are exactly what i see in the original HostReservations query.

I'm attempting to reverse engineer what you have provided but am not able to get all the way there. Im attempting to execute this to add a nic but have been working through a variety of errors:

entitySetName = "HostNicToReservations"

var nicProperties = {

  HostReservationID:resEntity,

  HostNicID:"93582d2c-3f00-4e6c-92b8-e48320a2b544"

};

var nicEntity = vCACEntityManager.createModelEntity(host.id, modelName, entitySetName, nicProperties);

Any suggestions or assistance you could provide would be greatly appreciated! Thanks again for getting me 90% of the way there.

dcornwell
Enthusiast
Enthusiast
Jump to solution

Sorry, grabbed the wrong file.  Here is the action to create a reservation:

/***************************************
* Create a Reservation
* Input parameters:
* String businessGroupName
* vCAC:vCACHost iaasHost
* String eSXIHostName
* String reservationName
* Integer memorySize
* Integer storageSize
*
****************************************
*/

// Name of model being used
var modelName = "ManagementModelEntities.svc";

// links to other tables / objects
var links = null;

// no headers needed
var headers = null;

//Get the Business Group Entity
// Entity set that maps to Business Group is called ProvisioningGroups
var entitySetName = "ProvisioningGroups";

// Create property object that contains input value: businessGroup
var properties = {GroupName:businessGroupName };

// Read/retrieve the existing Business Group entity; there should be exactly one
var businessGroupEntities =  vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, properties, null);

if (businessGroupEntities.length <= 0 ) {
System.error("Business Group: " + businessGroupName + " not found.");
  errorCode = businessGroupName + "does not exist";
  throw businessGroupName + "does not exist";
}

System.debug("Business Group");
System.debug(businessGroupEntities[0].keyString);
System.debug(businessGroupEntities[0].getProperty('GroupName'));
System.debug(businessGroupEntities[0].getProperty('GroupID'));

//Get the eSXI Host entity
entitySetName = "Hosts";

// Create property object that contains input value: eSXIHostName
var properties = {HostName:eSXIHostName };

// Retrieve the existing Business Group entity; there should be exactly one
var eSXIHostEntities =  vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, properties, null);

if (eSXIHostEntities.length <= 0 ) {
System.error("eSIX Host: " + eSXIHostName + " not found.");
  errorCode = eSXIHostName + "does not exist";
  throw "No eSXI Host";
}

System.debug("eSXIHost");
System.debug(eSXIHostEntities[0].keyString);
System.debug(eSXIHostEntities[0].getProperty('HostID'));
System.debug(eSXIHostEntities[0].getProperty('HostName'));


if (businessGroupEntities.length > 1 ) {
System.error("Business Group: " + businessGroupName + " found " + businessGroupEntities.length + " has duplicates, can't link to reservation");
  errorCode = businessGroupName + " has duplicates, can't link to reservation";
  throw ("Business Group: " + businessGroupName + " found " + businessGroupEntities.length + " ambigious, can't link to reservation");
}

System.debug("Found Business Group: " + businessGroupEntities[0].getProperty('GroupName'));

System.debug("Found eSXI Host: ", eSXIHostEntities[0].getProperty('HostID'));

//Create Reservation
entitySetName = "HostReservations";

links = {ProvisioningGroup:businessGroupEntities[0], Host:eSXIHostEntities[0] };
var headers = null;

var testResProperties = {
  HostReservationName:reservationName,
  };

//Verify that no reservation exists with the same name for this business group
var existsRes = vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, testResProperties, null);
if (existsRes.length > 0 ) {
  System.error("Reservation : " + reservationName + " already exists; cannot create duplicate");
  throw ("Reservation : " + reservationName + " already exists; cannot create duplicate");
  }

// hard-coded for testing; should become input fields
var reservationProperties = {
  HostReservationName:reservationName,
  Enabled:true,
  ReservationMemorySizeMB:memorySize,
  ReservationStorageSizeGB:storageSize,
  MaxVMsPowerOn:99,
  ReservationPriority:1
  };

// create the Reservation
var resEntity = vCACEntityManager.createModelEntity(iaasHost.id, modelName, entitySetName, reservationProperties, links, headers);

// check Reservation entity created
if (resEntity == null ) {
  System.error("ERROR: Reservation Entity " + reservationName + " not created");
  throw("Create reservation " + reservationName + " failed");
  }
//Verify reservation by retrieving entity
var testRes = vCACEntityManager.readModelEntitiesByCustomFilter(iaasHost.id, modelName, entitySetName, reservationProperties, null);

if (testRes.length < 1 )
  System.error("ERROR: Reservation Entity " + reservationName + " not found");
 

//Return the new Reservation
System.log("Created Reservation: " + reservationName);
return (resEntity);

0 Kudos
dcornwell
Enthusiast
Enthusiast
Jump to solution

I used:

- vCO Plugin for vCAC Guide - chapter on IaaS workflows

- vco team blog: http://www.vcoteam.info/articles/learn-vco/269-working-with-vcloud-automation-center-infrastructure-...

- I found specific properties and entities using LinqPad to view and query the IaaS database: http://www.linqpad.net/

I am not familiar with OData and not very much with Microsoft SQL, although I have worked with relational and object databases in the past.  Reservations are pretty straightforward; I have broken my IaaS database a couple of times with multi-machine blueprints.  Be sure to back up your system before getting too deep in IaaS entities.

pizzle85
Expert
Expert
Jump to solution

Do you set the Network during this process? How do you determine which disk you allocate your storage on?

0 Kudos
mythrandir52
Contributor
Contributor
Jump to solution

Also how would you set the alarm information?

Truth is a three edged sword
0 Kudos
willonit
Hot Shot
Hot Shot
Jump to solution

Did you ever find a way to incorporate selecting storage and network paths into this? Everything is working great except for that.

0 Kudos
M3VM
Enthusiast
Enthusiast
Jump to solution

What input should be given for 'String eSXIHostName' as I am getting the error "ESXi Host not found".. ? Is it IP or Hostname exactly?

Can give any hostname of the ComputeResource Cluster?

0 Kudos
pizzle85
Expert
Expert
Jump to solution

The esxi fqdn or drs cluster name as shown under compute resources in the GUI.

pizzle85
Expert
Expert
Jump to solution

If I recall correctly I think a native vCAC library vRO work flow was added to do this. Probably easier...

0 Kudos