Remove a node from the cloud

In this video we will remove a node form the cloud.

Link to the video: http://youtu.be/_SoS54uU7oU

From the MAAS server:

Export external JUJU:
export JUJU_HOME=~/.cloud-install/juju

Enter internal JUJU:
juju ssh landscape/0 sudo 'JUJU_HOME=/var/lib/landscape/juju-homes/`sudo ls -rt /var/lib/landscape/juju-homes/ | tail -1` sudo -u landscape -E bash'

Get the status of the node you want to remove:
juju status nova-compute/3

Remove the node:
juju remove-unit nova-compute/3
 
list compute nodes/hypervisors, watch the video on how to build these commands for your environment:
nova --os-username admin --os-tenant-name admin --os-auth-url http://10.1.1.115:5000/v2.0 --os-password MVjTpAkfMMJgqWe hypervisor-list

Now is a good time to start screen to move around in the nodes:
screen    starts screen
CTRL + C     creates a new screen
CTRL + P     moves between screens

From the internal juju prompt, got to the mysql LXC container:
juju ssh mysql/0

Login to mysql with root, get the root password from the JUJU gui mysql charm:
mysql -u root -p

Enter the NOVA database:
USE nova;

List the compute nodes table
SELECT id, created_at, updated_at, hypervisor_hostname FROM compute_nodes;

Back to the screen you have logged into the node we are removing, list the services:
nova --os-username admin --os-tenant-name admin --os-auth-url http://10.1.1.115:5000/v2.0 --os-password MVjTpAkfMMJgqWe service-list

Back to the mysql screen, remove the node from the table:
DELETE FROM compute_nodes WHERE hypervisor_hostname='node2dc7900.maas';

Now still in the NOVA database list the services table:
SELECT id, created_at, updated_at, host FROM services;

Delete node from the services table:
DELETE FROM services WHERE host='node2dc7900';

Back to the screen with the node we are removing, list the hypervisors again, node should be gone:
nova --os-username admin --os-tenant-name admin --os-auth-url http://10.1.1.115:5000/v2.0 --os-password MVjTpAkfMMJgqWe hypervisor-list

List the services again, node should be gone:
nova --os-username admin --os-tenant-name admin --os-auth-url http://10.1.1.115:5000/v2.0 --os-password MVjTpAkfMMJgqWe service-list

Now we work on the neutron piece, list the neutron agents
neutron --os-username admin --os-tenant-name admin --os-auth-url http://10.1.1.115:5000/v2.0 --os-password MVjTpAkfMMJgqWe agent-list

Go back to the msql screen and open the neutron database:
use neutron;

List the agents table:
SELECT id, created_at,  host FROM agents;

Remove the node from the agents table:
DELETE FROM agents WHERE host='node2dc7900';


Now exit from mysql and check the status of the machine in juju:

juju status nova-compute/3

It should now be gone, if it is not and it is stuck in a dying state, you will have to force delete the machine using the machine number.

juju destroy-machine --force 3

Comments