All of the commands below can be done on the service node.
Note please ensure that the following environment variables are set. These are used by the various clients to access Keystone.
export OS_USERNAME=admin export OS_PASSWORD=adminpassword export OS_TENANT_NAME=admin export OS_AUTH_URL=http://127.0.0.1:5000/v2.0/
Internal Networking Configuration
Get the tenant ID (Used as $TENANT_ID later).
keystone tenant-list
+----------------------------------+--------------------+---------+ | id | name | enabled | +----------------------------------+--------------------+---------+ | 48fb81ab2f6b409bafac8961a594980f | admin | True | | cbb574ac1e654a0a992bfc0554237abf | service | True | | e371436fe2854ed89cca6c33ae7a83cd | invisible_to_admin | True | | e40fa60181524f9f9ee7aa1038748f08 | demo | True | +----------------------------------+--------------------+---------+
Create a internal network on the demo tenant ($TENANT_ID will be e40fa60181524f9f9ee7aa1038748f08):
quantum net-create --tenant-id $TENANT_ID net1 --provider:network_type vlan --provider:physical_network physnet1 --provider:segmentation_id 1024
+---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | id | e99a361c-0af8-4163-9feb-8554d4c37e4f | | name | net1 | | provider:network_type | vlan | | provider:physical_network | physnet1 | | provider:segmentation_id | 1024 | | router:external | False | | shared | False | | status | ACTIVE | | subnets | | | tenant_id | e40fa60181524f9f9ee7aa1038748f08 | +---------------------------+--------------------------------------+
Create a subnet on the network (Used as $SUBNET_ID later):
quantum subnet-create --tenant-id $TENANT_ID net1 10.0.0.0/24
+------------------+--------------------------------------------+ | Field | Value | +------------------+--------------------------------------------+ | allocation_pools | {"start": "10.0.0.2", "end": "10.0.0.254"} | | cidr | 10.0.0.0/24 | | dns_nameservers | | | enable_dhcp | True | | gateway_ip | 10.0.0.1 | | host_routes | | | id | c395cb5d-ba03-41ee-8a12-7e792d51a167 | | ip_version | 4 | | name | | | network_id | e99a361c-0af8-4163-9feb-8554d4c37e4f | | tenant_id | e40fa60181524f9f9ee7aa1038748f08 | +------------------+--------------------------------------------+
External Networking Configuration
Create a router (Used as $ROUTER_ID later):
quantum router-create --tenant_id $TENANT_ID router1
+-----------------------+--------------------------------------+ | Field | Value | +-----------------------+--------------------------------------+ | admin_state_up | True | | external_gateway_info | | | id | 685f64e7-a020-4fdf-a8ad-e41194ae124b | | name | router1 | | status | ACTIVE | | tenant_id | e40fa60181524f9f9ee7aa1038748f08 | +-----------------------+--------------------------------------+
Add the router to the subnet:
quantum router-interface-add $ROUTER_ID $SUBNET_ID
Added interface to router 685f64e7-a020-4fdf-a8ad-e41194ae124b
Create the external network (Used as $EXTERNAL_NETWORK_ID). Note this is on a different tenant to $TENANT_ID:
quantum net-create ext_net --tenant-id $TENANT_ID --router:external=True
+---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | id | 8858732b-0400-41f6-8e5c-25590e67ffeb | | name | ext_net | | provider:network_type | vlan | | provider:physical_network | physnet1 | | provider:segmentation_id | 1 | | router:external | True | | shared | False | | status | ACTIVE | | subnets | | | tenant_id | cbb574ac1e654a0a992bfc0554237abf | +---------------------------+--------------------------------------+
Create the subnet for floating IPs. Note the DHCP service is disabled for this subnet:
quantum subnet-create ext_net 172.24.4.224/28 -- --enable_dhcp=False
+------------------+--------------------------------------------------+ | Field | Value | +------------------+--------------------------------------------------+ | allocation_pools | {"start": "172.24.4.226", "end": "172.24.4.238"} | | cidr | 172.24.4.224/28 | | dns_nameservers | | | enable_dhcp | False | | gateway_ip | 172.24.4.225 | | host_routes | | | id | aef60b55-cbff-405d-a81d-406283ac6cff | | ip_version | 4 | | name | | | network_id | 8858732b-0400-41f6-8e5c-25590e67ffeb | | tenant_id | cbb574ac1e654a0a992bfc0554237abf | +------------------+--------------------------------------------------+
Set the router for the external network:
quantum router-gateway-set $ROUTER_ID $EXTERNAL_NETWORK_ID
Set gateway for router 685f64e7-a020-4fdf-a8ad-e41194ae124b
Floating IP Allocation
After a VM is deployed a floating IP address can be associated to the VM. A VM that is created will be allocated a Quantum port ($PORT_ID). The port ID for the VM can be retrieved as follows:
nova list +--------------------------------------+--------+--------+---------------+ | ID | Name | Status | Networks | +--------------------------------------+--------+--------+---------------+ | 1cdc671d-a296-4476-9a75-f9ca1d92fd26 | testvm | ACTIVE | net1=10.0.0.3 | +--------------------------------------+--------+--------+---------------+ quantum port-list -- --device_id 1cdc671d-a296-4476-9a75-f9ca1d92fd26 +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------+ | id | name | mac_address | fixed_ips | +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------+ | 9aa47099-b87b-488c-8c1d-32f993626a30 | | fa:16:3e:b4:d6:6c | {"subnet_id": "c395cb5d-ba03-41ee-8a12-7e792d51a167", "ip_address": "10.0.0.3"} | +--------------------------------------+------+-------------------+---------------------------------------------------------------------------------+
Allocate a floating IP (Used as $FLOATING_ID):
quantum floatingip-create ext_net +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | fixed_ip_address | | | floating_ip_address | 172.24.4.227 | | floating_network_id | 8858732b-0400-41f6-8e5c-25590e67ffeb | | id | 40952c83-2541-4d0c-b58e-812c835079a5 | | port_id | | | router_id | | | tenant_id | e40fa60181524f9f9ee7aa1038748f08 | +---------------------+--------------------------------------+
Associate a floating IP to a VM (in the case of the example it is 9aa47099-b87b-488c-8c1d-32f993626a30):
quantum floatingip-associate $FLOATING_ID $PORT_ID Associated floatingip 40952c83-2541-4d0c-b58e-812c835079a5
Show the floating IP:
quantum floatingip-show $FLOATING_ID +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | fixed_ip_address | 10.0.0.3 | | floating_ip_address | 172.24.4.227 | | floating_network_id | 8858732b-0400-41f6-8e5c-25590e67ffeb | | id | 40952c83-2541-4d0c-b58e-812c835079a5 | | port_id | 9aa47099-b87b-488c-8c1d-32f993626a30 | | router_id | 685f64e7-a020-4fdf-a8ad-e41194ae124b | | tenant_id | e40fa60181524f9f9ee7aa1038748f08 | +---------------------+--------------------------------------+ ping 172.24.4.227 PING 172.24.4.227 (172.24.4.227) 56(84) bytes of data. 64 bytes from 172.24.4.227: icmp_req=2 ttl=64 time=0.152 ms 64 bytes from 172.24.4.227: icmp_req=3 ttl=64 time=0.049 ms