Overview
This article will provide you with how to update the new Server objects that are created when moving VMs to a new vCenter.
Procedure
Match by VM hostname
If you reuse hostnames use the method below to match by UUID. Run the below code in shell_plus to update the MOID of the previous Server object to match the new MOID.
ssh to your CloudBolt instance
Open shell_plus by running
/opt/cloudbolt/manage.py shell_plus
3. Use the below code to update the VMs by VM Hostname:
for new_server in Server.objects.filter(status="ACTIVE").filter(resource_handler=00): #replace 00 with the id of your Resource Handler if VmwareServerInfo.objects.get(server=new_server): new_si = VmwareServerInfo.objects.get(server=new_server) new_moid = new_si.moid hostname = new_server.hostname if Server.objects.filter(hostname=hostname, status="HISTORICAL"): old_server = Server.objects.filter(hostname=hostname, status="HISTORICAL") if VmwareServerInfo.objects.get(server=old_server): old_si = VmwareServerInfo.objects.get(server=old_server) old_si.moid = new_moid old_si.save() else: pass else: pass
Match by UUID
Run the below code in shell_plus to update the MOID of the previous Server object to match the new MOID.
ssh to your CloudBolt instance
Open shell_plus by running
/opt/cloudbolt/manage.py shell_plus
Use the below code to update the VMs by UUID:
for new_server in Server.objects.filter(status="ACTIVE").filter(resource_handler=00): #replace 00 with the id of your Resource Handler if VmwareServerInfo.objects.get(server=new_server): new_si = VmwareServerInfo.objects.get(server=new_server) new_moid = new_si.moid #resource_handler_svr_id is the UUID of the server new_uuid = new_server.resource_handler_svr_id if Server.objects.get(resource_handler_svr_id=new_uuid, status="HISTORICAL"): old_server = Server.objects.get(resource_handler_svr_id=new_uuid, status="HISTORICAL") if VmwareServerInfo.objects.get(server=old_server): old_si = VmwareServerInfo.objects.get(server=old_server) old_si.moid = new_moid old_si.save() else: pass else: pass
Sync Resource Handler
Once your VMs have been updated from shell_plus, go to your Resource Handler’s Servers tab and select Sync VMs from resource handler
.
Your VMs will now have their same data from the previous Server object.
0 Comments