Skip to content

Instantly share code, notes, and snippets.

@SayBeano

SayBeano/neutron.sh

Forked from etoews/neutron.sh
Created Jun 6, 2016
Embed
What would you like to do?
Create a Neutron network, subnet, and port and boot an instance with the port
OS_AUTH_URL=http://162.242.242.161:5000/v2.0/
OS_REGION_NAME=RegionOne
OS_USERNAME=admin
OS_TENANT_NAME=admin
OS_PASSWORD=devstack
NET_NAME="test1-net"
IP_CIDR=192.168.0.0/24
IP_START=192.168.0.10
IP_END=192.168.0.20
IP_GW=192.168.0.1
IP=192.168.0.10
NET_ID=`neutron net-create $NET_NAME --router:external=True | egrep "\sid\s" | awk '{print $4}'`
SUBNET_ID=`neutron subnet-create $NET_NAME --allocation-pool start=$IP_START,end=$IP_END --gateway=$IP_GW --enable_dhcp=False $IP_CIDR | egrep "\sid\s" | awk '{print $4}'`
PORT_ID=`neutron port-create --fixed-ip subnet_id=$SUBNET_ID,ip_address=$IP $NET_ID | egrep "\sid\s" | awk '{print $4}'`
IMAGE_ID=`nova image-list | egrep "cirros-.*-uec\s" | awk '{print $2}'`
nova --debug boot test-server --image $IMAGE_ID --flavor 1 --nic port-id=$PORT_ID
# To delete the Neutron resources
# neutron port-list | awk '{print $2}' | xargs -I{} neutron port-delete "{}"
# neutron subnet-list | awk '{print $2}' | xargs -I{} neutron subnet-delete "{}"
# neutron net-list | awk '{print $2}' | xargs -I{} neutron net-delete "{}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment