How to convert instance name from instance-?? to actual names ?

While adding compute node in my previous article, I noticed two kind of naming convention is used which makes bit difficult to identify which instance is running on which node.

Example : In below command I am seeing instance name like “instance-00000009” instead of the names which I am seeing in “nova list” output.

[root@vswitch1 ~(keystone_admin)]# nova hypervisor-servers vswitch1
+————————————–+——————-+—————+———————+
| ID                                   | Name              | Hypervisor ID | Hypervisor Hostname |
+————————————–+——————-+—————+———————+
| a0f07082-e54b-4bc5-82f0-2f67d0e9b7f0 | instance-00000007 | 1             | vswitch1            |
| 1611741a-840e-4c1c-92a0-0d5b46058273 | instance-00000009 | 1             | vswitch1            |
| 891c3b12-4d76-4f7b-b22a-eb21457ce5f4 | instance-0000000b | 1             | vswitch1            |
| 75189fdb-2a37-4808-81f6-3de3ffc57020 | instance-0000000c | 1             | vswitch1            |
+————————————–+——————-+—————+———————+

On other hand in below output we are seeing the expected names.

[root@vswitch1 ~(keystone_admin)]# nova list
+————————————–+—————————————-+———+————+————-+——————————————-+
| ID                                   | Name                                   | Status  | Task State | Power State | Networks                                  |
+————————————–+—————————————-+———+————+————-+——————————————-+
| a0f07082-e54b-4bc5-82f0-2f67d0e9b7f0 | test1                                  | SHUTOFF | –          | Shutdown    | private_network=10.10.2.9, 192.168.122.11 |
| 75189fdb-2a37-4808-81f6-3de3ffc57020 | test1vswitch2                          | ACTIVE  | –          | Running     | private1=10.10.3.6                        |
| 1611741a-840e-4c1c-92a0-0d5b46058273 | test3                                  | SHUTOFF | –          | Shutdown    | private1=10.10.3.3                        |
| 891c3b12-4d76-4f7b-b22a-eb21457ce5f4 | testinstance1-my_instance-wt43ngisfi2q | ACTIVE  | –          | Running     | private1=10.10.3.5                        |
+————————————–+—————————————-+———+————+————-+——————————————-+

Did some google search and  made the below modification in /etc/nova/nova.conf and restart the nova service.

FROM :

[root@vswitch1 ~(keystone_admin)]# grep -i instance_name /etc/nova/nova.conf
#instance_name_template=instance-%08x

TO :

[root@vswitch1 ~(keystone_admin)]# grep -i instance_name /etc/nova/nova.conf
#instance_name_template=instance-%08x
instance_name_template=”%(hostname)s”

Restarted nova service.

I am able to see the desired names in output now.

[root@vswitch1 ~(keystone_admin)]# nova hypervisor-servers vswitch1
+————————————–+—————————————-+—————+———————+
| ID                                   | Name                                   | Hypervisor ID | Hypervisor Hostname |
+————————————–+—————————————-+—————+———————+
| a0f07082-e54b-4bc5-82f0-2f67d0e9b7f0 | test1                                  | 1             | vswitch1            |
| 1611741a-840e-4c1c-92a0-0d5b46058273 | test3                                  | 1             | vswitch1            |
| 891c3b12-4d76-4f7b-b22a-eb21457ce5f4 | testinstance1-my-instance-wt43ngisfi2q | 1             | vswitch1            |
| 75189fdb-2a37-4808-81f6-3de3ffc57020 | test1vswitch2                          | 1             | vswitch1            |
+————————————–+—————————————-+—————+———————+

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s