Jump to: navigation, search

Difference between revisions of "Neutron/TrunkPort"

(API-CLI mapping)
(CLI usage example)
Line 78: Line 78:
  
 
<pre>
 
<pre>
# Legacy ports.
+
openstack network create net0
neutron port-create net0 --name port0
+
openstack network create net1
neutron port-create net1 --name port1
+
openstack network create net2
 +
openstack subnet create --network net0 --subnet-range 10.0.4.0/24 subnet0
 +
openstack subnet create --network net1 --subnet-range 10.0.5.0/24 subnet1
 +
openstack subnet create --network net2 --subnet-range 10.0.6.0/24 subnet2
 +
openstack port create --network net0 port0 # will become a parent port
 +
openstack port create --network net1 port1 # will become a child port: at trunk create time
 +
openstack port create --network net2 port2 # will become a child port: later
  
# Turn port0 into a trunk port, add port1 as a subport to it.
+
openstack network trunk create --parent-port port0 trunk0
neutron trunk-create --port-id PORT0-UUID --subport PORT1-UUID,vlan,101 --name trunk0
+
openstack network trunk create --parent-port port0 trunk1 # error expected: Port UUID is currently in use and is not eligible for use as a parent port.
 +
openstack network trunk list
 +
openstack network trunk show trunk0
 +
openstack network trunk delete trunk0
  
# The only vNIC in your instance corresponds to the legacy port (turned into a trunk),
+
openstack network trunk create --parent-port port0 --subport port=port1,segmentation-type=vlan,segmentation-id=101 trunk0
# so boot your instance with the trunk port given. Do not add subports as NICs to 'nova boot'.
+
openstack network trunk list
 +
openstack network trunk show trunk0
 +
openstack network subport list --trunk trunk0
 +
 
 +
# The only vNIC in your instance corresponds to the parent port, so boot your instance with the parent port given.
 +
# Do not add child ports as NICs to 'nova boot / openstack server create'.
 
# Use an image with support for vlan interfaces. CirrOS will not cut it.
 
# Use an image with support for vlan interfaces. CirrOS will not cut it.
 
# eg: sudo ip link add ... type vlan ...
 
# eg: sudo ip link add ... type vlan ...
nova boot ... --image VLAN-CAPABLE-IMAGE --nic port-id=PORT0-UUID --poll vm0
+
#openstack server create --flavor m1.nano --image VLAN-CAPABLE-IMAGE --nic port-id=port0 --wait vm0
  
 
# The typical cloud image will auto-configure eth0 only and not the vlan interfaces (eth0.VLAN-ID).
 
# The typical cloud image will auto-configure eth0 only and not the vlan interfaces (eth0.VLAN-ID).
 
ssh VM0-ADDRESS sudo ip link add link eth0 name eth0.101 type vlan id 101
 
ssh VM0-ADDRESS sudo ip link add link eth0 name eth0.101 type vlan id 101
  
# Further subports can be created at any time, including after boot.
+
openstack network trunk set --subport port=port1,segmentation-type=vlan,segmentation-id=999 trunk0 # error expected: Failed to add subports to trunk 'trunk0': Port UUID is in use by another trunk.
neutron port-create net2 --name port2
+
openstack network trunk set --subport port=port2,segmentation-type=vlan,segmentation-id=101 trunk0 # error expected: Failed to add subports to trunk 'trunk0': segmentation_type vlan and segmentation_id 101 already in use on trunk UUID.
neutron trunk-subport-add TRUNK0-UUID PORT2-UUID,vlan,102
+
openstack network trunk set --subport port=port2,segmentation-type=vlan,segmentation-id=102 trunk0
 +
openstack network trunk show trunk0
  
# Again you need to bring your subport vlan interfaces up.
+
# Again you need to bring your child port vlan interfaces up.
 
ssh VM0-ADDRESS sudo ip link add link eth0 name eth0.102 type vlan id 102
 
ssh VM0-ADDRESS sudo ip link add link eth0 name eth0.102 type vlan id 102
  
# Subports can be deleted at runtime too.
 
 
ssh VM0-ADDRESS sudo ip link delete dev eth0.102
 
ssh VM0-ADDRESS sudo ip link delete dev eth0.102
neutron trunk-subport-delete PORT2-UUID
+
openstack network trunk unset --subport port2 trunk0
neutron port-delete port2
+
 
 +
openstack port delete port0 # error expected: FIXME HttpException: Conflict
 +
openstack port delete port1 # error expected: FIXME HttpException: Conflict
  
# Delete stuff when you're all done.
+
# clean up
neutron trunk-delete TRUNK0-UUID
+
openstack server list | awk '/ vm[0-9]+ / { print $2 }' | xargs -r openstack server delete
nova delete vm0
+
openstack network trunk list | awk '/ trunk[0-9]+ / { print $2 }' | xargs -r openstack network trunk delete
neutron port-delete port1
+
openstack port list | awk '/ port[0-9]+ / { print $2 }' | xargs -r openstack port delete
neutron port-delete port0
+
openstack network list | awk '/ net[0-9]+ / { print $2 }' | xargs -r openstack network delete
 
