Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. var transform = null;
  2. if (thinProvisioned == true) {
  3. transform = VcVirtualMachineRelocateTransformation.sparse;
  4. } else if (thinProvisioned == false) {
  5. transform = VcVirtualMachineRelocateTransformation.flat;
  6. }
  7.  
  8. if (datastore == null) {
  9. datastore = vm.datastore[0];
  10. }
  11. relocateSpec = System.getModule("com.vmware.library.vc.vm.spec").getRelocateSpec(datastore,null,host,pool,transform);
  12.  
  13. ///////////////// Build ServiceLocator for cross-vCenter vMotion -- Begin modifications JG
  14. var vCreds = new VcServiceLocatorNamePassword(); //Future: Use SAML token isntead of user/pass
  15. vCreds.username = vcusername;
  16. vCreds.password = vcpassword;
  17.  
  18. var vcSL = new VcServiceLocator();
  19. var destVcSdk = VcPlugin.allSdkConnections[1]; //TODO: Fix this hack
  20. vcSL.instanceUuid = destVcSdk.about.instanceUuid;
  21. vcSL.url = destVcSdk.name.toString();
  22. vcSL.sslThumbprint = destvCenterThumbprint; //Ugly, but vCO doesn't provide a mechanism to query vCenter SSL thumbprint that I can find.
  23. vcSL.credential = vCreds;
  24. relocateSpec.service = vcSL; //Add ServiceLocator to relocate spec
  25.  
  26. //////////////////// End substantative modifications
  27.  
  28. cloneSpec = System.getModule("com.vmware.library.vc.vm.spec").getCloneSpec(null,null,relocateSpec,powerOn,template);
  29.  
  30. var task = vm.cloneVM_Task(vmFolder, name, cloneSpec);
  31.  
  32. var actionResult = System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task,true,2);
  33.  
  34. // If success, actionResult == VC:VirtualMachine object representing the cloned VM
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement