VMware Cloud Community
pezh0re
Enthusiast
Enthusiast
Jump to solution

CloudClient 4.4.0 Bulk Change Reservations

We recently split out our vCenter clusters and need to migrate all the Windows VMs from the shared cluster reservation to a new reservation. As we have ~200 VMs to move, I'd prefer to do this in some sort of batch job. I'd prefer PowerShell, but from what I understand CloudClient should be able to do the job.

For the sake of completeness, we're running the following:

  • vRA 7.2
  • CloudClient 4.4.0
  • vSphere 6.5

The old reservation is "Windows - 01", we need to move the Windows VMs to "Windows - 02" (super descriptive names, I know).

I was able to successfully log in interactively to vRA and the IaaS service, then change the reservation for a single vm (and back again):


CloudClient>vra machines change reservation --ids restest01 --reservationName "Windows - 02"

Successfully sent request to register machine restest01

CloudClient>vra machines change reservation --ids restest01 --reservationName "Windows - 01"

Successfully sent request to register machine restest01

I'd like to source the list of machines somehow (manually grab, use PowerShell, cloud client.. something), then provide that list of machines that need to move to cloud client. The first step will be try the change above from command line, but I'm getting auth errors:

C:\temp\cloudclient\4.4.0\VMware_vRealize_CloudClient-4.4.0-5511232> .\bin\cloudclient.bat vra machines change reservation --ids restest --reservationName "Windows - 02"

Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true

JRE Version: 1.8.0_121

Dec 07, 2017 3:45:45 PM org.springframework.shell.core.SimpleParser parse

WARNING: com.vmware.cloudclient.exception.CloudClientException: Failed to convert 'restest01' to type CloudMachineView[] for option 'ids'

Dec 07, 2017 3:45:45 PM org.springframework.shell.core.SimpleParser parse

WARNING: Authentication Error : Login required.

I've tried generating a CloudClient.properties file, and an encoded credential, but it doesn't seem to want to work.

Thoughts?

0 Kudos
1 Solution

Accepted Solutions
pezh0re
Enthusiast
Enthusiast
Jump to solution

After more testing, I think I have the solution (for anyone else who is looking to use PowerShell & CloudClient). I realized two things:

  1. I assumed running login keyfile --file filename.enc after logging into IaaS/vRA in the interactive session would save my login credentials and that the password prompt was to protect the username/password combo I had used previously in the vra login iaas and vra login userpass commands. This is incorrect. The login keyfile command encrypts the given password only.
  2. The CloudClient.properties file must edited after generation - it doesn't attempt to set values based on the currently logged in session.

With that knowledge in hand, I was able to create two keyfiles (one for my vRA password and one for the iaas password). I was able to update the CloudClient.properties file to match the following (with various sanitation):

CloudClient.properties · GitHub

I'm not sure if it is necessary to comment out the vra_password and vra_iaas_password options when using a keyfile, but commented out works for me.

The next problem I ran into was cloudclient not finding my given reservation:

.\bin\cloudclient.bat vra machines change reservation --ids "restest01" --reservationName "Windows - 02"
...
WARNING: Error: Unable to find a Reservation by the name or id 'Windows'

Escaping the spaces fixed that issue (e.g. "Windows\ -\ 02").

The last step was to leverage PowerVRA to retrieve all VMs with the old reservation, and pipe that (along with the new reservation to cloudclient.bat). The finished script can be found here: Set-vRAMachineReservations.ps1 · GitHub

View solution in original post

0 Kudos
4 Replies
pezh0re
Enthusiast
Enthusiast
Jump to solution

After more testing, I think I have the solution (for anyone else who is looking to use PowerShell & CloudClient). I realized two things:

  1. I assumed running login keyfile --file filename.enc after logging into IaaS/vRA in the interactive session would save my login credentials and that the password prompt was to protect the username/password combo I had used previously in the vra login iaas and vra login userpass commands. This is incorrect. The login keyfile command encrypts the given password only.
  2. The CloudClient.properties file must edited after generation - it doesn't attempt to set values based on the currently logged in session.

With that knowledge in hand, I was able to create two keyfiles (one for my vRA password and one for the iaas password). I was able to update the CloudClient.properties file to match the following (with various sanitation):

CloudClient.properties · GitHub

I'm not sure if it is necessary to comment out the vra_password and vra_iaas_password options when using a keyfile, but commented out works for me.

The next problem I ran into was cloudclient not finding my given reservation:

.\bin\cloudclient.bat vra machines change reservation --ids "restest01" --reservationName "Windows - 02"
...
WARNING: Error: Unable to find a Reservation by the name or id 'Windows'

Escaping the spaces fixed that issue (e.g. "Windows\ -\ 02").

The last step was to leverage PowerVRA to retrieve all VMs with the old reservation, and pipe that (along with the new reservation to cloudclient.bat). The finished script can be found here: Set-vRAMachineReservations.ps1 · GitHub

0 Kudos
DLally
Enthusiast
Enthusiast
Jump to solution

Is there some sort of voodoo magic to be able to do this?  I've tried ClouClient 4.3, 4.4 and 4.5 and when I run the change reservation, the command sits there forever and doesn't do anything.  

4.3 and 4.4 cycle through this while it sits and churns away..

"2018-11-28 16:42:46,734 thread="Spring Shell" com.vmware.cloudclient.vcac.service.iaas.ManagedMachineViewModelService.getManagedMachineViewModel:33 - null"

 

I have like 150 servers to change reservation so this would be very helpful to just script! 

2018-11-28 16:42:46,734 thread="Spring Shell" com.vmware.cloudclient.vcac.service.iaas.ManagedMachineViewModelService.getManagedMachineViewModel:33 - null
0 Kudos
DLally
Enthusiast
Enthusiast
Jump to solution

Ok so after letting it sit, and complete.  It took like 10 minutes to cycle through this log "2018-11-28 16:42:46,734 thread="Spring Shell" com.vmware.cloudclient.vcac.service.iaas.ManagedMachineViewModelService.getManagedMachineViewModel:33 - null" and then it finally complete.   

 

That seems a bit extreme to have to wait that long for the command to complete

0 Kudos
VinithMenon
VMware Employee
VMware Employee
Jump to solution

Hello - could you let me know how were you able to get over this error ?

"Failed to convert 'restest01' to type CloudMachineView[] for option 'ids'", trying with v 4.7 and it gives this error

4.3 Gave the below

pastedImage_2.png@

pastedImage_0.png

0 Kudos