VMware Cloud Community
SeanKohler
Expert
Expert

ASD - Change Item (machine) Lease through VCO Workflow

Anybody have success in 6.1.x they would be willing to share?

There seems to be potentially a REST mechanism to do so by adding VCAC as a REST endpoint to VCO. That is less than ideal.

Would rather perform the action through the IaaS VCACCafe interface  (which is itself REST it appears, but nonetheless... the APIs are defined).  There seems to be a break on the ability to execute Resource Actions from a workflow at all.  Methods that used to be defined no longer work.

// should return Array of vCACCAFECsResourceOperation, but doesn't work = "403 forbidden"... it is the wrong return type anyway

var errorForbidden = vCACCAFEEntitiesFinder.getResourceActions(cafehost);

Any ideas?

Reply
0 Kudos
2 Replies
SeanKohler
Expert
Expert

And on and on and on it goes... with no help because nobody knows... :smileymischief:

Using vCAC 6 REST APIs - Part 1 - Elastic Skies

Using vCAC 6.X REST APIs - Part 2 - Elastic Skies

So based on those, grabbed the post data during a lease extension.  Gave it the old college try, and I get 403 errors during the post.

403.jpg

====================

403ad.jpg

/*
System.log(vcacvm.virtualMachineID);
System.log(vcacvm.virtualMachineName);
System.log(expirydate.getFullYear());
System.log(expirydate.getMonth()+1);
System.log(expirydate.getDate());
System.log(expirydate.getHours());
System.log(expirydate.getMinutes());
*/

var datestring = expirydate.getFullYear()+"-"+(expirydate.getMonth()+1)+"-"+expirydate.getDate()+"T"+expirydate.getHours()+":"+expirydate.getMinutes()+":00.000-0700";
System.log(datestring);

// pulled using firebug, straight from valid POST during lease extension

var leaseExtend = {
   "@type":"ResourceActionRequest",
   "resourceRef":{
      "id":"33a87fe2-52a9-43a9-bb27-37fb433f3017"
   },
   "resourceActionRef":{
      "id":"a2557742-1727-42c2-8e31-f57ade5a8097"
   },
   "organization":{
      "tenantRef":"vsphere.local",
      "tenantLabel":"vsphere.local",
      "subtenantRef":"55b46852-602a-497d-88fc-3368068e44a2",
      "subtenantLabel":"PRIVATE-INFO"
   },
   "state":"SUBMITTED",
   "requestNumber":0,
   "requestData":{
      "entries":[
         {
            "key":"provider-operationId",
            "value":{
               "type":"string",
               "value":"Infrastructure.Machine.Action.ChangeLease"
            }
         },
         {
            "key":"provider-machineId",
            "value":{
               "type":"string",
               "value":vcacvm.virtualMachineID
            }
         },
         {
            "key":"provider-MachineName",
            "value":{
               "type":"string",
               "value":vcacvm.virtualMachineName
            }
         },
         {
            "key":"provider-ExpirationDate",
            "value":{
               "type":"dateTime",
               "value":datestring
            }
         }
      ]
   }
}
leaseExtend = System.getModule("org.dojotoolkit.dojo.json").serialize(leaseExtend);
//System.log(leaseExtend);


var catalogRest = host.createRestClient(vCACCAFEServicesEnum.CATALOG_SERVICE);
System.log(catalogRest.getUrl()); // Results in good URL response so service is created

//Falls over
var response = catalogRest.post("consumer/requests/",leaseExtend);
System.log(response);


Reply
0 Kudos
SeanKohler
Expert
Expert

With no alternative for hijacking Change Lease in 6.1, decided to just do Approval Policies to limit lease selection capability for two use cases in a single business group:

1. Leases for a specific type of Blueprint Name.  (e.g. Contains "POC").

2. Leases that are requested for greater than 1 year from today (which is a moving target because tomorrow is today, tomorrow... lol).

The first one is possible.  The second one appears not to be.

For the first one, if "POC" exists in the Blueprint name for the Item that was Provisioned, it is kicked over for Approval as expected.  And this is wonderful.

POCPolicy.jpg

For the second one... not so good.

POCPolicy2.jpg

If you use Lease, it just looks at the current lease days on the machine and applies the policy based on a gt/lt/eq/!eq condition of that number.  Has nothing to do with the request only with the present state.  And there is no Requested Date field to select from.  I don't think the conditions are tied in any way to the Action the Policy is placed on.

POCPolicy3.jpg

Anybody have a real example where the request data itself is pulled and/or any kind of conditional capabilities around dates?

Reply
0 Kudos