Skip to content

Instantly share code, notes, and snippets.

@boina-n
Created December 11, 2018 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boina-n/eaa9d811ccba177735bd3972ccdcb61a to your computer and use it in GitHub Desktop.
Save boina-n/eaa9d811ccba177735bd3972ccdcb61a to your computer and use it in GitHub Desktop.
How to attach ports to a machine on openstack
primary_subnet=PRD_APPLIS
secondary_subnet=ADM_APPLIS
primary_network=port_opsman01_I_PRD_APPLIS
secondary_network=port_opsman01_I_ADM_APPLIS
virtmachine=opsman01
#show a Default port
neutron port-show $primary_network
#show a Second port
neutron port-show $secondary_network
#Create ports
neutron port-create --name $primary_network --fixed-ip subnet_id=$primary_subnet,ip_address=10.110.148.10 $primary_subnet
neutron port-create --name $secondary_network --fixed-ip subnet_id=$secondary_subnet,ip_address=10.233.122.10 $secondary_subnet
# Get the network IDs
default_network_id=$(neutron port-show $primary_network -f json | jq '.id' |tr -d '"')
second_network_id=$(neutron port-show $secondary_network -f json | jq '.id' |tr -d '"')
# Attach ports to the VM
nova interface-attach --port-id=$default_network_id $virtmachine
nova interface-attach --port-id=$second_network_id $virtmachine
# start the vm
nova start $virtmachine
# You also probably need to set the openstack security group to the vm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment