-
Notifications
You must be signed in to change notification settings - Fork 35
VLAN application examples
This information contains VLAN application examples, including verification. cps_config_vlan.py
contains examples for adding and deleting VLANs, adding and deleting ports to and from VLANs, and so on (see cps_config_vlan.py).
NOTE: VLAN refers to an NPU VLAN object which is modeled as a Linux bridge.
1. Import the CPS and CPS object Python library.
import cps_object
import cps
2. Create a CPS object.
cps_obj = cps_object.CPSObject('dell-base-if-cmn/if/interfaces/interface')
3. Define the VLAN ID.
VLAN_ID=100
cps_obj.add_attr("base-if-vlan/if/interfaces/interface/id",VLAN_ID)
4. Define the VLAN type with an L2 or L2 VLAN ID.
cps_obj.add_attr('if/interfaces/interface/type','ianaift:l2vlan')
5. Associate a create operation with the CPS object to create a new VLAN.
cps_update = {'change':cps_obj.get(),'operation': 'create'}
6. Add the CPS operation and object pair to a new CPS transaction.
transaction = cps.transaction([cps_update])
7. Verify the return value.
if not transaction:
raise RuntimeError ("Error creating Vlan")
See create_vlan.py to view the Python application example.
# cps_get_oid.py dell-opx-if-cmn/if/interfaces/interface if/interfaces/interface/type=ianaift:l2vlan
Key: 1.19.44.2883617.2883612.2883613.
dell-base-if-cmn/if/interfaces/interface/if-index = 40
dell-if/if/interfaces/interface/phys-address =base-if-vlan/if/interfaces/interface/id = 100
if/interfaces/interface/name = br100dell-if/if/interfaces/interface/learning-mode = 1
if/interfaces/interface/enabled = 0
Key: 1.19.44.2883617.2883612.2883613.
dell-base-if-cmn/if/interfaces/interface/if-index = 3
dell-if/if/interfaces/interface/phys-address = 90:b1:1c:f4:ab:ed
base-if-vlan/if/interfaces/interface/id = 0
if/interfaces/interface/name = docker0
dell-if/if/interfaces/interface/learning-mode = 1
if/interfaces/interface/enabled = 0
NOTE: OPX allocates an
ifindex
for each VLAN created. Further CPS set and get operations can useifindex
as the key.
$ brctl show
bridge name bridge id STP enabled interfaces
br100
1. Import the CPS and CPS object Python library.
import cps
import cps_object
2. Create a CPS object.
cps_obj = cps_object.CPSObject('dell-base-if-cmn/if/interfaces/interface')
3. Define the VLAN interface name.
VLAN_IF_NAME='br100'
cps_obj.add_attr('if/interfaces/interface/name',VLAN_IF_NAME)
4. Define the untagged port to add to the VLAN.
if_port_list=['e101-001-0']
cps_obj.add_attr('dell-if/if/interfaces/interface/untagged-ports',if_port_list)
5. Associate a set operation with the CPS object to modify the property of an existing VLAN.
cps_update = {'change':cps_obj.get(),'operation': 'set'}
6. Add the CPS operation and object pair to a new CPS transaction.
transaction = cps.transaction([cps_update])
7. Verify the return value.
if not transaction:
raise RuntimeError ("Error adding ports to Vlan")
See add_vlan_port.py to view the Python application example.
# cps_get_oid.py dell-opx-if-cmn/if/interfaces/interface if/interfaces/interface/type=ianaift:l2vlan
Key: 1.19.44.2883617.2883612.2883613.
dell-base-if-cmn/if/interfaces/interface/if-index = 43
dell-if/if/interfaces/interface/phys-address =
dell-if/if/interfaces/interface/untagged-ports = e101-003-0,e101-002-0,e101-001-0
base-if-vlan/if/interfaces/interface/id = 100
if/interfaces/interface/name = br100
dell-if/if/interfaces/interface/learning-mode = 1
if/interfaces/interface/enabled = 0
Key: 1.19.44.2883617.2883612.2883613.
dell-base-if-cmn/if/interfaces/interface/if-index = 3
dell-if/if/interfaces/interface/phys-address = 90:b1:1c:f4:ab:ed
base-if-vlan/if/interfaces/interface/id = 0
if/interfaces/interface/name = docker0
dell-if/if/interfaces/interface/learning-mode = 1
if/interfaces/interface/enabled = 0
$ brctl show
bridge name bridge id STP enabled interfaces
br100 8000.90b11cf4abee no e101-001-0
e101-002-0
e101-003-0
1. Import the CPS and CPS object Python library.
import cps
import cps_object
2. Create a CPS object.
cps_obj = cps_object.CPSObject('dell-base-if-cmn/if/interfaces/interface')
3. Define the VLAN interface name.
VLAN_IF_NAME='br100'
cps_obj.add_attr('if/interfaces/interface/name',VLAN_IF_NAME)
4. Define the untagged port to be included in the VLAN (all other ports will be deleted from the VLAN).
if_port_list=['e101-002-0']
cps_obj.add_attr('dell-if/if/interfaces/interface/untagged-ports',if_port_list)
5. Associate a set operation with the CPS object to modify the property of an existing VLAN.
cps_update = {'change':cps_obj.get(),'operation': 'set'}
6. Add the CPS operation and object pair to a new CPS transaction.
transaction = cps.transaction([cps_update])
7. Verify the return value.
if not transaction:
raise RuntimeError ("Error in deleting ports to Vlan")
print "successful"
See delete_ports_vlan.py to view the Python application example.
# cps_get_oid.py dell-base-if-cmn/if/interfaces/interface if/interfaces/interface/type=ianaift:l2vlan
Key: 1.19.44.2883617.2883612.2883613.
dell-base-if-cmn/if/interfaces/interface/if-index = 47
dell-if/if/interfaces/interface/phys-address =
dell-if/if/interfaces/interface/untagged-ports = e101-002-0
base-if-vlan/if/interfaces/interface/id = 100
if/interfaces/interface/name = br100
dell-if/if/interfaces/interface/learning-mode = 1
if/interfaces/interface/enabled = 0
Key: 1.19.44.2883617.2883612.2883613.
dell-base-if-cmn/if/interfaces/interface/if-index = 3
dell-if/if/interfaces/interface/phys-address = 90:b1:1c:f4:ab:ed
base-if-vlan/if/interfaces/interface/id = 0
if/interfaces/interface/name = docker0
dell-if/if/interfaces/interface/learning-mode = 1
if/interfaces/interface/enabled = 0
$ brctl show
bridge name bridge id STP enabled interfaces
br100 8000.000000000000 no e101-002-0
1. Import the CPS and CPS object Python library.
import cps
import cps_object
2. Create a CPS object.
cps_obj = cps_object.CPSObject('dell-base-if-cmn/if/interfaces/interface')
3. Define the name of the VLAN interface to delete.
VLAN_IF_NAME='br100'
cps_obj.add_attr('if/interfaces/interface/name',VLAN_IF_NAME)
4. Associate a delete operation with the CPS object to delete an existing VLAN.
cps_update = {'change':cps_obj.get(),'operation': 'delete'}
5. Add the CPS operation and object pair to a new CPS transaction.
transaction = cps.transaction([cps_update])
6. Verify the return value.
if not transaction:
raise RuntimeError ("Error in deleting Vlan")
print "successful"
See delete_vlan.py to view the Python application example.
# cps_get_oid.py dell-base-if-cmn/if/interfaces/interface if/interfaces/interface/type=ianaift:l2vlan
Key: 1.19.44.2883617.2883612.2883613.
dell-base-if-cmn/if/interfaces/interface/if-index = 3
dell-if/if/interfaces/interface/phys-address = 90:b1:1c:f4:ab:ed
base-if-vlan/if/interfaces/interface/id = 0
if/interfaces/interface/name = docker0
dell-if/if/interfaces/interface/learning-mode = 1
if/interfaces/interface/enabled = 0
$ brctl show br100
© 2019 OpenSwitch project. All information is contributed to and made available by OPX under the Creative Commons Attribution 4.0 International License (available at http://creativecommons.org/licenses/by/4.0/).
- Home
- System overview
- Software releases
- Hardware support
- FAQs
- Install
- Build
- Configure
- Develop
- Administer
- Troubleshoot
- Software compatibility
- Contribute
- DevOps
- Join