Featured image of post OpenStack 常用命令

OpenStack 常用命令

OpenStack 常用命令

OpenStack 常用命令

MySQL

1
2
show variables like "storage_engine";	//查询默认存储引擎InnoDB
show variables like "have%";	//查询支持的存储引擎

Keyston

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
source /etc/keystone/admin-openrc.sh

openstack user create --domain demo --password password testuser 
//--domain为所属域 --password为密码 testuser是用户名

[root@controller ~]# openstack user list
//查看用户列表
+----------------------------------+----------+
| ID                               | Name     |
+----------------------------------+----------+
| 1877ca2b73b04380af77a5cd3d057734 | demo     |
| 21a0b28505a140b9b54ca5a20542746c | glance   |
| 65e4fa15c643474d99f0b7950b5328bb | neutron  |
| 710f538564124ecd9fdcfaef40792e84 | admin    |
| 7caa95a15cb54d789d69e511c8214cb8 | nova     |
| cce5f695864940a0a32eab0d2015528c | testuser |
+----------------------------------+----------+

[root@controller ~]# openstack endpoint list
//endpoint列表
+---------------+-----------+--------------+--------------+---------+-----------+------------------+
| ID            | Region    | Service Name | Service Type | Enabled | Interface | URL              |
+---------------+-----------+--------------+--------------+---------+-----------+------------------+
| 1f7824e81d9f4 | RegionOne | neutron      | network      | True    | internal  | http://controlle |
| f04b595b97a0a |           |              |              |         |           | r:9696           |
| e78f46        |           |              |              |         |           |                  |
| 399280c404a54 | RegionOne | glance       | image        | True    | public    | http://controlle |
| a1bb314531c2b |           |              |              |         |           | r:9292           |
| 880ca1        |           |              |              |         |           |                  |
|   . ... ... ... ... ... ... ... ... ... ... ... 略 ... ... ... ... ... ... ... ... ... ... ... . |
| fcb27923a6674 | RegionOne | neutron      | network      | True    | public    | http://controlle |
| 064a5f6d6ddd6 |           |              |              |         |           | r:9696           |
| 90fa54        |           |              |              |         |           |                  |
+---------------+-----------+--------------+--------------+---------+-----------+------------------+

[root@controller ~]# openstack role list
//查询OpenStack的角色列表
+----------------------------------+-------+
| ID                               | Name  |
+----------------------------------+-------+
| 2a818016714e4f828d96e05475a67208 | user  |
| a38871259df34ea39884b9019cea926b | admin |
+----------------------------------+-------+

[root@controller ~]# openstack service list
//查看keystone 服务
+----------------------------------+----------+----------+
| ID                               | Name     | Type     |
+----------------------------------+----------+----------+
| 40d9e5252f5f4967bc336542e6faab23 | glance   | image    |
| 442e7454d7244037b7fdd05a96440dec | keystone | identity |
| 6a95c79cc01147029bf79b5dfa3304f5 | neutron  | network  |
| 8a78c7d6a9af432f89ae9a4d185b29d5 | nova     | compute  |
| d821457f69fa4838ba42074652649548 | neutron  | network  |
+----------------------------------+----------+----------+

[root@controller ~]# openstack project list
//查看keystone租户
+----------------------------------+---------+
| ID                               | Name    |
+----------------------------------+---------+
| 00fa84b7a654447886421978253a2829 | demo    |
| 869f732ec387457ba9cfdcb424cc8ea2 | admin   |
| b421cbca4234472a94de962c634b5bb9 | service |
+----------------------------------+---------+

[root@controller ~]# openstack project show demo
//查看租户情况,show 后面加上上面查询到的用户 name
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Demo Project                     |
| domain_id   | ad5088bf450145819f9338635ebfb7a6 |
| enabled     | True                             |
| id          | 00fa84b7a654447886421978253a2829 |
| is_domain   | False                            |
| name        | demo                             |
| parent_id   | ad5088bf450145819f9338635ebfb7a6 |
+-------------+----------------------------------+

[root@controller ~]# openstack domain create --description "PPX_PiXiaoMei_Only" NeiHanDuanZi_TV
//创建域
//--description "PPX_PiXiaoMei_Only" 不是必须的, 下同
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | PPX_PiXiaoMei_Only               |
| enabled     | True                             |
| id          | 57581f0aa311416c88c9fdb36688a46e |
| name        | NeiHanDuanZi_TV                  |
+-------------+----------------------------------+

[root@controller ~]# openstack project create --domain NeiHanDuanZi_TV --description "PDL" PXM
//创建项目(租户)
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | PDL                              |
| domain_id   | 57581f0aa311416c88c9fdb36688a46e |
| enabled     | True                             |
| id          | 4b6c52f02496465ebc70447b740a043c |
| is_domain   | False                            |
| name        | PXM                              |
| parent_id   | 57581f0aa311416c88c9fdb36688a46e |
+-------------+----------------------------------+

