VMware Cloud Community
CloudAutoCraft
Enthusiast
Enthusiast
Jump to solution

CloudClient -- change lease / expiration

I’m using CloudClient 3.4 against vCAC 6.1.1

I have several machines I need to change the lease for.  I’ve worked my way up to figuring out that the command I need to run is:

vra provisioneditem action execute --id da813a6e-af7a-46b7-a528-36f092c40c8a --action "Change Lease" –properties “expires=MM/DD/YY”

When I run that command, I get:

CloudClient>vra provisioneditem action execute --id da813a6e-af7a-46b7-a528-36f092c40c8a --action "Change Lease" --properties "Expires=2/1/2016"

Error: The input provided resulted in a REST exception: Unknown field: Expires. The HTTP status is 400 - BAD_REQUEST.

I need help with what to put behind --properties.  What prop(s) drive(s) lease expiration?

  1. What do I need to put in the properties field?  (Property name(s)?  Is there a certain date format?)
  2. Can I pass multiple machine IDs via a single command?  I would assume that I would comma-separate them and wrap the whole thing in quotes?
  3. Am I on the right track here?

Thanks!

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
SeanKohler
Expert
Expert
Jump to solution

Ok... so a bunch here.

Great you are using Cloud Client for one, but here is more information to help you in your thoughts and processes.

1. If you don't know how to already, be sure to know how to use Firebug or Chrome Tools(F12) to capture a request made in vRA. This gives you the postData for the makeRequest, which tells you exactly how the property keys are defined.  (for the most part... there IS an exception with a couple of the ones that are "number" format... I think memory was one of them.)

changeLease.jpg

2. Since you have Cloud Client, you can actually GET requests that were already made and see what the request was like... (you can get the Request ID from vRO inventory, from a cloud client listing, from the above makeRequest capture, and other ways)

CloudClient>vra request detail --id "a06a45da-cf76-4e67-9e23-b1e2dce11922"

changeLease2.jpg

Careful with the machineID there, it is not actually the right one for the provisioned "Resource"... for that we need the resourceRef.id  (which can also be seen in the request).  You will come to find that all the provider- part of the request are essentially the properties portion of the request, but many of them are provided by default.  The only one you have to satisfy for this action call is provider-ExpirationDate.

3. With the resourceRef.id you can get the list of actions you can run with your account entitlements.  And with the action ID and the Resource ID, you can get the fields it is expecting.

changeLease3.jpg

changeLease4.jpg

4. Now knowing the format (through several different ways), we can submit a proper set of properties in our request.

changeLease5.jpg

So at least... that is the idea behind all of it.  Unfortunately for me... I am still using 3.3.1  (but will be moving to 3.4 soon) and there are bugs on the request callback for the Change Lease Action and default date values.  It will probably work for you.  I do change lease much differently as I wrapped an ASD request around it.  I would use Cloud Client to call my ASD request.  (which works as I take in all strings and do my type conversion in workflow.)

And that brings me to this...

>>> Can I pass multiple machine IDs via a single command?  I would assume that I would comma-separate them and wrap the whole thing in quotes?

Nope.  But you can have a vRO workflow that iteratively (and/or asynchronously) calls a Cloud Client Change Lease per machine.  So you can have an array of machines, selected by the user or whatever (if you have ASD), and run the change lease on each machine in the array programmatically.  That effectively allows you to do *one successful thing*, but do it many times from one request. (Edit: Or you could send a list of machines into a shell script and iteratively move through each, but I would steer you away from that type of methodology if I could... preferring to set orchestration iteration up in vRO.)

>>>3. Am I on the right track here?

