Stressed About Managing Multiple Clouds? We've Got Your Back!
Thanks for the response. I figured it out. I used the v2 API to “detach” (delete) the disks from the VM. This is the Ansible syntax using the URI module to remove disks 1 and 2 (disk 0 is the boot disk so I leave it alone): - name: Detach disks scsi:1 and scsi:2 uri: url: "{{ base_urlv2 }}/vms/{{ vm_uuid }}/disks/detach" validate_certs: no force_basic_auth: yes method: POST status_code: 200,201 user: "{{ username }}" password: "{{ password }}" return_content: no body_format: json body: vm_disks: - disk_address: device_bus: "SCSI" device_index: 2 - disk_address: device_bus: "SCSI" device_index: 1 register: retval ignore_errors: yes … and then I clone disk images from the image store, mounting them as SCSI 1 and SCSI 2. This takes several steps: 1. Determine the UUID of the VM you want to mount the images on. 2. Determine the VMDisk ID for each image you want to attach to the VM. 3. Clone/mount the disk images. The Ansible YAML for this is fairly long so I won’t post it here unless so
Does the host name in /etc/ansible/hosts exactly match the VM name in Nutanix? Like case?
I think Ansible is not picking up the embedded inventory_hostname value. Change your filter as follows and give it a try: filter: "vm_name==”{{ inventory_hostname }}”" You might also try the following if that doesn’t work: filter: vm_name==”{{ inventory_hostname }}” Also be sure to include the following in the body because they are required by the API: offset: 0 length: 1 sort_atributes: “”
I have done this. The playbook below does it: :) It determines the UUID of a VM (myvm) and powers it on. It also run a couple scripts to start an Oracle database server on the VM which is a Linux host. f the VM is a Windows server you should use win_command instead of “command”. win_command is documented on the Ansible site here → https://docs.ansible.com/ansible/latest/modules/list_of_windows_modules.html ---- name: Determine the UUID for VM myvm and power it on # nutanixhostname is the name of the nutanix cluster as saved in /etc/ansible/hosts hosts: nutanixhostname gather_facts: false connection: local vars: # I use the v3 API to get the UUID and the v2 API to power on the VM base_urlv2: "https://ntnxb.irea.us:9440/PrismGateway/services/rest/v2.0" base_urlv3: "https://ntnxb.irea.us:9440/api/nutanix/v3"# Hard-coded Nutanix username and pasword username: adminuser password: adminoassword# ALternatively, best practice is to retrieve the stored username and
The only reference I've found indicates that it is "The attribute to perform sort on". I tested this using sort_atribute "vm_name" and I got a sorted list by VM name. HOWEVER when I tried sort_attributes "num_sockets", or "memory_size_mib", or "memory_size_bytes" the list returned was not sorted. I spoke with Nutanix' new API DIrector at .NEXT and he promised better documentation soon. I sure hope so.
That worked. Thanks!
What do you mean by "... the same for snapshots"?
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.