When you’ve created more than one OpenStack user via the CLI or Horizon dashboard it gets old really quick. It’s a good idea to automate it or use a tool to do the job for you.
Along with whatever you want to automate, one problem with creating and managing OpenStack users is managing their Neutron networks. I’ve written a simple tool in Shell which takes care of this for you interactively, giving the following attributes so they can be off and running immediately creating instances and mapping floating IP addresses for external connectivity.
- Create a generic Neutron Network (192.168.1.0), Subnet and Router
- Add a port to their router, link and set their router gateway to the external network
- Create Security Group rules for common traffic (SSH, ICMP)
How to Use It
Download the tool and make it executable, source your keystonerc_admin file
# wget https://raw.githubusercontent.com/sadsfae/misc-scripts/master/shell/openstack-create-user.sh # chmod +x openstack-create-user.sh # source keystonerc_admin
Edit openstack-create-user.sh and replace the following lines to match your environment.
You may also want to replace other variables as needed, noting the comments.
# Neutron external network from 'neutron net-list' EXTERNAL_NET_ID="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" CONTROLLER_PUB_IP="1.1.1.1" USER_PASSWORD="changepassword" USER_DOMAIN="@example.com"
Run the tool: specify tenant, username and choose whether a generic network should be created.
# ./openstack-create-user.sh ##################################################### # OpenStack Account Creator 6000 # # # ##################################################### Enter Tenant name (defaults to username): pants Enter User name: banana Create Generic Network? Y/N: Y
You should now see the output below:
#################################### # Account Summary # ==================================== Username: banana Tenant: pants Tenant ID: e36ceecef68749139fdf0515c03db817 Network Name: default-network-pants-zbvh2 Network ID: bf02ec9a-18b8-4881-8c54-e45f97e06efe ====================================