vCAC Timer triggered automatic Approval or Rejection of Machine Requests

We recently had a customer who wanted an automatic approval of machine requests after a specific time span when no other approver would have rejected the request. On the other hand he wanted an automatic rejection of machine requests after a defined idle time for machine types that used large amount of resources (as the resource is still being reserved by vCAC though not yet provisioned).

In order to achieve this we set up a resource account and added that resource to the approver group. Then we installed a script that periodically checked machines for being in an ‘AwaitingApproval’ state and checked their ‘VMCreationDate’. Calculating the timespan from [datetime]::UtcNow and that date we determined what to do with the machine and issued the corresponding request via the VMPS soap interface:

PS > $Machine.GetType().FullName
DynamicOps.ManagementModel.VirtualMachine;

PS > $VMPS = New-WebServiceProxy https://vcac52.sharedop.org/VMPS
  -Class VMPS -Namespace VMPS -UseDefaultCredential

PS > $IdTkn = New-Object VMPS.IdentityToken
PS > $IdTkn.User = '{0}\{1}' -f $ENV:USERDOMAIN, $ENV:USERNAME;

PS > $ru = New-Object VMPS.RequestUpdate;
PS > $ru.RequestID = $Machine.VirtualMachineID;
PS > $ru.Information = 'no way';
PS > $VMPS.RejectVirtualMachineRequest($IdTkn, $ru);
# OR #
PS > $ru.Information = 'doit';
PS > $VMPS.AcceptVirtualMachineRequest($IdTkn, $ru);

Trackbacks

  1. […] To further dive into it you can have a look at some of my other blog posts like machine import and Approval/Reject of requested machines. Here is a list of all actions (excluding all async […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: