Over the last few years, I have spoken to a number of customers who have greatly benefited from the ability to live migrate Virtual Machines across different vCenter Servers that are NOT part of the same vCenter Single Sign-On (SSO) Domain, which I had first shared back in 2015 here and here. This extended capability of the Cross vCenter vMotion feature enabled customers to solve new use cases that were challenging, especially for scenarios such as Datacenter migration, consolidation or even migrating existing workloads from their current environment into new SDDC deployments such as VMware Cloud Foundation (VCF) as an example.
Although customers could initiate Cross vCenter vMotions using the vSphere API which included PowerCLI (Move-VM cmdlet was enhanced in 6.5, more details here), the overall experience was still not as friendly. This was especially true for customers who may only have a small number of VMs to migrate and prefer a UI-based interface rather than an API/CLI only option. In addition, for large number of VM migrations, there was not an easy way to perform "batch" VM migrations that was easily consumable for folks who may not have a strong background in Automation or the vSphere APIs.
Today, I am pleased to share a new VMware Fling called the Cross vCenter Migration Utility that will help simplify the consumption of initiating VM migration(s) across different vCenter Servers, especially between dispart SSO Domains where a graphical interface was not available. This solution was developed out of our VMware Cloud Foundation (VCF) Engineering group which is part of the Integrated Systems Business Unit at VMware. I had spoken to a number of folks within the group about the extended Cross vCenter vMotion capability and I was super excited when I heard they were planning to release this tool as a Fling and make it available to all customers. I was fortunately to have been involved in the project alongside the Engineering lead Vishal Gupta and we are excited that we can finally talk about this project and see how customers will be using this new tool.
UPDATE (05/07/18) - The Fling has just been updated to 2.0 with the following new features:
- Added support to select individual host as the placement target
- Added support for migrating VMs with shared datastore
- Added clone functionality in addition to relocate
- Added resource summary details for placement targets
- Added a prompt to verify site thumbprint during SSL verification
- Added a link to refresh vm list in the inventory view
- Updated REST APIs to add operation type parameter
Cross vCenter Migration Utility Fling
Cross vCenter vMotion Requirements: KB 2106952
Download Fling here
- Completely UI-driven workflow for VM migration
- Provides REST API for managing migration operations
- Works with vCenter not part of the same SSO domain
- Supports both live/cold migration of VMs
- Batch migration of multiple VMs in parallel
- Flexible network mappings b/w source and destination sites
Simplified UI
The Fling is a multi-platform Java client application that can run on Windows, macOS and Linux. After you start the application from the command-line, you can simply access it using a web browser which runs on localhost and port 8080 (default). The first step is to register your vCenter Server(s) as shown in the screenshot below, you can register as many as you want but do note that the application is stateless and the configurations will be lost once the application is closed.
Once you have registered your vCenter Server(s), you can initiate a VM migration request by simply going to the Migrate tab. Here you select the source and target resources and VM(s) that you wish to migrate. The really nice thing about the UI is that it will automatically detect all VM Networks for the VMS that you have selected which makes mapping the destination networks a breeze. Once you are ready, you can click submit and watch the progress either using the UI and/or the vSphere Web/H5 Client.
Automation via REST API
For customers with smaller environments, a simplified UI is a great option, but we knew the UI should not be the only method of consumption. In fact, we assume most will want to drive this from Automation standpoint which meant having a nice simplified REST API. In the upper right hand corner of the application, you will find an "API" link to built-in Swagger documentation. Not only can you access the REST API documentation within the application but you can also use the API directly from the Swagger UI if you would like as shown in the screenshot below.
PowerCLI Integration
I know many of our customers today automate using PowerCLI and I thought this would be a great way to not only help test the Fling's REST API but to also share some useful PowerShell functions that customers can quickly take advantage of immediately for the initial vCenter Server registration to initiating batch migration requests.
With that, I have created a PowerShell module called XVM.psm1 which you can simply download and import by running the following command:
Import-Module XVM.psm1
Once imported you will have access to the following 7 functions:
- Get-VMNetwork
- Get-XVCMSite
- Get-XVCMStatus
- Get-XVCMTask
- New-XVCMRequest
- New-XVCSite
- Remove-XVCMSite
Below is a screenshot of using the Get-XVCMStatus, New-XVCMSite and Get-XVCMSite to check whether the API endpoint is running and then registering two vCenter Servers and listing them afterwards.
The Get-VMNetwork uses PowerCLI behind the scenes to take in a list of VMs (if left blank, all VMs are returned) and provides a nice summary output of all VM Networks that are attached to the VMs that you might be interested in migrating. This is useful for creating the network mapping for migrating between your source and destination vCenter Server.
The New-XVCMRequest is what starts a VM migration request (hot/cold) and the input params should be fairly straight forward. You will need to provide the logical site name that we had defined earlier, in our example below that is SiteA and SiteB. Next, we need to provide the source and destination vSphere Datacenter and Cluster, destination vSphere Datastore which will be used for VM placement on the destination vCenter Server. You also will need to include a list of VMs you wish to migrate, notice the input is similar to that of Get-VMNetwork function. Finally, you need to include a hashtable of the VM networks to map between your source and destination vCenter Server. Upon a submitting a successful migration request, you get back a TaskId that you can then pass into the Get-XVCMTask function to get progress on the individual migrations as shown in the screenshot below.
PowerCLI Demo
Here is a video demonstrating the use of the PowerCLI Module
Cross vCenter Migration Utility Fling - PowerCLI Integration Demo from lamw on Vimeo.
We hope you give the Fling a try and if you have any feedback or comments, feel free to leave it on my blog or better yet, directly on the Fling site where both Vishal and I will be monitoring.
Jason says
Very useful Fling! Do the pre-flight checks include MAC address uniqueness at the destination (in other words, ensuring an existing VM the destination does not have a conflicting MAC address)? Thanks!
William Lam says
Jason,
There's currently no pre-flight checks built into the underlying vMotion API which is what the Fling is consuming (think of it as a client that uses the API just like the vSphere Web Client for example). This is something that we definitely could consider adding into the Fling
Jason says
Thanks for replying! I look forward to seeing if that functionality gets added. Thanks
Pablo Bezares says
Hi, I am planning to migrate VMs from vCenter 6.5 to 7.0U3. Can I do a cross vCenter migration of AD, exchange and database (SQL and Oracle) workloads? Is there any workload not recommended?
Thanks,
William Lam says
You’ll have to test for your specific application/usage. We’ve had customers share they’ve been successful for such workloads, not no details of load/config/etc
Chip Zoller says
There is a minor but important clarification that is needed in KB 2106952 relating to xvMotion. The first two column headers are "Source vCenter Server" and "Destination vCenter Server" respectively, but the values provided in each are "vSphere". This brings up an important question on which I'd like clarification: What if the source or destination vCenter is at the version specified but the ESXi hosts are not? For example, will a xvMotion succeed where the source is vC 6U3 + ESXi 6U2 and the destination is vC 6.5U1 + ESXi 6.5U1? This is an important distinction for customers that may wish to use the API or Fling because it informs them what exactly they must upgrade on the source vSphere side in order to accomplish migrations. Is it only vCenter, or vCenter and ESXi?
William Lam says
Its BOTH. vCenter Server + ESXi hosts must be the same version. vSphere, IMHO, is a "Family" name that includes BOTH VC+ESXi hosts, but I know its often used interchangeably with the ESXi Hypervisor which can cause some confusion.
Chip Zoller says
That's what I figured, but the column headers cause a slight bit of confusion and I know that this question will be one asked when considering cross vCenter migrations.
Lieven D'HOORE says
Which network ports need to be opened between the different components?
Gianluca says
I too would like to know it this leverages the already configured migration networks/ports (8000) configured on source and target ESXi as detailed here:
https://docs.vmware.com/en/VMware-vSphere/6.5/com.vmware.vsphere.upgrade.doc/GUID-171B99EA-15B3-4CC5-8B9A-577D8336FAA0.html
or not. Thanks
Brad says
just tried this for moving vm's from 6.0 vcsa to 6.5 and getting an error. "error while getting placement results for vm". Any idea's?
Vishal says
Hi Brad,
The error is coming from vSphere PlaceVm function so it should not be due to an issue with the utility itself. It basically means that DRS could not place the VM in the destination cluster. Could you verify if the cluster has DRS enabled? This link provides more information around the possible causes:
https://vdc-repo.vmware.com/vmwb-repository/dcr-public/723e7f8b-4f21-448b-a830-5f22fd931b01/5a8257bd-7f41-4423-9a73-03307535bd42/doc/vim.ClusterComputeResource.html#placeVm
Vadym says
Hallo!
I have vcenter 6 and i migrating vm to vcenter 6.5. I register my vcenter in xvmotion.
But i don't see my VM in vcenter 6! I see cluster, datacenter and storage, but i don't see VM
I have 400 Vm in my datacenter.
Vadym says
I don't see VM only in xvmotion
Fredrick Smith says
I am getting an error when trying to migrate VMs. "The object or item referred to could not be found." Any ideas.
Tim says
Can you migrate a vSphere 6.5 Standard environment to a 6.5 Enterprise environment with this tool? Or do both environments need to be the same edition?
lamw says
Less important about the same edition but rather the Cross vCenter vMotion licensed feature which will be needed from BOTH vCenter Servers or else the operation should fail with a not valid license warning.
Willies Mustache says
Does it support migration from traditional setups (host-san) to vSAN?
mark says
i dont see the register button?
windows 10.
mark says
found the issue with Java version all good...Thanks
Robert says
Hi William,
thanks again for your great posts!
There is one thing that is nearly never mentioned....and for me, it is not 100% sure, if this is needed or not.
How does the traffic flow between the different vcenter servers (and the ESXi hosts)? Does traffic go through the "management network" or through the "vmotion network" (of the ESXi hosts)?
Let's turn it around. What if I really want to BLOCK cross vcenter migration (even through the API or with this new tool)? Do I only have to make sure, all ESXi hosts of vcenter A cannot reach any of the ESXi hosts of vCenter B via the "vmotion network"?
Thanks for your help.
Robert
peter creegan says
is there any sort of 'back out' if there is a failure ?
William Lam says
Yes, this is automatically built into the underlying vMotion API. If it fails for whatever reason, the VM will not move. This is same behavior as the vSphere UI
Dario says
Hi
We're planning to move VMs from a DC to a different one, on a new vCenter environment. Should we have shared storage to perform hot migration?
I try to explain better my doubt:
In this utility Summary, it's reported that "Performs storage vMotion, not requiring shared storage" while in Requirements there is a link to KB2106952 in which there is a contradictory phrase, "For migration of compute resources only, both vCenter Server instances must be connected to the shared virtual machine storage".
If I have a machine with Cross vCenter Workload Migration Utility running, both access from this machine to new & old vCenters and no shared storage between new & old vCenter, will I be able to hot-migrate VMs? Does the local storage of my machine act like a bridge to keep alive VMs during migration?
Thanks in advance,
Dario
Amarnath says
Did you complete your migration? can you please briefly explain. live migration not possible without shared storage.
John Andrews says
My port 8080 is already being used by another process. I tried adding -Dserver.port=8082 but it still tries and fails to use port 8080
PS C:\Users\jxxxxxx\Downloads\xvm-2.2\xvm-2.2> java -jar .\xvm-2.2.jar -Dserver.port=8082
Picked up _JAVA_OPTIONS: -Xmx512M
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.3.RELEASE)
09:20:40 INFO Starting ApiController v2.2 on DC1-PDW-JMPSV03 with PID 16612 (C:\Users\jxxxxxxx\Downloads\xvm-2.2\xvm-2.
2\xvm-2.2.jar started by jxxxxxxx in C:\Users\jandrews\Downloads\xvm-2.2\xvm-2.2)
09:20:40 DEBUG Running with Spring Boot v2.0.3.RELEASE, Spring v5.0.7.RELEASE
09:20:40 INFO No active profile set, falling back to default profiles: default
09:20:42 INFO Initializing ProtocolHandler ["http-nio-8080"]
09:20:42 INFO Starting service [Tomcat]
09:20:42 INFO Starting Servlet Engine: Apache Tomcat/8.5.31
09:20:42 INFO The APR based Apache Tomcat Native library which allows optimal performance in production environments wa
s not found on the java.library.path: [C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\Sun\Java\bin;
C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Java\jre1.8.0_1
51\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\W
indowsPowerShell\v1.0\;C:\Program Files\PuTTY\;C:\Windows\idmu\common;.]
09:20:42 INFO Initializing Spring embedded WebApplicationContext
09:20:44 INFO Context refreshed
09:20:44 INFO Found 1 custom documentation plugin(s)
09:20:44 INFO Scanning for api listing references
09:20:44 INFO Starting ProtocolHandler ["http-nio-8080"]
09:20:44 ERROR Failed to start connector [Connector[HTTP/1.1-8080]]
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-8080]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.j
ava:256)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:198)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServ
erApplicationContext.java:300)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServe
rApplicationContext.java:162)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerAppli
cationContext.java:140)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
at com.vmware.xvm.ApiController.main(ApiController.java:321)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1020)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 21 common frames omitted
Caused by: java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.Net.bind(Unknown Source)
at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:210)
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1150)
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591)
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018)
... 22 common frames omitted
09:20:44 INFO Pausing ProtocolHandler ["http-nio-8080"]
09:20:44 INFO Stopping service [Tomcat]
09:20:44 INFO The stop() method was called on component [StandardServer[-1]] after stop() had already been called. The
second call will be ignored.
09:20:44 INFO Stopping ProtocolHandler ["http-nio-8080"]
09:20:44 INFO Destroying ProtocolHandler ["http-nio-8080"]
09:20:44 ERROR
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector
may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this app
lication to listen on another port.
Dwayne says
CLi option for shared storage , Bulk migration - What should i use for the Variable -DstDatastore
Dwayne says
Hi I Keep getting this error
Invoke-WebRequest : The remote server returned an error: (500) Internal Server Error.
At C:\Temp\Fling\XVM.psm1:208 char:16
+ ... $results = Invoke-WebRequest -Uri $Uri -Method POST -Body $body -Con ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Failed to initiate migration request
Kenneth van Ditmarsch says
Hi William,
Thanks for the great post! I noticed that the XVM.psm1 module isn't up to date in a sense that is doesn't let you place VM's in target folders. Any chance on getting this updated?
Thanks,
Kenneth
Kenneth van Ditmarsch says
Ah, I only now noticed that it's generating the JSON so I should be fine by editting the module myself.
David Lutz says
I am getting certificate errors stating the name does not match even though the name matches the subject and SAN names on the certificate. I tried by IP as well, which is not in the certificate, and get the same error.
"server.company.local does not match the subject name listed on the certificate".
Hui-Jen (Jen) Shiau says
Hi, so, the thing I am confused by is that you state that you can vmotion between two vcenters in two different SSOs, yet the KB you quoted has the following pre-requisite:
https://kb.vmware.com/s/article/2106952
When using the vSphere Web Client, both vCenter Server instances must be in Enhanced Linked Mode and must be in the same vCenter Single Sign-On domain so that the source vCenter Server can authenticate to the destination vCenter Server.
That seems to contradict your claim. Can you please clarify? Does that mean we can't use the gui and must use a powercli script instead?
Mike Somerville says
William and Vishal - AWESOME! Can this be used to do vCenter-A to vCenter-B migrations when both A and B are two different SDDC's, in VMC on AWS? Will it work if in the same Region but different VPC's? How about In two different Regions?
Thanks for this great solution.
#toTheCloud
~mikes
William Lam says
Mike,
Yes, you'll be able to migrate between two different vCenter Servers which resides in two different SDDC within VMC. We just recently added support for NSX-T Opaque Networks (see https://www.williamlam.com/2019/04/nsx-t-opaque-networks-now-supported-with-cross-vcenter-workload-migration-fling.html).
One thing to be aware of is that you can not migrate between two NSX-T-based SDDC, this is currently a limitation of vCenter Server and same applies if you're coming from on-prem w/NSX-T to NSX-T based SDDC. Having said that, you can still perform a "cold" relocate but if you need vMotion, check out the new Cloud to Cloud feature that was added to HCX a couple of releases ago. In case you're not aware, HCX is free for VMC customers and its recommended option for large migrations, especially with the new C2C feature, you can do vMotion between NSX-T SDDC which can reside between two different SDDCs
Regarding the questions on different VPC and regions, this should work as well but you may incur charges as you cross the VPC/region, so something to consider
Mike Somerville says
Hi William. THANK YOU! Indeed I got some assitance from VMC on AWS and am currectly waiting for the C2C feture flag to be enabled... That said, with a IPsecVPN set up between SDDC-a and SDDC-b the UI works *perfectly" for a Clone - that's all I need for now. However, the PowerCLI is giving me an issue and I am sure its just the syntax - I am getting hung up on the NetworkMapping.
from :
PS C:\Windows\system32> Get-VMNetwork -srcVMs @("mikesUBUNTU")
Name Adapter Network
---- ------- -------
mikesUBUNTU Network adapter 1 OREGON-VMs-sddc
and the command I am typing is:
PS C:\Windows\system32> New-XVCMRequest opType clone -SrcSite OREGON -DstSite CALIF
-SrcDatacenter SDDC-Datacenter -DstDatacenter SDDC-Datacenter -DstCluster $null -DstDatastore WorkloadDatastore -DstHost 10.111.0.68 -srcVMs @("mikesUBUNTU")
-NetworkMapping @{"OREGON-VMs-sddc";"CALIF-sddc-VMs"}
and I get:
At line:1 char:202
+ ... -srcVMs @("mikesUBUNTU") -NetworkMapping @{"OREGON-VMs-sddc";"CALIF- ...
+ ~
Missing '=' operator after key in hash literal.
At line:1 char:202
+ ... -srcVMs @("mikesUBUNTU") -NetworkMapping @{"OREGON-VMs-sddc";"CALIF- ...
+ ~
The hash literal was incomplete.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEqualsInHashLiteral
Can you share an example of how the NetworkMapping should look given my simple Source/Destination combo...
*Clearly* this -NetworkMapping @{"OREGON-VMs-sddc";"CALIF-sddc-VMs"}
is not the right format for the HashTable....
Again THANK YOU!!! the UI works great - my next step is to script this migration so I can evacuate an entire SDDD.
#toTheCloud
~mikes
Mike Somerville says
Hi William, et. al. I figured out the Syntax for Network mapping. simple "orig"="dest". Cool.
However, with the following command, I now receive the error below....
New-XVCMRequest -opType Clone -SrcSite OREGON -DstSite CALIF -SrcDatacenter SDDC-Datacenter -DstDatacenter SDDC-Datacenter -DstCluster $null -DstDatastore WorkloadDatastore -DstHost 10.111.0.68 -srcVMs @(“mikesUBUNTU”) -NetworkMapping @{“OREGON-VMs-sddc”=”CALIF-sddc-VMs”}
Initiating migration request ...
Invoke-WebRequest : The remote server returned an error: (500) Internal Server Error.
At D:\Users\mikes\JUNK\XVM.psm1:208 char:16
+ ... $results = Invoke-WebRequest -Uri $Uri -Method POST -Body $body -Con ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Failed to initiate migration request
anyone have any ideas?/thoughts?
William Lam says
Mike,
Here's an example of the correct syntax for NetworkMapping property.
-NetworkMapping @{"DVPG-VM Network 1"="DVPG-Internal Network";"DVPG-VM Network 2"="DVPG-External Network"}
As you'd expect with PowerCLI, if you're not sure about the syntax of a given cmdlet or function, you can always do
Get-Help [function] -Detailed
and you'll see an example which I've included as part of the built-in documentation 🙂I also noticed that you're passing in $NULL for the Destination Cluster?
mikes says
Thanks. The example was confusing (for me)... The help provided the same example. After trial and error I discovered the proper syntax ...{"SourceNetworkName" = "DestinationNetworkName"}
Mike Somerville says
ah, the -DstCluster $null was used as in the comments of the XVM.psm1 it stated : "The name of the destination vSphere Cluster, set to null if DstHost is defined"... so I did that.
Niet: if i populate both, I still get an error. I am baffled as to why it works in the UI and not the CLI - i note that the parameters in the UI are different so perhaps that's the reason. *e.g. :Target Pool" in the UI...
Also, I not that if I don't choose "Advanced Options" in the UI, it gives an error....
But, hey, troubleshooting is 1/2 the fun 😉
Thanks!!
~mikes
Mike Somerville says
AH HA!!! Got it. _note_ I am migrating from one SDDC to another (both VMC on AWS). So, as of 5/6/2019, vCenter 6.8.2.400 and thus NSX-T to NSX-T.
I couldn't for the life of me figure out how the UI was working perfectly but not the PowerCLI Functions in XVM.psm1
1) the XVM.PSM1 needed to have the following lines added:
for the section param(
...
[Parameter(Mandatory=$true)][String]$DstPool,
[Parameter(Mandatory=$true)][String]$DstFolder
...
for the section $body @{
....
"targetPool"=$DstPool;
"targetFolder"=$DstFolder;
...}
Then
PS c:\Windows\System32\> Import-Module newXVM.psm1 # or whatever you want to name it.
It seemed the order of the Parameters was important SO I made sure the param and body and order I typed then in New-XVCMRequest matched.
I realized this by looking the output from the java -jar xvm-2.6.jar output. when a migration was started and successful from the UI
the order was:
operationType, sourceSite, targetSite, sourceDatacenter, vmList, targetDatacenter, targetCluster, targetHost, targetDatastore, networkMap, targetPool, targetFolder
So, the command that finally worked for me was:
PS c:\> New-XVCMRequest -opType Clone -SrcSite OREGON -DstSite CALIF -SrcDatacenter SDDC-Datacenter -srcVMs @(“DUDE-ubuntu”) -DstDatacenter SDDC-Datacenter -DstCluster "Cluster-1" -DstHost $null -DstDatastore WorkloadDatastore -NetworkMapping @{“OREGON-VMs-sddc”=”CALIF-sddc-VMs”} -DstPool Compute-ResourcePool -DstFolder Workloads
*** THANKS to Kenneth van Ditmarsch for the VERY helpful tidbit ".. I only now noticed that it’s generating the JSON so I should be fine by editting the module myself."
YES YES YES!!!! Indeed that did the trick.
If anyone wants the updated version, I'm happy to share but the lines above are probably pretty self explanatory.
Not sure how much need there is for SDDC/VMC on AWS : NSX-T to NSX-T... yet... but if you can't get the Preview for R118 for the HCX that promises to do that, this WORKS VERY ELEGANTLY!!!!
Thank so much, William!!
#toTheCloud
~mikes
William Lam says
Mike,
Appreciate your patience and thank you for working through the issue. It looks like I did indeed forget to update my PowerCLI Module to include the new functionality that we had introduced a few releases back which allows users to specify Resource Pool/VM Folder which is required for VMC Migrations. I've just modified the module with the changes you mentioned including an additional example for those interested.
Mike Somerville says
Greetings.
I have a need to Relocate all the VMs in a specific folder.
This command/variable seems to give me the proper value I need to fill the -srcVMs @(******) with a list of servers
PS C:\> $CALIFservers = (Get-VM -Location (Get-Folder -Name Workloads) | select Name -Expand Name ) - join ‘“,”’
PS C:\> $CALIFservers = '"' + $CALIFservers + '"'
*output*
PS C:\> $CALIFservers
"3-WIN2012","3-ubuntu","1-win2012","2-UBUNTU","4-win2012","2-WIN2012","1-ubuntu"
I get an error when i run:
PS C:\> New-XVCMRequest -opType Clone -SrcSite OREGON -DstSite CALIF -SrcDatacenter SDDC-Datacenter -srcVMs @($CALIFservers) -DstDatacenter SDDC-Datacenter -DstCluster "Cluster-1" -DstHost $null -DstDatastore WorkloadDatastore -NetworkMapping @{“OREGON-VMs-sddc”=”CALIF-sddc-VMs”} -DstPool Compute-ResourcePool -DstFolder Workloads
PS C:\> $CALIFservers
"3-WIN2012","3-ubuntu","1-win2012","2-UBUNTU","4-win2012","2-WIN2012","1-ubuntu"
PS C:\> New-XVCMRequest -opType Clone -SrcSite OREGON -DstSite CALIF -SrcDatacenter SDDC-Datacenter -srcVMs @($CALIFservers) -DstDatacenter SDDC-Datacenter -DstCluster "Cluster-1" -DstHost $null -DstDatastore WorkloadDatastore -NetworkMapping @{“OREGON-VMs-sddc”=”CALIF-sddc-VMs”} -DstPool Compute-ResourcePool -DstFolder Workloads
Initiating migration request ...
Invoke-WebRequest : The remote server returned an error: (500) Internal Server Error.
At D:\Users\mikes\JUNK\newXVM.psm1:218 char:16
+ ... $results = Invoke-WebRequest -Uri $Uri -Method POST -Body $body -Con ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Failed to initiate migration request
----------
the Java out is:
08:25:12 INFO Submitting migration job 6092aed7-9250-422d-aef5-ef79d1edbfb8 with vm list ["3-WIN2012","3-ubuntu","1-win2012","2-UBUNTU","4-win2012","2-WIN2012","1-ubuntu"]
08:25:12 DEBUG Migration request 6092aed7-9250-422d-aef5-ef79d1edbfb8 json spec {"operationType":"Clone","sourceSite":"OREGON","targetSite":"CALIF","sourceDatacenter":"SDDC-Datacenter","vmList":["\"3-WIN2012\",\"3-ubuntu\",\"1-win2012\",\"2-UBUNTU\",\"4-win2012\",\"2-WIN2012\",\"1-ubuntu\""],"targetDatacenter":"SDDC-Datacenter","targetCluster":"Cluster-1","targetHost":null,"targetDatastore":"WorkloadDatastore","networkMap":{"OREGON-VMs-sddc":"CALIF-sddc-VMs"},"targetPool":"Compute-ResourcePool","targetFolder":"Workloads"}
08:25:12 ERROR Requested vm(s) not found on source site
com.vmware.xvm.XvmException: null
You can see in the above what I *believe* is a correct Migration job request ?? (right?) because it looks *ALMOST* the same when I type each server name in manually... or copy/past the text:
"4-win2012","2-WIN2012","3-WIN2012","1-ubuntu","2-UBUNTU","1-win2012"
and run:
PS C:\> n New-XVCMRequest -opType Clone -SrcSite OREGON -DstSite CALIF -SrcDatacenter SDDC-Datacenter -srcVMs @("4-win2012","2-WIN2012","3-WIN2012","1-ubuntu","2-UBUNTU","1-win2012")
-DstDatacenter SDDC-Datacenter -DstCluster "Cluster-1" -DstHost $null -DstDatastore WorkloadDatastore
-NetworkMapping @{“OREGON-VMs-sddc”=”CALIF-sddc-VMs”} -DstPool Compute-ResourcePool
-DstFolder Workloads
(Java out ***all VMs in Migration Request Cloned to CALIF ****SUCCESSFULLY*** AWeSome! 🙂
07:42:06 INFO Submitting migration job 2976b684-86ee-425e-b44d-ec4f8cec31d8 with vm list [4-win2012, 2-WIN2012, 3-WIN2012, 1-ubuntu, 2-UBUNTU, 1-win2012]
07:42:16 DEBUG Migration request 2976b684-86ee-425e-b44d-ec4f8cec31d8 json spec {"operationType":"Clone","sourceSite":"OREGON","targetSite":"CALIF","sourceDatacenter":"SDDC-Datacenter","vmList":["4-win2012","2-WIN2012","3-WIN2012","1-ubuntu","2-UBUNTU","1-win2012"],"targetDatacenter":"SDDC-Datacenter","targetCluster":"Cluster-1","targetHost":null,"targetDatastore":"WorkloadDatastore","networkMap":{"OREGON-VMs-sddc":"CALIF-sddc-VMs"},"targetPool":"Compute-ResourcePool","targetFolder":"Workloads"}
07:42:16 DEBUG Found vm 2-WIN2012 with moid:vm-132
07:42:16 DEBUG Found vm 4-win2012 with moid:vm-133
07:42:16 DEBUG Found vm 2-UBUNTU with moid:vm-129
07:42:16 DEBUG Found vm 1-win2012 with moid:vm-128
07:42:16 DEBUG Found vm 3-WIN2012 with moid:vm-136
07:42:16 DEBUG Found vm 1-ubuntu with moid:vm-130
**i'm guessing this is my PowerCLI ignorance in trying to form the String $CALIFservers??? they way I am???
Any thoughts from the group? on how to name the srcVMs list/string a variable?
Thanks!
#toTheCloud
~mikes
Mike Somerville says
..sigh.... why do I always making things so complicated:
PS c:\> $servers = Get-VM -Location (Get-Folder -Name Workloads) | Select-Object Name -Expand Name
PS c:\> New-XVCMRequest -opType Relocate -SrcSite OREGON -DstSite CALIF -SrcDatacenter SDDC-Datacenter -srcVMs @($servers) -DstDatacenter SDDC-Datacenter -DstCluster "Cluster-1" -DstHost $null -DstDatastore WorkloadDatastore -NetworkMapping @{“OREGON-VMs-sddc”=”CALIF-sddc-VMs”} -DstPool Compute-ResourcePool -DstFolder Workloads
** I didn't need any special formatting of the VM list, just needed make sure it was servers only, no header...
this Evacuates the whole Workloads folder. If you do this every 29 days, the Single Host SDDC makes a great DEV solution with quite a LOT of capacity (all things relative, i know...)
#wildSuccess
DJ says
This whole string was super helpful for me. Thanks!
DJ says
Is there a diagram anywhere that shows how this operation flows? I found a good one for vMotion in general, but haven't seen anything for xvMotion. We have a fairly complex firewall setup, and it would be helpful to walk the networking folks through how this whole thing works.
Example: 1). vMotion request sent to source vCenter Server from xvMotion utility. 2). Source vCenter sends request to destination ESXi host. 3). Etc. 4). Etc.
Thanks!
Sofiane says
Hi everyone
Does xVC support or no thick disks ? we try to move a powered off VM with a thick disk but the operation fail , on the log insight i found an error like this
[NfcWorker] Error encountered while processing copy spec for file [ds:........ .vmdk --> DS:......vmdk] failed: The operation experienced a network error -- Failed to send data message
we are running vcenter/ESXI 60.0.U2 on both sites
Regards
Sofiane
vinoth says
Hi
I am getting the below mentioned error,
A general system error occurred: SSL Exception: Verification parameters: PeerThumbprint: 28:53:1C:A0:45:B9:B3:3C:36:8A:68:BF:B8:0E:0E:40:19:A0:FE:42 ExpectedThumbprint: 26:E8:15:DC:40:BC:2E:53:ED:7C:6E:0D:5A:48:E1:D5:C0:44:2B:E5 ExpectedPeerName: cnpdcvspd703.pldc.kp.org The remote host certificate has these problems: * A certificate in the host's chain is based on an untrusted root. * self signed certificate in certificate chain
I am trying to migrate a VM and checked the option skip certificate verification. Still I am unable to migrate the VM .
Jan says
Hi William,
first of all thanks for this this tool, if we can get it to work it would be even greater. 😉
Is there any other possibility to address the network mapping for a vm?
We would like to migrate to a vCenter where Cisco ACI provides two or more dvSwitches with the same network on it. I guess therefore we get the warning:
18:09:23 WARN Duplicate networks found with name *network name here* in target site
18:09:23 INFO Initiating Relocate task for vm:*vm name*
18:09:23 DEBUG Begin task id a16ba720-25bd-4bec-a481-3dcc95fea6d1 with request id:6042847a-9462-431b-a33c-3bd185a2fe9a
18:09:23 DEBUG Object moids vm:vm-259 target:domain-c345
18:09:23 DEBUG Network moids src:com.vmware.vim25.ManagedObjectReference@1dfa3e5c dst:dvportgroup-3957
18:09:23 DEBUG Datastore moid:datastore-3104
18:09:23 ERROR Exception in Relocate task for vm : *vm name*
java.lang.RuntimeException: No suitable host with desired configuration found for vm: vm-259
[...]
The destination cluster is set to partially automated and only bound to one of those dvSwitches.
Greetings,
Jan
Saad says
Hello,
Does it migrate the storage too?
Yan says
Hello William is PS Module XVM.psm1 compatible with XVMotion 3.0 ? Looks like your scripts point to http://localhost:8080 and version 3.0 has moved to https://localhost:8443. I'm getting error "Could not establish trust relationship for the SSL/TLS secure channel" because of the self-signed cert on Cross vCenter Workload Migration Utility.
William Lam says
Yan,
The XVM.psm1 is just an example PS module. I've not had time to look into it for 3.0. Yes, the port has changed you can simply update the module or better yet, make it dynamic rather than static. For handling of the self-sign, if you're using PS Core, you can specify -SkipCertificateCheck which will workaround the issue
DJ says
Putting this here in case anyone else runs into the issue. In addition to the port change and -SkipCertificateCheck, if you use DVS, you need to include "(DistributedVirtualPortgroup)" after the network name in the network match. Beat my head against for a while on that one.
Javier says
Man this tool is a great tool. I did run into a small issue. I was migrating from one VCenter to another and the source shows %100 complete but the recieving VCenter is stuck at 39% and I notice the VM is still on the source. XVMotion showed %100 but does not clear it like it is not completely done.
AHMED says
my migration stuck at 100% and then gives error operation timed out
MK says
Hi Ahmed,
I am also facing this issue.
May I know if your issue is resolved? If yes please let me know how to resolve please.
I am doing cross vcenter migration from one 6.7 to another 6.7 vcenter which are not in ELM. Both are in same domain.
Frans says
How can I rename a VM when cloning to the same datastore?
AKG says
Hello Ghetto
I have two Virtual center on 6.7U3, site-A having vSphere 6.7 and Site-B having 6.5 version.
i have configured the vMotion on the same network 510 vlan on both site of vSphere, and vCenter is also on the same network vlan 509, vSphere (ESXi) is on different network only and both site of ESXi cant communicate on management vlan.
I can confirm required ports are opened for all in firewall of ESXi, vMotion is configured on both site with Provisioning, NFC, vMotion, Provisioning.
I am executing the cross-vMotin 3.1 but receiving the error "A general system error occurred: No such host is known" nothing is moving over 0%.
04:17:49 DEBUG Found vm test with moid:vm-55
04:17:49 INFO Initiating relocate task for vm:test
04:17:49 DEBUG Begin task id 290d411e-dbfa-4307-99c5-f6438c6307a6 with request id:d0d4ef3e-5fd9-4b9b-9127-9e574bb59143
04:17:49 DEBUG Object moids vm:vm-55 target:host-5812
04:17:49 DEBUG Network moids src:com.vmware.vim25.ManagedObjectReference@11af13 dst:dvportgroup-44463
04:17:49 DEBUG Network moids src:com.vmware.vim25.ManagedObjectReference@19f65d8 dst:dvportgroup-44463
04:17:49 DEBUG Datastore moid:datastore-265692
04:17:49 DEBUG Submitted task id 290d411e-dbfa-4307-99c5-f6438c6307a6 with request id:d0d4ef3e-5fd9-4b9b-9127-9e574bb591
43
04:17:49 INFO Initiated relocate task for vm:test
04:17:49 INFO Initiating monitoring task for vm:test
04:17:49 DEBUG Initiated migration task task-249 for vm
04:17:49 INFO Submitted migration operation: d0d4ef3e-5fd9-4b9b-9127-9e574bb59143
04:17:49 INFO Task status vm:test duration:0s state:running progress:0%
04:17:54 INFO Task status vm:test duration:0s state:error progress:0%
Rahul says
Hi
I have executed the jar and was able to move one machine using this utility. BUt after few days when i am trying it is saying "unable to discoonect the vcenter"
CerealCH says
I have change code to work with last version 3.1 of Cross Vcenter Workload Migration Utility.
Changes :
Set-XVCMConfiguration
This function configure the global variable `CrossvCenterURL`, and calls the `Disable-SSLCertificateValidation` function to ignore SSL certificate validation.
Disable-SSLCertificateValidation
Add new function to ignore SSL certificate validation with Powershell 5.1
New-XVCMRequest
diskFormatConversion
[ValidateSet('Same Format as Source', 'Thick Provision Lazy Zeroed', 'Thick Provision Eager Zeroed', 'Thin Provision')]
VMNamePattern
Used to define VM paterns. Set to null if you dont use
Some other minor changes
How to use :
Import-Module XVM.psm1
# Cross vCenter URL
$CrossvCenterURL = "https://crossvcenterworkloadutility:8443"
# Configure XVCM
Set-XVCMConfiguration -CrossvCenterURL $CrossvCenterURL -DisableSSLCertificateValidation $true
# Get sites informations (not required to initiate migration just for identify Cross Vcenter Workload Migration Utility informations)
Get-XVCMSite
# Get Cross vCenter connectivity status
Get-XVCMStatus
# Initiate migration
$networkMap = @{
"SRTZ-DVS9 (DistributedVirtualPortgroup)"="DPGDVS-SURTE-123 (DistributedVirtualPortgroup)"
}
New-XVCMRequest -opType "relocate" `
-SrcSite "sitenameOfSourceSite" `
-DstSite sitenameOfDestinationSite `
-SrcDatacenter "VMDatacenter1" `
-DstDatacenter "VMDatacenter3" `
-DstCluster "Dest-CLUSTER1" `
-DstDatastore "TARGETDatastore12" `
-NetworkMapping $networkMap `
-srcVMs @("PhotonOS-01","PhotonOS-02","PhotonOS-03","PhotonOS-04") `
-DstHost $null `
-DstPool "TheSwimmingPool" `
-DstFolder "TheVMFolder" `
-diskFormatConversion 'Same Format as Source' `
-VMNamePattern $null `
---------------------------------------------------------------------------------------
Function Disable-SSLCertificateValidation
{
# Ignore SSL Certificate validsation and accept all
$Provider = New-Object Microsoft.CSharp.CSharpCodeProvider
$Compiler = $Provider.CreateCompiler()
$Params = New-Object System.CodeDom.Compiler.CompilerParameters
$Params.GenerateExecutable = $false
$Params.GenerateInMemory = $true
$Params.IncludeDebugInformation = $false
$Params.ReferencedAssemblies.Add("System.DLL") > $null
$TASource = @'
namespace Local.ToolkitExtensions.Net.CertificatePolicy
{
public class TrustAll : System.Net.ICertificatePolicy
{
public bool CheckValidationResult(System.Net.ServicePoint sp,System.Security.Cryptography.X509Certificates.X509Certificate cert, System.Net.WebRequest req, int problem)
{
return true;
}
}
}
'@
$TAResults = $Provider.CompileAssemblyFromSource($Params, $TASource)
$TAAssembly = $TAResults.CompiledAssembly
## We create an instance of TrustAll and attach it to the ServicePointManager
$TrustAll = $TAAssembly.CreateInstance("Local.ToolkitExtensions.Net.CertificatePolicy.TrustAll")
[System.Net.ServicePointManager]::CertificatePolicy = $TrustAll
}
# Set global variable
$global:CrossvCenterURL = $null;
Function Set-XVCMConfiguration
{
[OutputType([NullString])]
Param
(
[Parameter(Mandatory = $true)]
[String]$CrossvCenterURL,
[Parameter(Mandatory = $true)]
[boolean]$DisableSSLCertificateValidation
)
Write-Information "INFO : Cross vcenter URL set to : $CrossvCenterURL"
Set-Variable -Name "CrossvCenterURL" -Value $CrossvCenterURL -scope global -Option AllScope
# Ignore certificate validation
If ($DisableSSLCertificateValidation -eq $true)
{
Write-Information "INFO : Ignore SSL Certificate Validation"
Disable-SSLCertificateValidation
}
}
Function Get-XVCMStatus
{
$Uri = "$CrossvCenterURL/api/status" #Updated for 2.0, Old: "$CrossvCenterURL/api/ping"
Try
{
$results = Invoke-WebRequest -Uri $Uri -Method GET -TimeoutSec 60 -ErrorAction SilentlyContinue -ErrorVariable oErr
}
Catch
{
$results = $null
}
If ($results.StatusCode -eq 200)
{
$Message = ("Server status: " + $results.Content.ToString())
Write-Information ("INFO : $Message")
Return $Message
}
Else
{
$Message = ("Cross vCenter Workload Migration Utility is probably not running : " + $oErr.Message.Tostring())
Write-Warning $Message
Return $Message
}
}
Function Get-XVCMSite
{
$Uri = "$CrossvCenterURL/api/sites"
Try
{
$results = Invoke-WebRequest -Uri $Uri -Method GET -ErrorVariable oErr
}
Catch
{
$results = $null
}
If ($results.StatusCode -eq 200)
{
$json = $results.Content.ToString()
$json = $json.Replace("[", "'[").Replace("]", "]'").ToString().Trim()
$Message = ConvertFrom-Json $json | Select-Object sitename, hostname, username
return $results.Content.ToString()
}
Else { Write-Warning "Failed to retrieve VC Site Registration details" }
}
Function New-XVCMSite
{
Param (
[Parameter(Mandatory = $true)]
[String]$SiteName,
[Parameter(Mandatory = $true)]
[String]$VCHostname,
[Parameter(Mandatory = $true)]
[String]$VCUsername,
[Parameter(Mandatory = $true)]
[String]$VCPassword,
[Parameter(Mandatory = $false)]
[Switch]$Insecure
)
$Uri = "$CrossvCenterURL/api/sites"
$insecureFlag = $false
If ($Insecure)
{
$insecureFlag = $true
}
$body = @{
"sitename" = $SiteName;
"hostname" = $VCHostname;
"username" = $VCUsername;
"password" = $VCPassword;
"insecure" = $insecureFlag;
}
$body = $body | ConvertTo-Json
Write-Host -ForegroundColor Cyan "Registering vCenter Server $VCHostname as $SiteName ..."
$results = Invoke-WebRequest -Uri $Uri -Method POST -Body $body -ContentType "application/json"
If ($results.StatusCode -eq 200)
{
Write-Host -ForegroundColor Green "Successfully registered $SiteName"
}
Else { Write-Host -ForegroundColor Red "Failed to register $SiteName" }
}
Function Remove-XVCMSite
{
Param (
[Parameter(Mandatory = $true)]
[String]$SiteName
)
$Uri = "$CrossvCenterURL/api/sites/$SiteName"
Write-Host -ForegroundColor Cyan "Deleting vCenter Server Site Registerion $SiteName ..."
$results = Invoke-WebRequest -Uri $Uri -Method DELETE
If ($results.StatusCode -eq 200)
{
Write-Host -ForegroundColor Green "Successfully deleted $SiteName"
}
Else { Write-Host -ForegroundColor Red "Failed to deleted $SiteName" }
}
Function New-XVCMRequest
{
Param
(
[Parameter(Mandatory = $true)]
[String]$opType,
[Parameter(Mandatory = $true)]
[String]$SrcSite,
[Parameter(Mandatory = $true)]
[String]$DstSite,
[Parameter(Mandatory = $true)]
[String]$SrcDatacenter,
[Parameter(Mandatory = $true)]
[String]$DstDatacenter,
[Parameter(Mandatory = $true)]
[AllowNull()]
$DstCluster,
[Parameter(Mandatory = $true)]
[String]$DstPool,
[Parameter(Mandatory = $true)]
[String]$DstFolder,
[Parameter(Mandatory = $true)]
[String]$DstDatastore,
[Parameter(Mandatory = $true)]
[ValidateSet('Same Format as Source', 'Thick Provision Lazy Zeroed', 'Thick Provision Eager Zeroed', 'Thin Provision')]
[string[]]$diskFormatConversion,
[Parameter(Mandatory = $true)]
[AllowNull()]
$DstHost,
[Parameter(Mandatory = $true)]
[String[]]$srcVMs,
[Parameter(Mandatory = $false)]
[AllowNull()]
$VMNamePattern = $null,
[Parameter(Mandatory = $true)]
[Hashtable]$NetworkMapping
)
$Uri = "$CrossvCenterURL/api/tasks"
# Set disk format
Switch ($diskFormatConversion)
{
'Thick Provision Lazy Zeroed' {
$diskFormatC = "Thick Provision Lazy Zeroed"
}
'Thick Provision Eager Zeroed' {
$diskFormatC = "Thick Provision Eager Zeroed"
}
'Thin Provision' {
$diskFormatC = "Thin Provision"
}
default {
$diskFormatC = "Same Format as Source"
}
}
$body = [ORDERED]@{
"operationType" = $opType;
"sourceSite" = $SrcSite;
"targetSite" = $DstSite;
"sourceDatacenter" = $SrcDatacenter;
"vmList" = $srcVMs;
"vmNamePattern" = $VMNamePattern;
"targetDatacenter" = $dstDatacenter;
"targetCluster" = $DstCluster;
"targetHost" = $DstHost;
"targetDatastore" = $DstDatastore;
"networkMap" = $NetworkMapping;
"targetPool" = $DstPool;
"targetFolder" = $DstFolder;
"diskFormatConversion" = $diskFormatC
}
$body = $body | ConvertTo-Json
Write-Debug "JSON Value : $body"
Write-Information "INFO : Initiating migration request ..."
Try
{
$results = Invoke-WebRequest -Uri $Uri -Method POST -Body $body -ContentType "application/json" -ErrorVariable oErr
}
Catch
{
$results = $null
}
If ($results.StatusCode -eq 200)
{
$Message = ("Successfully issued migration with requestId:" + $results.Content.ToString())
Write-Information ("INFO : $Message")
Return "Success"
}
Else
{
$Message = ("Failed to initiate migration request" + $oErr.Message.Tostring())
Write-Warning $Message
Return $Message
}
}
Function Get-XVCMTask
{
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: http://www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function retrieves either all migration tasks and/or a specific migration task
.PARAMETER Id
The task ID returned from initiating a migration
.EXAMPLE
Get-XVCMTask -Id
#>
Param (
[Parameter(Mandatory = $false)]
[String]$Id
)
$Uri = "$CrossvCenterURL/api/tasks"
If ($Id)
{
$body = @{ "requestId" = $Id }
$results = Invoke-WebRequest -Uri $Uri -Method GET -Body $body -ContentType "application/json"
}
Else
{
$results = Invoke-WebRequest -Uri $Uri -Method GET
}
If ($results.StatusCode -eq 200)
{
$results.Content | ConvertFrom-Json
}
Else { Write-Host -ForegroundColor Red "Failed to retrieve tasks" }
}
Function Get-VMNetwork
{
Param (
[Parameter(Mandatory = $false)]
[String[]]$srcVMs
)
If (-not $global:DefaultVIServers) { Write-Host -ForegroundColor red "No vCenter Server Connection found, please connect to your source vCenter Server using Connect-VIServer"; Break }
$results = @()
If ($srcVMs)
{
ForEach ($srcVM In $srcVMs)
{
$vm = Get-VM -Name $srcVM
$networkDetails = $vm | Get-NetworkAdapter
$tmp = [pscustomobject] @{
Name = $srcVM;
Adapter = $networkDetails.name;
Network = $networkDetails.NetworkName;
}
$results += $tmp
}
}
Else
{
ForEach ($vm In Get-VM)
{
$networkDetails = $vm | Get-NetworkAdapter
$tmp = [pscustomobject] @{
Name = $vm.Name;
Adapter = $networkDetails.name;
Network = $networkDetails.NetworkName;
}
$results += $tmp
}
}
$results
}
CerealCH says
You can follow last changes here :
https://github.com/CerealCH/Public/tree/main/CrossvCentervmotion