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);
1 Comment »