Some time back I showed a way on how one can change the placement while provisioning. The central problem is that the placement takes place in that moment when the user submits his machine request. So at any step during the provisioning the placement has already been determined and resources already have been allocated.
During my research regarding the import of existing virtual machines I came across the ‘RegisterExistingVirtualMachine()’ SOAP action the VMPS ProvisionService in vCAC. As it turns out that same method also allows for changing a reservation of machine during provisioning.
PS > $vmps.RegisterExistingVirtualMachine; OverloadDefinitions ------------------- void RegisterExistingVirtualMachine( VMPS.IdentityToken securityToken, string virtualMachineID, string hostReservationID, string hostStorageReservationID, string virtualMachineTemplateID, string owner )
So in order to use this basically your placement logic only has to determine a HostReservation and a StorageReservation based upon any custom properties you define. (And it is still advisable not to rely on a ‘Vrm.DataCenter.Location’ field as this lives at the Compute Resource level and does not make sense for stretched clusters or physical machines.) Once you determined your two reservations (by taking into account free space, inactive resources, permissions of provisioning grooups and the like …) you only have to submit a SOAP call with these parameters and your reservation will be changed. The good thing is, that you can now be sure that vCAC is informed about what you are up to (and that you do not perform any actions behind its back.)
If you want to achieve the same with vCO or any other tool you will have to generate a SOAP call with a payload similar to this:
<!-- POST https://vcac52.sharedop.org/VMPS HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: "http://dynamicops.com/VMPS/RegisterExistingVirtualMachine" Host: vcac52.sharedop.org Content-Length: 749 Expect: 100-continue Accept-Encoding: gzip, deflate --> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <RegisterExistingVirtualMachine xmlns="http://dynamicops.com/VMPS"> <securityToken xmlns:a="http://DynamicOps.VMPS.Model" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <a:ImpersonatingUser i:nil="true" /> <a:User>SHAREDOP\vcacservice</a:User> </securityToken> <virtualMachineID>bdd9a7b2-c4ba-4455-86b7-004098af9e6c</virtualMachineID> <hostReservationID>93d0987d-1a3e-4ebf-8564-164a6bf985f4</hostReservationID> <hostStorageReservationID>8f81e3c5-13b6-41b0-ba2b-4d1b8f0552ee</hostStorageReservationID> <virtualMachineTemplateID>b9fe831b-26fd-4ef0-b5c2-ee8f258f1727</virtualMachineTemplateID> <owner>SHAREDOP\vcacservice</owner> </RegisterExistingVirtualMachine> </s:Body> </s:Envelope> <!-- HTTP/1.1 200 OK Content-Length: 170 Content-Type: text/xml; charset=utf-8 Server: Microsoft-HTTPAPI/2.0 Date: Sun, 16 Feb 2014 15:09:54 GMT --> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <RegisterExistingVirtualMachineResponse xmlns="http://dynamicops.com/VMPS" /> </s:Body> </s:Envelope>