openstack管理命令[T版命令]

T版管理命令

openstackT版管理计算命令

1. 列出所有计算实例

openstack server list

2. 查看计算实例的详细信息

openstack server show <instance_name_or_id>

3. 创建一个新的计算实例

 openstack server create --image <image_name_or_id> --flavor <flavor_name_or_id> --key-name <keypair_name> --security-group <security_group_name_or_id> --network <network_name_or_id> <instance_name><image_name_or_id> 是要使用的镜像的名称或 ID,
<flavor_name_or_id> 是计算实例规格的名称或 ID,
<keypair_name> 是 SSH 密钥对的名称,
<security_group_name_or_id> 是安全组的名称或 ID,
<network_name_or_id> 是要连接到的网络的名称或 ID,
<instance_name> 是要创建的实例的名称。

4. 删除一个计算实例

openstack server delete <instance_name_or_id>

5. 启动一个已停止的计算实例

openstack server start <instance_name_or_id>

6. 停止一个运行中的计算实例

openstack server stop <instance_name_or_id>   

7. 暂停一个运行中的计算实例

openstack server pause <instance_name_or_id>

8. 取消暂停一个处于暂停状态的计算实例

openstack server unpause <instance_name_or_id>

9. 挂起一个运行中的计算实例

openstack server suspend <instance_name_or_id>

10. 恢复一个处于挂起状态的计算实例

openstack server resume <instance_name_or_id>

11. 调整一个计算实例的规格

openstack server resize <instance_name_or_id> <flavor_name_or_id>

12. 查看计算实例的控制台日志

openstack console log show <instance_name_or_id>

13. 查看计算实例的控制台 URL

openstack console url show <instance_name_or_id>nova get-vnc-console <instance_name> novnc

14.连接到计算实例的控制台

 openstack console connect <instance_name_or_id>

15.Create a flavor

$ openstack flavor create --ram 512 --disk 1 --vcpus 1 m1.tiny

16.列出规格类型

$ openstack flavor list

openstackT版管理用户命令

1. 列出所有用户

openstack user list

2. 查看用户的详细信息

openstack user show <user_name_or_id>

3. 创建一个新的用户

openstack user create --password <password> --email <email> <user_name><password> 是用户的密码,
<email> 是用户的电子邮件地址,
<user_name> 是要创建的用户的名称。

4. 删除一个用户

   openstack user delete <user_name_or_id>

5. 将一个用户添加到指定的项目中

openstack user set --project <project_name_or_id> <user_name_or_id>

6. 为一个用户分配指定项目中的指定角色

openstack role add --project <project_name_or_id> --user <user_name_or_id> <role_name_or_id>

7. 从一个用户中删除指定项目中的指定角色

openstack role remove --project <project_name_or_id> --user <user_name_or_id> <role_name_or_id>

8. 列出所有角色

openstack role list

9. 查看角色的详细信息

openstack role show <role_name_or_id>

10. 创建一个新的角色

openstack role create <role_name>

11. 删除一个角色

openstack role delete <role_name_or_id>

12. 为一个组分配指定项目中的指定角色

openstack role add --project <project_name_or_id> --group <group_name_or_id> <role_name_or_id>

13. 从一个组中删除指定项目中的指定角色

openstack role remove --project <project_name_or_id> --group <group_name_or_id> <role_name_or_id>

14. 列出所有组

openstack group list

15. 查看组的详细信息

openstack group show <group_name_or_id>

16. 创建一个新的组

openstack group create <group_name>

17. 删除一个组

openstack group delete <group_name_or_id>

18. 将一个用户添加到指定的组中

openstack group set --user <user_name_or_id> <group_name_or_id>

19. 从一个组中删除指定的用户

openstack group unset --user <user_name_or_id> <group_name_or_id>

openstackT版管理网络命令

创建网络

1. 列出系统的扩展分区

$ openstack extension list -c Alias -c Name --network
+------------------------------------------+---------------------------+
| Name | Alias |
+------------------------------------------+---------------------------+
| Default Subnetpools  | default-subnetpools   |
| Network IP Availability  | network-ip-availability   |
| Auto Allocated Topology Services | auto-allocated-topology   |
| Neutron L3 Configurable external gateway | ext-gw-mode   |
| Address scope| address-scope |
| Neutron Extra Route  | extraroute|
+------------------------------------------+---------------------------+

2. 创建网络

