I know we can do this in PowerCli, but would like to know if there is any other method to register an VM in vcenter like using vcenter api or ansible ?
For migrating a machine vCenter A to vCenter B, my vRO does not have access to the vcenterB, but I need to register the machine in vCenter B. It would be easy if I can use rest api or ansible module to do it or is there a way I can use VMWare converter with vRO ?
Here recently a module was added to Ansible that can do just that. The module: https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/vmware/vmware_guest_register_operation.py
Some example code:
- name: Register VM to inventory
vmware_guest_register_operation:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
datacenter: "{{ datacenter }}"
folder: "/vm"
esxi_hostname: "{{ esxi_hostname }}"
name: "{{ vm_name }}"
template: no
path: "[datastore1] vm/vm.vmx"
state: present