openstack中 file/meta/user-data的区别

openstack中有多种方式可以将用户数据带入虚机中。


虚机启动时注入文件:

[root@compute1 ~]# nova boot --image 2401a752-fbda-482e-98f6-281656758b7f --file /home/test=./matt.test --flavor=1 test6
[root@compute2 ~]# ssh [email protected]
The authenticity of host '100.100.100.10 (100.100.100.10)' can't be established.
RSA key fingerprint is 25:6b:4a:4d:a9:f5:78:87:4a:81:fe:c5:b2:57:8f:d2.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '100.100.100.10' (RSA) to the list of known hosts.
[email protected]'s password: 
$ sudo su -
# cd /home/
# ls
cirros ftp test


虚机启动时注入meta:

[root@compute1 ~]# nova boot --image 2401a752-fbda-482e-98f6-281656758b7f --meta matt1=test1 --meta matt2=test2 --flavor=1 test2
[root@compute1 ~]# nova show test2
+-------------------------------------+--------------------------------------------------------------+
| Property | Value |
+-------------------------------------+--------------------------------------------------------------+
| status | ACTIVE |
| updated | 2013-09-12T02:39:43Z |
| OS-EXT-STS:task_state | None |
| OS-EXT-SRV-ATTR:host | compute2.webex.com |
| key_name | None |
| image | cirros-0.3.0-x86_64_2 (2401a752-fbda-482e-98f6-281656758b7f) |
| private-net network | 100.100.100.7 |
| hostId | 9f9ff1519a8807f08ae0798af159cbaa8c96912da9beacfd8b6ca134 |
| OS-EXT-STS:vm_state | active |
| OS-EXT-SRV-ATTR:instance_name | instance-000001b9 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | compute2.webex.com |
| flavor | m1.tiny (1) |
| id | 6c6cf452-0763-486d-a94c-acdf30c69304 |
| security_groups | [{u'name': u'default'}] |
| user_id | 2a167be1e83c477e9dd57033c2eaaec9 |
| name | test2 |
| created | 2013-09-12T02:38:25Z |
| tenant_id | 0b337e1ad59d43428b77c8bb2f84ce32 |
| OS-DCF:diskConfig | MANUAL |
| metadata | {u'matt2': u'test2', u'matt1': u'test1'} |
| accessIPv4 | |
| accessIPv6 | |
| progress | 0 |
| OS-EXT-STS:power_state | 1 |
| OS-EXT-AZ:availability_zone | nova |
| config_drive | |
+-------------------------------------+--------------------------------------------------------------+
[root@compute2 ~]# ssh [email protected]
[email protected]'s password: 
$ cd /
$ cat meta.js 
{"matt2": "test2", "matt1": "test1"}$ 


虚机启动时注入user-data:

[root@compute1 ~]# cat matt.test 
This is test for user-data
[root@compute1 ~]# nova boot --image 2401a752-fbda-482e-98f6-281656758b7f --user-data ./matt.test --flavor=1 test4
[root@compute1 ~]# ssh [email protected]
The authenticity of host '100.100.100.8 (100.100.100.8)' can't be established.
RSA key fingerprint is 31:7f:b6:5f:ea:b8:5a:b4:f5:97:35:27:7c:3c:8e:3a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '100.100.100.8' (RSA) to the list of known hosts.
[email protected]'s password: 
$ sudo su -
# telnet 169.254.169.254 80
GET /latest/user-data

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 27
Date: Thu, 12 Sep 2013 03:54:12 GMT
Connection: close

This is test for user-data
Connection closed by foreign host


你可能感兴趣的:(openstack,nova)