$ openstack network create net1
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value|
+---------------------------+--------------------------------------+
| admin_state_up| UP   |
| availability_zone_hints   |  |
| availability_zones|  |
| created_at| 2016-12-21T08:32:54Z |
| description   |  |
| headers   |  |
| id| 180620e3-9eae-4ba7-9739-c5847966e1f0 |
| ipv4_address_scope| None |
| ipv6_address_scope| None |
| mtu   | 1450 |
| name  | net1 |
| port_security_enabled | True |
| project_id| c961a8f6d3654657885226378ade8220 |
| provider:network_type | vxlan|
| provider:physical_network | None |
| provider:segmentation_id  | 14   |
| revision_number   | 3|
| router:external   | Internal |
| shared| False|
| status| ACTIVE   |
| subnets   |  |
| tags  | []   |
| updated_at| 2016-12-21T08:32:54Z |
+---------------------------+--------------------------------------+

注解
创建的网络的某些属性对于非管理员用户来说是不可见的

3. 创建一个指定的provider类型的网络

$ openstack network create net2 --provider-network-type vxlan
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value|
+---------------------------+--------------------------------------+
| admin_state_up| UP   |
| availability_zone_hints   |  |
| availability_zones|  |
| created_at| 2016-12-21T08:33:34Z |
| description   |  |
| headers   |  |
| id| c0a563d5-ef7d-46b3-b30d-6b9d4138b6cf |
| ipv4_address_scope| None |
| ipv6_address_scope| None |
| mtu   | 1450 |
| name  | net2 |
| port_security_enabled | True |
| project_id| c961a8f6d3654657885226378ade8220 |
| provider:network_type | vxlan|
| provider:physical_network | None |
| provider:segmentation_id  | 87   |
| revision_number   | 3|
| router:external   | Internal |
| shared| False|
| status| ACTIVE   |
| subnets   |  |
| tags  | []   |
| updated_at| 2016-12-21T08:33:34Z |
+---------------------------+--------------------------------------+

创建子网

1.创建一个子网

$ openstack subnet create subnet1 --network net1--subnet-range 192.0.2.0/24
+-------------------+--------------------------------------+
| Field | Value|
+-------------------+--------------------------------------+
| allocation_pools  | 192.0.2.2-192.0.2.254|
| cidr  | 192.0.2.0/24 |
| created_at| 2016-12-22T18:47:52Z |
| description   |  |
| dns_nameservers   |  |
| enable_dhcp   | True |
| gateway_ip| 192.0.2.1|
| headers   |  |
| host_routes   |  |
| id| a394689c-f547-4834-9778-3e0bb22130dc |
| ip_version| 4|
| ipv6_address_mode | None |
| ipv6_ra_mode  | None |
| name  | subnet1  |
| network_id| 180620e3-9eae-4ba7-9739-c5847966e1f0 |
| project_id| c961a8f6d3654657885226378ade8220 |
| revision_number   | 2|
| service_types |  |
| subnetpool_id | None |
| updated_at| 2016-12-22T18:47:52Z |
+-------------------+--------------------------------------+

subnet-create命令有以下必须和可选的参数

  • 网络子网的名称或标识编码

这个示例中,“net1”是指定网络名称的一个位置参数

  • 子网的CIDR

In this example, 192.0.2.0/24 is a positional argument that specifies the CIDR.

  • 子网名称是可选项

在此示例中,“–name subnet1” 用于指定子网名称

For information and examples on more advanced use of neutron’s subnet subcommand, see the OpenStack Administrator Guide.

创建路由器

1. 创建一个路由器

$ openstack router create router1
+-------------------------+--------------------------------------+
| Field   | Value|
+-------------------------+--------------------------------------+
| admin_state_up  | UP   |
| availability_zone_hints |  |
| availability_zones  |  |
| created_at  | 2016-12-22T18:48:57Z |
| description |  |
| distributed | True |
| external_gateway_info   | null |
| flavor_id   | None |
| ha  | False|
| headers |  |
| id  | e25a24ee-3458-45c7-b16e-edf49092aab7 |
| name| router1  |
| project_id  | e17431afc0524e0690484889a04b7fa0 |
| revision_number | 1|
| routes  |  |
| status  | ACTIVE   |
| updated_at  | 2016-12-22T18:48:57Z |
+-------------------------+--------------------------------------+

注意唯一返回的路由器标识符将会在后续的步骤中使用到。

2. 将路由器连接到外部的提供商网络

$ openstack router set ROUTER --external-gateway NETWORK