[root@controller ~]# openstack user create --domain NeiHanDuanZi_TV --password-prompt frelon
//创建用户
User Password:
Repeat User Password:
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | 57581f0aa311416c88c9fdb36688a46e |
| enabled   | True                             |
| id        | 5ac456db906a43e8a8427ae7f3a5334a |
| name      | frelon                           |
+-----------+----------------------------------+


[root@controller ~]# openstack role create oiL
//创建角色
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | None                             |
| id        | 893a47b1b1ce4f558858418da04c86e4 |
| name      | oiL                              |
+-----------+----------------------------------+

openstack role add  --project PXM --user frelon oiL
//为某项目中的某用户指定角色

Tenant也叫project,译为租户 , 所有的资源(包括但不限于CPU,Memory,Disk等)都属于Tenant , User 本生并没有任何调度资源的权力,只有把 User加入Tenant后,用户才有资源的调度权限,Tenant就相当于一个 用户组,只不过在OpenStack这里被强化了,用户必须加入一个或多个用户组才可以调度资源

Role主要是解决用户登陆后的权限问题,即用户登录以后可以干什么,有没有权利操作资源等等,简而言之就是鉴权,一个用户必须有一个或多个Role才有权力执行相应操作. Role是全局的,所有Domain里的Group,User

Group是用来配合Role来使用的,给Group加上相应的权限,再把用户加入Group该用户就可以获得Group所有的权限了,这样就方便了Role的分配

Domain 常常表示一个客户/合作伙伴,并且 project,Group,User在同一个Domain里面不可以重复

glance

1
2
3
4
5
6
7
8
glance image-create --name "testone" --disk-format "qcow2" --container-format bare --progress < /root/CentOS_6.5_x86_64_XD.qcow2
//上传镜像 并 用--name 命名为 "testone"

openstack image set testone --name examimage 
//修改已上传的镜像名称

openstack image list 
//列出已上传的镜像列表

nova

1
2
nova usage-list 
//查询资源使用情况

neutron

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 neutron router-list
 //列出当前存在的网络/路由器
 
 neutron router-show + id/name
 
 [root@controller ~]#  neutron router-list
+--------------------------------------+------+-----------------------+-------------+-------+
| id                                   | name | external_gateway_info | distributed | ha    |
+--------------------------------------+------+-----------------------+-------------+-------+
| bb46e65a-ad51-4c13-b1c6-51c845dcfb52 | cvn  | null                  | False       | False |
+--------------------------------------+------+-----------------------+-------------+-------+
[root@controller ~]#  neutron router-show bb46e65a-ad51-4c13-b1c6-51c845dcfb52
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | True                                 |
| availability_zone_hints |                                      |
| availability_zones      | nova                                 |
| description             |                                      |
| distributed             | False                                |
| external_gateway_info   |                                      |
| ha                      | False                                |
| id                      | bb46e65a-ad51-4c13-b1c6-51c845dcfb52 |
| name                    | cvn                                  |
| routes                  |                                      |
| status                  | ACTIVE                               |
| tenant_id               | 869f732ec387457ba9cfdcb424cc8ea2     |
+-------------------------+--------------------------------------+


trove

