Network type value constants are defined in multiple places

Bug #1196170 reported by Henry Gessau
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Wishlist
Justin Hammond

Bug Description

Network type values are defined all over the place.

For example, TYPE_FLAT ...

./quantum/plugins/mlnx/common/constants.py:23:TYPE_FLAT = 'flat'
./quantum/plugins/linuxbridge/common/constants.py:24:TYPE_FLAT = 'flat'
./quantum/plugins/openvswitch/common/constants.py:23:TYPE_FLAT = 'flat'
./quantum/plugins/hyperv/common/constants.py:27:TYPE_FLAT = 'flat'
./quantum/plugins/ml2/drivers/type_flat.py:26:TYPE_FLAT = 'flat'

It would be better to define the network types in one place and have all the plugins import them.

Before ML2 this was not really an issue since only one plugin was loaded. (Except for the Cisco plugin which can load multiple sub-plugins.) In ML2 with multiple mechanism drivers we should ensure that they all use the same network type values.

Henry Gessau (gessau)
Changed in neutron:
assignee: nobody → Henry Gessau (gessau)
Changed in neutron:
importance: Undecided → Wishlist
status: New → Triaged
tags: added: low-hanging-fruit neutron-core
Revision history for this message
James Kyle (jkyle) wrote :

Seems like a good place for this would be neutron/common/constansts.py.

Revision history for this message
Hirofumi Ichihara (ichihara-hirofumi) wrote :

I'm sorry. I missed control and I cannot restore old status.

Changed in neutron:
status: Triaged → Confirmed
Changed in neutron:
assignee: Henry Gessau (gessau) → Justin Hammond (justin-hammond)
status: Confirmed → In Progress
Revision history for this message
Justin Hammond (justin-hammond) wrote :

In addition to TYPE_FLAT there are many other constants defined for 'flat'

Example:
./nicira/dbexts/nicira_networkgw_db.py: mapping_info['segmentation_type'] = 'flat'
./nicira/dbexts/nicira_networkgw_db.py: elif seg_type and seg_type.lower() == 'flat' and seg_id:
./nicira/NeutronPlugin.py: FLAT = 'flat'
./openvswitch/common/constants.py:TYPE_FLAT = 'flat'
./ml2/drivers/type_flat.py:TYPE_FLAT = 'flat'
./mlnx/common/constants.py:TYPE_FLAT = 'flat'
./linuxbridge/common/constants.py:TYPE_FLAT = 'flat'
./cisco/common/cisco_constants.py:NETWORK_TYPE_FLAT = 'flat'
./cisco/common/cisco_constants.py:NETWORK_TYPE_FLAT = 'flat'
./hyperv/common/constants.py:TYPE_FLAT = 'flat'

Should I change FLAT/NETWORK_TYPE_FLAT to TYPE_FLAT and then change the code to use the new constant.

Furthermore should I change:

/nicira/dbexts/nicira_networkgw_db.py: mapping_info['segmentation_type'] = 'flat'

To use TYPE_FLAT instead of the string.

While I am doing this should I hit up the other constants or make a new bug report for other constants I find?

Revision history for this message
Matt Dietz (cerberus) wrote :

My vote is this bug already encompasses all the various constants found. As for consolidating the various variables, I would actually perform a multistage bug fix, where you fix the TYPE_FLAT ones first, and then translate the NETWORK_TYPE_FLATs as a second stage. Smaller changes merge faster, regardless of complexity.

Revision history for this message
Justin Hammond (justin-hammond) wrote :

@cerberus: That makes sense and I will work it as such unless objections appear. Thanks for the guidance.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/44942

Changed in neutron:
assignee: Justin Hammond (justin-hammond) → Eugene Nikanorov (enikanorov)
Changed in neutron:
assignee: Eugene Nikanorov (enikanorov) → Justin Hammond (justin-hammond)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/44942
Committed: https://git.openstack.org/cgit/openstack/neutron/commit/?id=4cdccd69a45aec19d547c10f29f61359b69ad6c1
Submitter: Jenkins
Branch: master

commit 4cdccd69a45aec19d547c10f29f61359b69ad6c1
Author: Justin Hammond <email address hidden>
Date: Mon Sep 2 11:58:10 2013 -0500

    Update common network type consts to same origin

    This patch removes new definitions of common network type constants (TYPE_FLAT,
    TYPE_LOCAL, etc.) and modifies uses of aforementioned constants to a common
    place where constants are defined (neutron.plugins.common.constants). This
    patch does not change values that are equal in value but different in name:
    NETWORK_TYPE_FLAT vs TYPE_FLAT. A second changeset will be made to handle that
    case.

    Unit tests were modified as well when they referred to the constant.

    Finally, the ovs agent code refers to the OVS plugin constants directly and
    these had to be changed as well. A TODO flag was put in that file due to use
    of another plugin specific constant.

    Network types that were only defined in a single plugin, such as mellanox's
    infiniband (IB) network type was not carried over to the common constants file.

    Fixes-bug: #1196170

    Change-Id: Ib6bfc8275496a24bf247946d177c734b62ae44bb

Changed in neutron:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in neutron:
milestone: none → icehouse-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: icehouse-2 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.