Absolutely!  You are on an awesome track and it should bring you great success.  (with, of course, some struggles and frustrations... but that's life in technology I suppose)

Keep at it and share what you find!

View solution in original post

4 Replies
SeanKohler
Expert
Expert
Jump to solution

Ok... so a bunch here.

Great you are using Cloud Client for one, but here is more information to help you in your thoughts and processes.

1. If you don't know how to already, be sure to know how to use Firebug or Chrome Tools(F12) to capture a request made in vRA. This gives you the postData for the makeRequest, which tells you exactly how the property keys are defined.  (for the most part... there IS an exception with a couple of the ones that are "number" format... I think memory was one of them.)

changeLease.jpg

2. Since you have Cloud Client, you can actually GET requests that were already made and see what the request was like... (you can get the Request ID from vRO inventory, from a cloud client listing, from the above makeRequest capture, and other ways)

CloudClient>vra request detail --id "a06a45da-cf76-4e67-9e23-b1e2dce11922"

changeLease2.jpg

Careful with the machineID there, it is not actually the right one for the provisioned "Resource"... for that we need the resourceRef.id  (which can also be seen in the request).  You will come to find that all the provider- part of the request are essentially the properties portion of the request, but many of them are provided by default.  The only one you have to satisfy for this action call is provider-ExpirationDate.

3. With the resourceRef.id you can get the list of actions you can run with your account entitlements.  And with the action ID and the Resource ID, you can get the fields it is expecting.

changeLease3.jpg

changeLease4.jpg

4. Now knowing the format (through several different ways), we can submit a proper set of properties in our request.

changeLease5.jpg

So at least... that is the idea behind all of it.  Unfortunately for me... I am still using 3.3.1  (but will be moving to 3.4 soon) and there are bugs on the request callback for the Change Lease Action and default date values.  It will probably work for you.  I do change lease much differently as I wrapped an ASD request around it.  I would use Cloud Client to call my ASD request.  (which works as I take in all strings and do my type conversion in workflow.)

And that brings me to this...

>>> Can I pass multiple machine IDs via a single command?  I would assume that I would comma-separate them and wrap the whole thing in quotes?

Nope.  But you can have a vRO workflow that iteratively (and/or asynchronously) calls a Cloud Client Change Lease per machine.  So you can have an array of machines, selected by the user or whatever (if you have ASD), and run the change lease on each machine in the array programmatically.  That effectively allows you to do *one successful thing*, but do it many times from one request. (Edit: Or you could send a list of machines into a shell script and iteratively move through each, but I would steer you away from that type of methodology if I could... preferring to set orchestration iteration up in vRO.)

>>>3. Am I on the right track here?

Absolutely!  You are on an awesome track and it should bring you great success.  (with, of course, some struggles and frustrations... but that's life in technology I suppose)

Keep at it and share what you find!

SeanKohler
Expert
Expert
Jump to solution

Well it is definitely Friday... I think I edited that about 12 times due to mistakes.  Smiley Happy

0 Kudos
CloudAutoCraft
Enthusiast
Enthusiast
Jump to solution

LOL -- I appreciate your dedication to helping your fellow cloud automators, SeanKohler!

So I wound up figuring out the solution on my own and I was just coming back out here to post an update before I call it a week.  Then I saw your post with all the GREAT info in your post -- THANK YOU!

Since my OP, I found the property name to be "provider-ExpirationDate" by use of this command:

CloudClient>vra provisioneditem action detail --actionid 418205b3-b5b0-40a4-ad15-285598a9b213 --itemid <MachineID_fromCloudClient>

Collection: $.fields[*]

+-------------------------+-----------------+-------------+-----------+--------------+----------+----------+

| id                      | label           | description | dataType  | defaultValue | required | readOnly |

+-------------------------+-----------------+-------------+-----------+--------------+----------+----------+

| provider-ExpirationDate | Expiration Date | null        | DATE_TIME | null         | false    | false    |

+-------------------------+-----------------+-------------+-----------+--------------+----------+----------+


As you pointed out, that doesn't give me the format of the DATE_TIME field, so I beat up the keyboard for awhile trying different DATE_TIME formats.  CloudClient was reporting success, but the Lease Expiration wasn't updating in vRA.  At wit's end (thanks to the lack of CloudClient documentation around property details), on a whim I added --format JSON to the command above.  Thankfully, the output from that gave me the expected format of the DATE_TIME field in the "minValue" attribute, which isn't listed in the default tabular format (I've deleted a lot of the output from the list below for conciseness's sake):


"fields" : [ {

  "id" : "provider-ExpirationDate",

  "label" : "Expiration Date",

  "description" : null,

  "dataType" : "DATE_TIME",

  "defaultValue" : null,

  "readOnly" : false,

  "required" : false,

  "visible" : true,

  "originalFieldDefition" : {

    "size" : 4,

    "id" : "provider-ExpirationDate",

    "label" : "Expiration Date",

    "description" : null,

    "dataType" : {

      "type" : "primitive",

      "typeId" : "DATE_TIME"

    },

<Deleted some output here>

      }, {

       "type" : "minValue",

        "value" : {

          "type" : "constant",

          "value" : {

            "type" : "dateTime",

            "value" : "2016-01-29T22:58:09.539+0000"

          }

        }

      } ],

So, lessons learned:

1.  Correct command here is:

vra provisioneditem action execute --id <Machine_ID> --action "Change Lease" --properties "provider-ExpirationDate='2016-02-01T11:58:09.539+0000'"

 

2.  Perhaps more importantly, play around with the output formatting in cloudclient to reveal details that aren't otherwise evident based on the documentation and command output of default formatting!

0 Kudos
SeanKohler
Expert
Expert
Jump to solution

‌Cool. I am really glad you got it working, and thanks for sharing your results!

0 Kudos