VMware Cloud Community
mythrandir52
Contributor
Contributor

Automating the creation of reservation

I am trying to automate my work of creating reservations.  I am leveraging the vco plug-in from flow grab (here) to do the basic creation of reservations.  With the plug-in i am able to create the base reservation, add the storage to the reservation and add the network mappings to the reservation.  I am missing just a few items i have been trying to create my own workflow with no progress to add the reservation policy.  Also, as a smaller item i need to setup the alerting tab.  How do i set the reservation policy for a reservation.

I am doing this as a small step of a greater workflow i am creating to create the entire business group in an automated fashion.

Steps in my busniess group creation master workflow:

  1. normalize business group name
  2. create ad groups for group manger and users
  3. create business group
  4. open helpdesk tickets to mail enable active directory groups. ==aSync-Process==
  5. assign ad groups and email to business group
  6. create separate entitlements for Linux and Windows devices
  7. add actions and blueprint to entitlements.
  8. create reservation for each data center  ==> flow grab workflow
  9. assign storage to each reservation  ==> flow grab workflow
  10. assign networks appropriate to the data center  ==> flow grab workflow
  11. assign reservation policy to the reservation  -----  This is where i am stuck  ------
  12. Create custom group in vrops for the business group based on tags assign to requested machines.
  13. Send managers cheat sheet to Group managers
  14. Send users cheat sheet to the users
Truth is a three edged sword
Reply
0 Kudos
4 Replies
BenNeise
Contributor
Contributor

We're looking at doing similar things, with the automated creation of Business Groups, Reservations, Reservation Policies, Entitlements, Blueprints and Catalog Items.

You can set the Reservation Policy of a Reservation by linking the entities. The following script, in a workflow with inputs of reservationName (string), reservationPolicyName (string) and vcacHost (vCAC:vCACHost), should do that for you:-

const model = "ManagementModelEntities.svc";

// Get the reservation entity

System.log("Getting the reservation entity with the name: " + reservationName);

var entitySetName = "HostReservations";

var query = new Properties();

  query.put("HostReservationName",reservationName);

var reservationEntity = vCACEntityManager.readModelEntitiesByCustomFilter(

  vcacHost.id,

    model,

    entitySetName,

    query,

    null

);

// That returns an array of results, so let's use the first value

if (reservationEntity.length === 1){

  reservationEntity = reservationEntity[0];

}

else {

  throw ("Wrong number of reservations found: " + reservationEntity.length);

}

// Get the reservation policy entity

System.log("Getting the reservation policy with the name: " + reservationPolicyName);

var entitySetName = "HostReservationPolicies";

var query = new Properties();

  query.put("name",reservationPolicyName);

var reservationPolicyEntity = vCACEntityManager.readModelEntitiesByCustomFilter(

  vcacHost.id,

    model,

    entitySetName,

    query,

    null

);

// That returns an array of results, so let's use the first value

if (reservationPolicyEntity.length === 1){

  reservationPolicyEntity = reservationPolicyEntity[0];

}

else {

  throw ("Wrong number of reservations found: " + reservationPolicyEntity.length);

}

// Link the reservation entity to the reservation policy entity

System.log(

  "Linking the reservation policy " +

  reservationEntity.getProperty("HostReservationName") +

  " with the reservation policy " +

  reservationPolicyEntity.getProperty("name")

);

var entitySetName = "HostReservations";

var updateProperties = new Properties();

var links = new Properties();

  links.put("HostReservationPolicy",reservationPolicyEntity);

var headers = null;

System.getModule("com.vmware.library.vcac").updateVCACEntity(

  vcacHost.id,

  model,

  entitySetName,

  reservationEntity.keyString,

  updateProperties,

  links,

  headers

);

This works with 6.2.3.

I've had a quick look at the alerting, and doing it in this method looks like it might be a bit... fiddly. You might need to create/configure an Alerts entity, link that to your HostReservations entity, then link that Alerts entity to a number of AlertItems and AlertEmailAddresses entities.

Just out of interest; how do you plan on doing the tagging for vROPs?

Reply
0 Kudos
Craig_G2
Hot Shot
Hot Shot

Hey it's cool to see that my package is of use to someone!

You can assign a reservation policy with the reservationPolicyId property.

In prepare template add:

jsonObject['reservationPolicyId'] = reservationPolicyId;

You'll just need to work out the id from the reservation policy form it's name. For example, in v7 you can do this:

var reservationClient = vCACCAFEHost.createReservationClient();

var reservationPolicyService = reservationClient.getReservationReservationPolicyService();

var reservationPolicyName = "ReservationPolicy1"

var reservationPolicyArray = reservationPolicyService.getAllReservationPolicies().getContent();

var reservationPolicy = reservationPolicyArray.filter(function :smileyinfo: {

  var name = i.getName().toLowerCase();

  return (name === reservationPolicyName.toLowerCase());

});

return reservationPolicy[0].getId();

But with v6 createReservationClient didn't exist, which is why I used the native restClient.

I'm planning to update the package quite soon so I will add the ability to select reservation policy from the presentation form.

Out of interest, what version of vRO are you running?

Thanks

Craig

Reply
0 Kudos
ymichalak
Hot Shot
Hot Shot

Hi Guyz,

the website for flow grab is down.

It's possible to find an other location to download this plug-in : Reservation Manager ?

 

Thx for your feedback.

Reply
0 Kudos
alagar_ford
Contributor
Contributor

I was looking for creating reservation Policy via createReservationPolicy method. Please advise
Reply
0 Kudos