</pre>
 
</pre>
  

Revision as of 15:20, 17 August 2016

This page mostly describes v4 of the trunk port spec, however it is slightly out-of-date.

Overview

Neutron extension to access lots of neutron networks over a single vNIC as tagged/encapsulated traffic.

API

API-CLI mapping

CLI verb (as in the spec) CLI verb (openstack client) HTTP method URL
trunk-create network trunk create POST /v2.0/trunks
trunk-delete network trunk delete DELETE /v2.0/trunks/$trunk_id
trunk-list network trunk list GET /v2.0/trunks
trunk-show network trunk show GET /v2.0/trunks/$trunk_id
trunk-subport-add network trunk set PUT /v2.0/trunks/$trunk_id/add_subports
trunk-subport-delete network trunk unset PUT /v2.0/trunks/$trunk_id/remove_subports
trunk-subport-list network subport list GET /v2.0/trunks/$trunk_id/get_subports

Network dump

Dump of the Work-in-Progress API: https://etherpad.openstack.org/p/trunk-api-dump-2016-07-20

other

FIXME Special values to legacy port attributes, eg: device_owner, device_id

FIXME Ignored and/or problematic neutron port attributes for subports:

attribute name reason
mac_address no mechanism to tell the guest os/app what mac to use
binding:* FIXME

CLI usage example

openstack network create net0
openstack network create net1
openstack network create net2
openstack subnet create --network net0 --subnet-range 10.0.4.0/24 subnet0
openstack subnet create --network net1 --subnet-range 10.0.5.0/24 subnet1
openstack subnet create --network net2 --subnet-range 10.0.6.0/24 subnet2
openstack port create --network net0 port0 # will become a parent port
openstack port create --network net1 port1 # will become a child port: at trunk create time
openstack port create --network net2 port2 # will become a child port: later

openstack network trunk create --parent-port port0 trunk0
openstack network trunk create --parent-port port0 trunk1 # error expected: Port UUID is currently in use and is not eligible for use as a parent port.
openstack network trunk list
openstack network trunk show trunk0
openstack network trunk delete trunk0

openstack network trunk create --parent-port port0 --subport port=port1,segmentation-type=vlan,segmentation-id=101 trunk0
openstack network trunk list
openstack network trunk show trunk0
openstack network subport list --trunk trunk0

# The only vNIC in your instance corresponds to the parent port, so boot your instance with the parent port given.
# Do not add child ports as NICs to 'nova boot / openstack server create'.
# Use an image with support for vlan interfaces. CirrOS will not cut it.
# eg: sudo ip link add ... type vlan ...
#openstack server create --flavor m1.nano --image VLAN-CAPABLE-IMAGE --nic port-id=port0 --wait vm0

# The typical cloud image will auto-configure eth0 only and not the vlan interfaces (eth0.VLAN-ID).
ssh VM0-ADDRESS sudo ip link add link eth0 name eth0.101 type vlan id 101

openstack network trunk set --subport port=port1,segmentation-type=vlan,segmentation-id=999 trunk0 # error expected: Failed to add subports to trunk 'trunk0': Port UUID is in use by another trunk.
openstack network trunk set --subport port=port2,segmentation-type=vlan,segmentation-id=101 trunk0 # error expected: Failed to add subports to trunk 'trunk0': segmentation_type vlan and segmentation_id 101 already in use on trunk UUID.
openstack network trunk set --subport port=port2,segmentation-type=vlan,segmentation-id=102 trunk0
openstack network trunk show trunk0

# Again you need to bring your child port vlan interfaces up.
ssh VM0-ADDRESS sudo ip link add link eth0 name eth0.102 type vlan id 102

ssh VM0-ADDRESS sudo ip link delete dev eth0.102
openstack network trunk unset --subport port2 trunk0

openstack port delete port0 # error expected: FIXME HttpException: Conflict
openstack port delete port1 # error expected: FIXME HttpException: Conflict

# clean up
openstack server list | awk '/ vm[0-9]+ / { print $2 }' | xargs -r openstack server delete
openstack network trunk list | awk '/ trunk[0-9]+ / { print $2 }' | xargs -r openstack network trunk delete
openstack port list | awk '/ port[0-9]+ / { print $2 }' | xargs -r openstack port delete
openstack network list | awk '/ net[0-9]+ / { print $2 }' | xargs -r openstack network delete

openvswitch vlan model

FIXME draw picture of wiring of tap interfaces, trunk and integration bridges

https://etherpad.openstack.org/p/trunk-bridge-tagged-patch-ovs-firewall-experiment

Drawings

Links