用路由器的唯一标识符替换ROUTER,用外部供应商网络的唯一标识符替换NETWORK 。

3. 将路由器连接到子网:

$ openstack router add subnet ROUTER SUBNET

用路由器的唯一标识符替换ROUTER ,用子网的唯一标识符替换SUBNET 。

创建端口

1. 创建指定IP地址的端口:

$ openstack port create --network net1 --fixed-ip subnet=subnet1,ip-address=192.0.2.40 port1
+-----------------------+-----------------------------------------+
| Field | Value   |
+-----------------------+-----------------------------------------+
| admin_state_up| UP  |
| allowed_address_pairs | |
| binding_host_id   | |
| binding_profile   | |
| binding_vif_details   | |
| binding_vif_type  | unbound |
| binding_vnic_type | normal  |
| created_at| 2016-12-22T18:54:43Z|
| description   | |
| device_id | |
| device_owner  | |
| extra_dhcp_opts   | |
| fixed_ips | ip_address='192.0.2.40', subnet_id='a   |
|   | 394689c-f547-4834-9778-3e0bb22130dc'|
| headers   | |
| id| 031ddba8-3e3f-4c3c-ae26-7776905eb24f|
| mac_address   | fa:16:3e:df:3d:c7   |
| name  | port1   |
| network_id| 180620e3-9eae-4ba7-9739-c5847966e1f0|
| port_security_enabled | True|
| project_id| c961a8f6d3654657885226378ade8220|
| revision_number   | 5   |
| security_groups   | 84abb9eb-dc59-40c1-802c-4e173c345b6a|
| status| DOWN|
| updated_at| 2016-12-22T18:54:44Z|
+-----------------------+-----------------------------------------+

In the previous command, net1 is the network name, which is a positional argument. --fixed-ip subnet<subnet>,ip-address=192.0.2.40 is an option which specifies the port’s fixed IP address we wanted.

注解

当你创建一个端口,你可以指定子网中任何未分配的IP地址,尽管这个地址不再预定义的IP地址池里(由云提供商设定)

2. 在不指定IP地址的情况下创建一个端口

$ openstack port create port2 --network net1
+-----------------------+-----------------------------------------+
| Field | Value   |
+-----------------------+-----------------------------------------+
| admin_state_up| UP  |
| allowed_address_pairs | |
| binding_host_id   | |
| binding_profile   | |
| binding_vif_details   | |
| binding_vif_type  | unbound |
| binding_vnic_type | normal  |
| created_at| 2016-12-22T18:56:06Z|
| description   | |
| device_id | |
| device_owner  | |
| extra_dhcp_opts   | |
| fixed_ips | ip_address='192.0.2.10', subnet_id='a   |
|   | 394689c-f547-4834-9778-3e0bb22130dc'|
| headers   | |
| id| eac47fcd-07ac-42dd-9993-5b36ac1f201b|
| mac_address   | fa:16:3e:96:ae:6e   |
| name  | port2   |
| network_id| 180620e3-9eae-4ba7-9739-c5847966e1f0|
| port_security_enabled | True|
| project_id| c961a8f6d3654657885226378ade8220|
| revision_number   | 5   |
| security_groups   | 84abb9eb-dc59-40c1-802c-4e173c345b6a|
| status| DOWN|
| updated_at| 2016-12-22T18:56:06Z|
+-----------------------+-----------------------------------------+

注解

Note that the system allocates one IP address if you do not specify an IP address in the openstack port create command.

注解

You can specify a MAC address with --mac-address MAC_ADDRESS. If you specify an invalid MAC address, including 00:00:00:00:00:00 or ff:ff:ff:ff:ff:ff, you will get an error.

3. 具有指定的固定IP地址的查询端口:

$ neutron port-list --fixed-ips ip_address=192.0.2.2 \ip_address=192.0.2.40
+----------------+------+-------------------+-------------------------------------------------+
| id | name | mac_address   | fixed_ips   |
+----------------+------+-------------------+-------------------------------------------------+
| baf13412-26... |  | fa:16:3e:f6:ec:c7 | {"subnet_id"... ..."ip_address": "192.0.2.2"}   |
| f7a08fe4-e7... |  | fa:16:3e:97:e0:fc | {"subnet_id"... ..."ip_address": "192.0.2.40"}  |
+----------------+------+-------------------+-------------------------------------------------+

本文链接:https://my.lmcjl.com/post/2467.html

展开阅读全文

4 评论

留下您的评论.