Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var transform = null;
- if (thinProvisioned == true) {
- transform = VcVirtualMachineRelocateTransformation.sparse;
- } else if (thinProvisioned == false) {
- transform = VcVirtualMachineRelocateTransformation.flat;
- }
- if (datastore == null) {
- datastore = vm.datastore[0];
- }
- relocateSpec = System.getModule("com.vmware.library.vc.vm.spec").getRelocateSpec(datastore,null,host,pool,transform);
- ///////////////// Build ServiceLocator for cross-vCenter vMotion -- Begin modifications JG
- var vCreds = new VcServiceLocatorNamePassword(); //Future: Use SAML token isntead of user/pass
- vCreds.username = vcusername;
- vCreds.password = vcpassword;
- var vcSL = new VcServiceLocator();
- var destVcSdk = VcPlugin.allSdkConnections[1]; //TODO: Fix this hack
- vcSL.instanceUuid = destVcSdk.about.instanceUuid;
- vcSL.url = destVcSdk.name.toString();
- vcSL.sslThumbprint = destvCenterThumbprint; //Ugly, but vCO doesn't provide a mechanism to query vCenter SSL thumbprint that I can find.
- vcSL.credential = vCreds;
- relocateSpec.service = vcSL; //Add ServiceLocator to relocate spec
- //////////////////// End substantative modifications
- cloneSpec = System.getModule("com.vmware.library.vc.vm.spec").getCloneSpec(null,null,relocateSpec,powerOn,template);
- var task = vm.cloneVM_Task(vmFolder, name, cloneSpec);
- var actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,true,2);
- // If success, actionResult == VC:VirtualMachine object representing the cloned VM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement