Saturday, September 26, 2015

Resize nova instances on RDO Liberty

  Per http://funcptr.net/2014/09/29/openstack-resizing-of-instances/
During the resize process, the node where the instance is currently running will use SSH to connect to another compute node where the re-sized instance will live, and copy over the instance and associated files.
  Actually, there is an option to change this behavior and perform resize instance on the same compute node .
View :- http://www.madorn.com/resize-on-single-compute.html#.Vgb1wrNRpFB
Just one notice it requires restart all nova services on Controller and
openstack-nova-compute on Compute Node.
Posting bellow presumes that there are at least 2 Compute nodes :-
  compute01
  compute02
 
There are a couple of assumptions which will be made:
  1. Nova and qemu user both have the same UID on all compute nodes
  2. The path for your instances is the same on all of your compute nodes

*************************
On Controller
*************************
Verify nova account has no any shell
  cat /etc/passwd | grep nova
In this case add /bin/bash to account "nova"
  usermod -s /bin/bash nova
****************************************
Generate SSH key and Configuration
****************************************
After doing this the next steps are all run as the nova user.
# su - nova
 
Now  to generate an SSH key:
$  ssh-keygen -t rsa

Save the key without a passphrase.

Next we need to configure SSH to not do host key verification,

$  cat << EOF > ~/.ssh/config 
>Host * 
>StrictHostKeyChecking no 
>UserKnownHostsFile=/dev/null 
>EOF 

Next step is :-
$  cat ~/.ssh/id_rsa.pub > .ssh/authorized_keys 
$  chmod 600 .ssh/authorized_keys
 
*******************************************************
Then user nova creates tar ball to replicate it
between all Compute Nodes
*******************************************************
# su - nova
$ id
$ pwd
   /var/lib/nova
$ tar -cvf  ssh.tar .ssh/*
^D
# cd ~nova
# scp ssh.tar compute01:/var/lib/nova
# scp ssh.tar compute02:/var/lib/nova 
# ssh compute01
**********************
In other terminal
********************** 
# ssh compute02
**************************************** 
On Compute01 and Compute02
****************************************
# usermod -s /bin/bash nova
# cd /var/lib/nova
# chown nova:nova ssh.tar
# su - nova 
$  ls -la 
$  tar -xvf ssh.tar

At this point :  You should be able ssh as "nova"  from contoller to compute01 , compute02 and between compute nodes without password prompt.
Compute nodes are trusting Controller and each other via account "nova"

*****************************
Now run on Controller
*****************************
[root@ip-192-169-142-127 ~(keystone_admin)]# . keystonerc_demo
[root@ip-192-169-142-127 ~(keystone_demo)]# nova list
+--------------------------------------+------------+---------+------------+-------------+--------------------------------------+
| ID                                   | Name       | Status  | Task State | Power State | Networks                             |
+--------------------------------------+------------+---------+------------+-------------+--------------------------------------+
| 64b84cb7-c249-4808-b16e-0071d4d288e8 | CirrOSDevs | ACTIVE  | -          | Running     | demo_network=40.0.0.15, 172.24.4.234 |
| b6a9c438-3d7c-4f7e-aa4d-3ad47178eeac | VF22Devs15 | SHUTOFF | -          | Shutdown    | demo_network=40.0.0.13, 172.24.4.232 |
+--------------------------------------+------------+---------+------------+-------------+--------------------------------------+
[root@ip-192-169-142-127 ~(keystone_demo)]# nova resize CirrOSDevs 2 --poll

Server resizing... 100% complete
Finished
[root@ip-192-169-142-127 ~(keystone_demo)]# nova list
+--------------------------------------+------------+---------------+------------+-------------+--------------------------------------+
| ID                                   | Name       | Status        | Task State | Power State | Networks                             |
+--------------------------------------+------------+---------------+------------+-------------+--------------------------------------+
| 64b84cb7-c249-4808-b16e-0071d4d288e8 | CirrOSDevs | VERIFY_RESIZE | -          | Running     | demo_network=40.0.0.15, 172.24.4.234 |
| b6a9c438-3d7c-4f7e-aa4d-3ad47178eeac | VF22Devs15 | SHUTOFF       | -          | Shutdown    | demo_network=40.0.0.13, 172.24.4.232 |
+--------------------------------------+------------+---------------+------------+-------------+--------------------------------------+
[root@ip-192-169-142-127 ~(keystone_demo)]# nova resize-confirm 64b84cb7-c249-4808-b16e-0071d4d288e8
[root@ip-192-169-142-127 ~(keystone_demo)]# nova list
+--------------------------------------+------------+---------+------------+-------------+--------------------------------------+
| ID                                   | Name       | Status  | Task State | Power State | Networks                             |
+--------------------------------------+------------+---------+------------+-------------+--------------------------------------+
| 64b84cb7-c249-4808-b16e-0071d4d288e8 | CirrOSDevs | ACTIVE  | -          | Running     | demo_network=40.0.0.15, 172.24.4.234 |
| b6a9c438-3d7c-4f7e-aa4d-3ad47178eeac | VF22Devs15 | SHUTOFF | -          | Shutdown    | demo_network=40.0.0.13, 172.24.4.232 |
+--------------------------------------+------------+---------+------------+-------------+--------------------------------------+