OpenStack命令大全

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
access token create                        project create
acl delete                                 project delete
acl get                                    project list
acl submit                                 project set
acl user add                               project show
acl user remove                            ptr record list
aggregate add host                         ptr record set
aggregate create                           ptr record show
aggregate delete                           ptr record unset
aggregate list                             quota set
aggregate remove host                      quota show
aggregate set                              recordset create
aggregate show                             recordset delete
availability zone list                     recordset list
backup create                              recordset set
backup delete                              recordset show
backup list                                region create
backup restore                             region delete
backup show                                region list
ca get                                     region set
ca list                                    region show
catalog list                               request token authorize
catalog show                               request token create
command list                               role add
complete                                   role assignment list
compute agent create                       role create
compute agent delete                       role delete
compute agent list                         role list
compute agent set                          role remove
compute service delete                     role set
compute service list                       role show
compute service set                        router create
configuration show                         router delete
console log show                           router list
console url show                           router set
consumer create                            router show
consumer delete                            secret container create
consumer list                              secret container delete
consumer set                               secret container get
consumer show                              secret container list
container create                           secret delete
container delete                           secret get
container list                             secret list
container save                             secret order create
container set                              secret order delete
container show                             secret order get
container unset                            secret order list
credential create                          secret store
credential delete                          secret update
credential list                            security group create
credential set                             security group delete
credential show                            security group list
dataprocessing cluster create              security group rule create
dataprocessing cluster delete              security group rule delete
dataprocessing cluster list                security group rule list
dataprocessing cluster scale               security group rule show
dataprocessing cluster show                security group set
dataprocessing cluster template create     security group show
dataprocessing cluster template delete     server add security group
dataprocessing cluster template list       server add volume
dataprocessing cluster template show       server create
dataprocessing cluster template update     server delete
dataprocessing cluster update              server dump create
dataprocessing cluster verification        server image create
dataprocessing data source create          server list
dataprocessing data source delete          server lock
dataprocessing data source list            server migrate
dataprocessing data source show            server pause
dataprocessing data source update          server reboot
dataprocessing image list                  server rebuild
dataprocessing image register              server remove security group
dataprocessing image show                  server remove volume
dataprocessing image tags add              server rescue
dataprocessing image tags remove           server resize
dataprocessing image tags set              server resume
dataprocessing image unregister            server set
dataprocessing job binary create           server shelve
dataprocessing job binary delete           server show
dataprocessing job binary download         server ssh
dataprocessing job binary list             server start
dataprocessing job binary show             server stop
dataprocessing job binary update           server suspend
dataprocessing job delete                  server unlock
dataprocessing job execute                 server unpause
dataprocessing job list                    server unrescue
dataprocessing job show                    server unset
dataprocessing job template create         server unshelve
dataprocessing job template delete         service create
dataprocessing job template list           service delete
dataprocessing job template show           service list
dataprocessing job template update         service provider create
dataprocessing job type configs get        service provider delete
dataprocessing job type list               service provider list
dataprocessing job update                  service provider set
dataprocessing node group template create  service provider show
dataprocessing node group template delete  service set
dataprocessing node group template list    service show
dataprocessing node group template show    snapshot create
dataprocessing node group template update  snapshot delete
dataprocessing plugin configs get          snapshot list
dataprocessing plugin list                 snapshot set
dataprocessing plugin show                 snapshot show
domain create                              snapshot unset
domain delete                              software config create
domain list                                software config delete
domain set                                 software config list
domain show                                software config show
ec2 credentials create                     software deployment create
ec2 credentials delete                     software deployment delete
ec2 credentials list                       software deployment list
ec2 credentials show                       software deployment metadata show
endpoint create                            software deployment output show
endpoint delete                            software deployment show
endpoint list                              stack abandon
endpoint set                               stack adopt
endpoint show                              stack cancel
extension list                             stack check
federation domain list                     stack create
federation project list                    stack delete
federation protocol create                 stack event list
federation protocol delete                 stack event show
federation protocol list                   stack hook clear
federation protocol set                    stack hook poll
federation protocol show                   stack list
flavor create                              stack output list
flavor delete                              stack output show
flavor list                                stack resource list
flavor set                                 stack resource mark unhealthy
flavor show                                stack resource metadata
flavor unset                               stack resource show
group add user                             stack resource signal
group contains user                        stack resume
group create                               stack show
group delete                               stack snapshot create
group list                                 stack snapshot delete
group remove user                          stack snapshot list
group set                                  stack snapshot restore
group show                                 stack snapshot show
help                                       stack suspend
host list                                  stack template show
host show                                  stack update
hypervisor list                            subnet delete
hypervisor show                            subnet list
hypervisor stats show                      subnet pool delete
identity provider create                   subnet pool list
identity provider delete                   subnet pool show
identity provider list                     subnet show
identity provider set                      tld create
identity provider show                     tld delete
image add project                          tld list
image create                               tld set
image delete                               tld show
image list                                 token issue
image remove project                       token revoke
image save                                 trust create
image set                                  trust delete
image show                                 trust list
ip fixed add                               trust show
ip fixed remove                            usage list
ip floating add                            usage show
ip floating create                         user create
ip floating delete                         user delete
ip floating list                           user list
ip floating pool list                      user password set
ip floating remove                         user set
ip floating show                           user show
keypair create                             volume create
keypair delete                             volume delete
keypair list                               volume list
keypair show                               volume qos associate
limits show                                volume qos create
mapping create                             volume qos delete
mapping delete                             volume qos disassociate
mapping list                               volume qos list
mapping set                                volume qos set
mapping show                               volume qos show
module list                                volume qos unset
network create                             volume set
network delete                             volume show
network list                               volume type create
network set                                volume type delete
network show                               volume type list
object create                              volume type set
object delete                              volume type show
object list                                volume type unset
object save                                volume unset
object set                                 zone abandon
object show                                zone axfr
object store account set                   zone blacklist create
object store account show                  zone blacklist delete
object store account unset                 zone blacklist list
object unset                               zone blacklist set
orchestration build info                   zone blacklist show
orchestration resource type list           zone create
orchestration resource type show           zone delete
orchestration service list                 zone list
orchestration template function list       zone set
orchestration template version list        zone show
policy create                              zone transfer accept request
policy delete                              zone transfer accept show
policy list                                zone transfer request create
policy set                                 zone transfer request delete
policy show                                zone transfer request list
port delete                                zone transfer request set
port show                                  zone transfer request show