Remove Stale VMs and VMIs
Before you can remove a stale virtual machine (VM) or virtual machine interface (VMI), you must first remove any back references associated to the VM or VMI.
A net-delete of the virtual machine 2a8120ec-bd18-49f4-aca0-acfc6e8fe74f returned the following messages that there are two VMIs that still have back-references to the stale VM. You must first delete the two VMIs, then the neutron net-delete <> command will complete without errors.
"DELETE/virtual-network/2a8120ec-bd18-49f4-aca0-acfc6e8fe74f HTTP/1.1" 409 203
ERROR [neutron.api.v2.resource] delete failed
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/neutron/api/v2/resource.py", line
84, in resource
result = method(request=request, **args)
File "/usr/lib/python2.7/dist-packages/neutron/api/v2/base.py", line
432, in delete
obj_deleter(request.context, id, **kwargs)
plugin.py", line 294, in delete_network
RefsExistError: Back-References from
bb700b579 still exist
Show Virtual Machines
Use the following command to show all virtual machines known to the Contrail API server. Replace the variable <config-node-IP> (example-node) with the IP address of the config-node in your setup:
In the example, 03443891-99cc-4784-89bb-9d1e045f8aa6 is a stale VM that you need to remove.
When you attempt to delete the stale VM, a message displays that children to the VM still exist:
root@example-node:~# curl -X DELETE -H "Content-Type: application/json; charset=UTF-8" http: //127.0.0.1:8082/virtual-machine/03443891-99cc-4784-89bb-9d1e045f8aa6
Children http: //127.0.0.1:8082/virtual-machine-interface/0c32a82a-7bd3-46c7-b262-6d85b9911a0d still exist
Open http://example-node:8082/virtual-machine/03443891-99cc-4784-89bb-9d1e045f8aa6, and you see a virtual-machine-interface (VMI) attached to it. You must remove this VMI first.
However, when you attempt to delete the VMI from the stale VM, you receive a message that there is still a back-reference:
root@example-node:~# curl -X DELETE -H "Content-Type: application/json; charset=UTF-8" http: //<example-IP>:8082/virtual-machine-interface/0c32a82a-7bd3-46c7-b262-6d85b9911a0d
Back-References from http: //<example-IP>:8082/instance-ip/6ffa29a1-023f-462b-b205-353da8e3a2a4 still exist
Because there is a back-reference from an instance-ip object still present, you must first delete the instance-ip object as follows:
root@example-node:~# curl -X DELETE -H "Content-Type: application/json; charset=UTF-8" http: //<example-IP>:8082/instance-ip/6ffa29a1-023f-462b-b205-353da8e3a2a4
After you delete the instance-ip object, you can delete the VMI and the VM.
NOTE: To prevent inconsistency, be sure that the VM is NOT present in the nova db before deleting the VM.
Show Virtual Machines Using Python API
The following example shows how to view virtual machines using a Python API. This example shows virtual machines and back-references. Once you identify back-references and existing children, you can delete them first, then delete the stale VM:
root@example-node:~# source /opt/contrail/api-venv/bin/activate
(api-venv)root@example-node:~# pythonPython 2.7.5 (default, Mar 10 2014, 03:55:35) [GCC 4.6.3] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> from vnc_api.vnc_api import VncApi>>> vh=VncApi()>>> vh.virtual_machine_interface_delete(id='0c32a82a-7bd3-46c7-b262-6d85b9911a0d')Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/contrail/api-venv/lib/python2.7/site-packages/vnc_api/gen/vnc_api_client_gen.py", line 3793, in virtual_machine_interface_delete content = self._request_server(rest.OP_DELETE, uri) File "/opt/contrail/api-venv/lib/python2.7/site-packages/vnc_api/vnc_api.py", line 342, in _request_server raise RefsExistError(content)cfgm_common.exceptions.RefsExistError: Back-References from http: // <example-IP>:8082/instance-ip/6ffa29a1-023f-462b-b205-353da8e3a2a4 still exist
Use help (vh) to show all delete methods supported.
Typical commands for deleting VMs and VMIs include:
- virtual_machine_delete() to delete a virtual machine
- instance_ip_delete() to delete an instance-ip