When provisioning a server via PXE or ISO install you might run into a problem where you see your machines being in an ‘Installing OS’ state (between ‘BuildingMachine’ and ‘MachineProvisioned’) though the actual installation has finished long time ago. This might be because the ‘Guest Agent’ is either not installed on the image/machine or because there is no connectivity between the machine and vCAC (eg for security reason). Instead of waiting for the provisioning to time out there is a workaround that you might want to use: you manually advance the workflow to the next (i.e. Completed) state.
In order to do this you will lookup the (child) provisioning workflow for your machine via the WorkflowMaps and initiate a ChangeStateRequest as illustrated in the following example:
PS > $m.GetType().FullName; DynamicOps.ManagementModel.ManagementModelEntities PS > $Machine = $m.VirtualMachines |? VirtualMachineName -eq 'myServer'; PS > $wfMap = $m.WorkflowMaps |? VirtualMachineID -eq $Machine.VirtualMachineID; PS > $wfMap VirtualMachineID ChildWorkflowID ---------------- --------------- 561e4136-a0ee-4746-8108-b3aa8ca49352 8836d18a-ed82-4bcc-bb76-a29632bdd7b3 PS > $csr = New-Object DynamicOps.ManagementModel.ChangeStateRequest; PS > $csr WorkflowID NextState IsEvent ---------- --------- ------- 00000000-0000-0000-0000-000000000000 PS > $csr.WorkflowID = $wfMap.ChildWorkflowID; PS > $csr.NextState = 'BuildComplete'; PS > $csr.IsEvent = $false; PS > $m.AddToChangeStateRequests($csr); PS > $m.UpdateObject($csr); PS > $m.SaveChanges();
The API equivalent would look like this:
PS > $Method = 'POST' PS > $Uri = 'https://vcac52.sharedop.org/repository/Data/ManagementModelEntities.svc/ChangeStateRequests' PS > $ContentType = 'application/atom+xml;type=entry' PS > $Body = @" <?xml version="1.0" encoding="utf-8" standalone="yes"?> <entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"> <title /> <author> <name /> </author> <updated>2014-02-13T05:42:00.123456Z</updated> <id /> <content type="application/xml"> <m:properties> <d:IsEvent m:type="Edm.Boolean">false</d:IsEvent> <d:NextState>BuildComplete</d:NextState> <d:WorkflowID m:type="Edm.Guid">8836d18a-ed82-4bcc-bb76-a29632bdd7b3</d:WorkflowID> </m:properties> </content> </entry> "@ PS > Invoke-RestMethod -Method $Method -Uri $Uri -Body $Body -UseDefaultCredentials -ContentType $ContentType;
After issuing this request you will see your machine advancing to the ‘MachineProvisioned’ state.
Note: Depending on your workflow you might see a step with a slightly different name, you should have a look at the workflow states for your specific workflow and advance to the next desired state.
How would you set this up for a UCS provisioning? I am trying to utilize your setup to advance a physical provisioning workflow. The situation is this – it would be amazing to be able to demo feature functionality w/ the UCS Emulator. However because the agent never responds it won’t allow me to provision it fully. Is there a way to utilize your script to push past the “InstallingOS”?
Hi Jarek, though I never tried with the UCS Emulator the script in the post would normally exactly do that – advancing the state of “Installing OS” to “Machine Provisioned”. So I do not seem to fully understand your question. Did you try this out with the emulator? What kind of error are you seeing? Could it be that for UCS Deployment the states are named differently? Maybe if you gave more information via mail we could find out where the actual error is. Regards, Ronald
What does $m variable indicates? looks like the some lines are missing..
Hi Gopi, the ‘$m’ is of type ‘DynamicOps.ManagementModel.ManagementModelEntities’ as you can see in the script block, which is essentially the management context from vCAC (or to better say it, the service reference to the ManagementModelEntites.svc from vCAC). You can create that either by adding manually a ‘Add-Type -Path ‘ or just use our vCAC PowerShell module which you can download at: https://d-fens.ch/2014/05/20/biz-dfch-ps-vcac-utilities-powershell-module-available/. For a further explanation of the MgmtContext you can have a look at ‘https://d-fens.ch/2013/10/10/investigating-the-vcac-5-2-mgmtcontext/’. The reason why I did not explain on how to get to ‘$m’ is, that most/all of the vCAC scripts rely on that MgmtContext anyway. You will find a couple of other articles describing the context and on how vCAC uses it on our blog. Maybe this can further assist you in exploring vCAC. In case you have further questions please let me know. Ronald