sh Openstack CLI命令使用标识V3(包含组)创建新项目/租户和网络

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Openstack CLI命令使用标识V3(包含组)创建新项目/租户和网络相关的知识,希望对你有一定的参考价值。

# Now we are managing the users on a project by using groups. So everything
# is about creating users and add they to the groups.
# A special user is created always with the same name of the project,
# just to reserve the name and avoid confusion and have an email.


############## Define those variables for the tenant (this is just an example)
TENANT=test
PASSWORD=test
TENANT_DESC="Test"
TENANT_EMAIL="platform-engineering@springer.com"
TENANT_NET_CIDR="10.0.0.0/24"
TENANT_NET_GW="10.0.0.1"
############### 

# Create a new project and get the id
openstack project create $TENANT --description $TENANT_DESC 
TENANT_ID=$(openstack project list | awk "/\ $TENANT\ / { print \$2 }")

# Create a new user 
openstack user create --project $TENANT --password $PASSWORD --email $TENANT_EMAIL $TENANT

# Create a new group for the project
openstack group create --description "$TENANT users" $TENANT-users

# Create the global user role if it does not exists
openstack role create --or-show user

# Add the new user to the users of the project
openstack group add user $TENANT-users $TENANT

# Add the user role to the project and group
openstack role add --project $TENANT --group $TENANT-users user
# otherwise we would have to add the user directly:
#openstack role add --project demo --user demo user

# Create the network with VLAN
neutron net-create --tenant-id $TENANT_ID --provider:network_type vlan  "$TENANT-net"
# The field provider:segmentation_id is the VLAN ID for the tenant

# Create the subnet and get the ID
neutron subnet-create --name "$TENANT-subnet" --tenant-id $TENANT_ID --gateway $TENANT_NET_GW "$TENANT-net" $TENANT_NET_CIDR
TENANT_SUBNET_ID=$(neutron subnet-list -f csv -F id -F cidr | grep "$TENANT_NET_CIDR" | cut -f1 -d',' | tr -d '"')
  
# Create an HA Router and get the ID
neutron router-create --ha True --tenant-id $TENANT_ID "$TENANT-net-to-online_live-extnet"
ROUTER_ID=$(neutron router-list  -f csv -F id -F name | grep "$TENANT-net-to-online_live-extnet" | cut -f1 -d',' | tr -d '"')
 
# Set the gw for the new router
neutron router-gateway-set "$TENANT-net-to-online_live-extnet" online_dev
   
# Add a new interface in the main router
neutron router-interface-add $ROUTER_ID $TENANT_SUBNET_ID

以上是关于sh Openstack CLI命令使用标识V3(包含组)创建新项目/租户和网络的主要内容,如果未能解决你的问题,请参考以下文章

openstack命令行 CLI

openstack中利用screen命令重启服务

neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead

sh Openstack命令示例

openstack CLI

sh Openstack:使用python-novaclient命令将浮动IP与实例解除关联/重新关联,以纠正连接问题。