Search This Blog

Showing posts with label meta. Show all posts
Showing posts with label meta. Show all posts

Wednesday, October 24, 2012

How to check all metadata on your cloud servers

You can create a cloud server and attach a metadata to it. You can modify the settings through out the cloud server life.

Problem

How to check all metadata on all your cloud servers in a simple way.

root@server:~# nova list | tail -n +4 | tac | tail -n +2 | cut  -d'|' -f2 | while read i; do  nova show $i | egrep -i 'name|metadata'; done | sed 's/  */ /g'
| metadata | {} |
| name | test4 |

| metadata | {u'mykey2': u'value2 and 3', u'myke1': u'value1'} |
| name | test4 |

| metadata | {u'rado': u'my value2', u'rade2': u'value3'} |
| name | test3 |

| metadata | {u'rado': u'my value2'} |
| name | test2 |

| metadata | {} |
| name | test1 |

| metadata | {} |
| name | manage2 |

References
  1. http://stackoverflow.com/questions/8017456/output-file-lines-from-last-to-first-in-bash
  2. http://stackoverflow.com/questions/1411713/how-to-split-a-file-and-keep-the-first-line-in-each-of-the-pieces

Example of nova boot command

Problem

There is a lot of written about how the Cloud API works. What the request has to look like and what the correct successes is. But there aren't many practical tutorials or howtos on how to use the tools in practice.

Below is an example of how to create a cloud server using the nova tool.

Solution

This is a link that describe how to install the nova tool [1]. I'm not going to cover this here and I assume you already have it.

  1. Creaet a simple cloud server

  2. root@server:~# nova help | grep image
    root@server:~# nova help | grep flavor
    root@server:~# nova help | grep meta
    root@server:~# nova boot --flavor 2 --image 5cebb13a-f783-4f8c-8058-c4182c724ccd test4 
    +-------------------------+--------------------------------------+
    | Property                | Value                                |
    +-------------------------+--------------------------------------+
    | OS-DCF:diskConfig       | AUTO                                 |
    | OS-EXT-STS:power_state  | 0                                    |
    | OS-EXT-STS:task_state   | scheduling                           |
    | OS-EXT-STS:vm_state     | building                             |
    | accessIPv4              |                                      |
    | accessIPv6              |                                      |
    | adminPass               | 7777                                 |
    | created                 | 2012-10-23T23:11:46Z                 |
    | flavor                  | 512MB Standard Instance              |
    | hostId                  |                                      |
    | id                      | db16f2bc-0f75-4215-927b-c8a34e165dce |
    | image                   | Ubuntu 12.04 LTS (Precise Pangolin)  |
    | metadata                | {}                                   |
    | name                    | test4                                |
    | progress                | 0                                    |
    | rax-bandwidth:bandwidth | []                                   |
    | status                  | BUILD                                |
    | tenant_id               | 7777                                 |
    | updated                 | 2012-10-23T23:11:47Z                 |
    | user_id                 | 7777                                 |
    +-------------------------+--------------------------------------+
    


  3. Creaet a simple cloud server with metadata
root@server:~# nova boot --flavor 2 --image 5cebb13a-f783-4f8c-8058-c4182c724ccd test4 --meta myke1='value1' --meta mykey2='value2 and 3'
+-------------------------+---------------------------------------------------+
| Property                | Value                                             |
+-------------------------+---------------------------------------------------+
| OS-DCF:diskConfig       | AUTO                                              |
| OS-EXT-STS:power_state  | 0                                                 |
| OS-EXT-STS:task_state   | scheduling                                        |
| OS-EXT-STS:vm_state     | building                                          |
| accessIPv4              |                                                   |
| accessIPv6              |                                                   |
| adminPass               | 777                                               |
| created                 | 2012-10-23T23:15:18Z                              |
| flavor                  | 512MB Standard Instance                           |
| hostId                  |                                                   |
| id                      | 3f6be5ae-9c4e-4b0f-880f-c4928e426864              |
| image                   | Ubuntu 12.04 LTS (Precise Pangolin)               |
| metadata                | {u'mykey2': u'value2 and 3', u'myke1': u'value1'} |
| name                    | test4                                             |
| progress                | 0                                                 |
| rax-bandwidth:bandwidth | []                                                |
| status                  | BUILD                                             |
| tenant_id               | 7777                                              |
| updated                 | 2012-10-23T23:15:19Z                              |
| user_id                 | 777                                               |
+-------------------------+---------------------------------------------------+

References
  1. http://docs.rackspace.com/servers/api/v2/cs-gettingstarted/content/section_gs_install_nova.html
  2. http://docs.openstack.org/api/quick-start/content/
  3. http://devops.rackspace.com/13/getting-started-using-python-novaclient-to-manage-cloud-servers
  4. http://vexxhost.com/blog/2012/09/10/installing-cpanel-on-a-cloud-server/