]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove unused database table from Cisco plugin
authorHenryGessau <gessau@cisco.com>
Wed, 3 Jul 2013 21:05:35 +0000 (17:05 -0400)
committerHenryGessau <gessau@cisco.com>
Wed, 3 Jul 2013 21:19:17 +0000 (17:19 -0400)
Fixes: bug #1197053
Change-Id: If0a9198046498cb559353dc9f1b3820b5e01cb7c

quantum/db/migration/alembic_migrations/versions/b7a8863760e_rm_cisco_vlan_bindin.py [new file with mode: 0644]
quantum/plugins/cisco/db/network_db_v2.py
quantum/plugins/cisco/db/network_models_v2.py
quantum/plugins/cisco/nexus/cisco_nexus_plugin_v2.py

diff --git a/quantum/db/migration/alembic_migrations/versions/b7a8863760e_rm_cisco_vlan_bindin.py b/quantum/db/migration/alembic_migrations/versions/b7a8863760e_rm_cisco_vlan_bindin.py
new file mode 100644 (file)
index 0000000..05a1b1f
--- /dev/null
@@ -0,0 +1,60 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+#
+# Copyright 2013 OpenStack Foundation
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+#
+
+"""Remove cisco_vlan_bindings table
+
+Revision ID: b7a8863760e
+Revises: 3cabb850f4a5
+Create Date: 2013-07-03 19:15:19.143175
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'b7a8863760e'
+down_revision = '3cabb850f4a5'
+
+# Change to ['*'] if this migration applies to all plugins
+
+migration_for_plugins = [
+    'quantum.plugins.cisco.network_plugin.PluginV2'
+]
+
+from alembic import op
+import sqlalchemy as sa
+
+
+from quantum.db import migration
+
+
+def upgrade(active_plugin=None, options=None):
+    if not migration.should_run(active_plugin, migration_for_plugins):
+        return
+
+    op.drop_table('cisco_vlan_bindings')
+
+
+def downgrade(active_plugin=None, options=None):
+    if not migration.should_run(active_plugin, migration_for_plugins):
+        return
+
+    op.create_table(
+        'cisco_vlan_bindings',
+        sa.Column('vlan_id', sa.Integer(display_width=11), nullable=False),
+        sa.Column('vlan_name', sa.String(length=255), nullable=True),
+        sa.Column('network_id', sa.String(length=255), nullable=False),
+        sa.PrimaryKeyConstraint('vlan_id')
+    )
index 3790c87ec1eea87d9edc10d6868d29fa6f1b424f..41d0b68cd7b3cac55d850c19375343958210b750 100644 (file)
@@ -18,7 +18,6 @@
 
 from sqlalchemy.orm import exc
 
-from quantum.common import exceptions as q_exc
 from quantum.db import api as db
 from quantum.openstack.common import log as logging
 from quantum.plugins.cisco.common import cisco_exceptions as c_exc
@@ -126,73 +125,6 @@ def get_all_vlanids_used():
             filter_by(vlan_used=True).all())
 
 
-def get_all_vlan_bindings():
-    """Lists all the vlan to network associations."""
-    LOG.debug(_("get_all_vlan_bindings() called"))
-    session = db.get_session()
-    return session.query(network_models_v2.Vlan_Binding).all()
-
-
-def get_vlan_binding(netid):
-    """Lists the vlan given a network_id."""
-    LOG.debug(_("get_vlan_binding() called"))
-    session = db.get_session()
-    try:
-        binding = (session.query(network_models_v2.Vlan_Binding).
-                   filter_by(network_id=netid).one())
-        return binding
-    except exc.NoResultFound:
-        raise q_exc.NetworkNotFound(net_id=netid)
-
-
-def add_vlan_binding(vlanid, vlanname, netid):
-    """Adds a vlan to network association."""
-    LOG.debug(_("add_vlan_binding() called"))
-    session = db.get_session()
-    try:
-        binding = (session.query(network_models_v2.Vlan_Binding).
-                   filter_by(vlan_id=vlanid).one())
-        raise c_exc.NetworkVlanBindingAlreadyExists(vlan_id=vlanid,
-                                                    network_id=netid)
-    except exc.NoResultFound:
-        binding = network_models_v2.Vlan_Binding(vlanid, vlanname, netid)
-        session.add(binding)
-        session.flush()
-        return binding
-
-
-def remove_vlan_binding(netid):
-    """Removes a vlan to network association."""
-    LOG.debug(_("remove_vlan_binding() called"))
-    session = db.get_session()
-    try:
-        binding = (session.query(network_models_v2.Vlan_Binding).
-                   filter_by(network_id=netid).one())
-        session.delete(binding)
-        session.flush()
-        return binding
-    except exc.NoResultFound:
-        pass
-
-
-def update_vlan_binding(netid, newvlanid=None, newvlanname=None):
-    """Updates a vlan to network association."""
-    LOG.debug(_("update_vlan_binding() called"))
-    session = db.get_session()
-    try:
-        binding = (session.query(network_models_v2.Vlan_Binding).
-                   filter_by(network_id=netid).one())
-        if newvlanid:
-            binding["vlan_id"] = newvlanid
-        if newvlanname:
-            binding["vlan_name"] = newvlanname
-        session.merge(binding)
-        session.flush()
-        return binding
-    except exc.NoResultFound:
-        raise q_exc.NetworkNotFound(net_id=netid)
-
-
 def get_all_qoss(tenant_id):
     """Lists all the qos to tenant associations."""
     LOG.debug(_("get_all_qoss() called"))
index a70863e7f0f1d531177d39eeb6c9d855bec0780c..60e4b216198e4b56a520a74b01d9ee75cc349c99 100644 (file)
@@ -83,26 +83,6 @@ class VlanID(model_base.BASEV2, L2NetworkBase):
         return "<VlanID(%d,%s)>" % (self.vlan_id, self.vlan_used)
 
 
-class Vlan_Binding(model_base.BASEV2, L2NetworkBase):
-    """Represents a binding of vlan_id to network_id."""
-    __tablename__ = 'cisco_vlan_bindings'
-
-    vlan_id = Column(Integer, primary_key=True)
-    vlan_name = Column(String(255))
-    network_id = Column(String(255),
-                        nullable=False)
-
-    def __init__(self, vlan_id, vlan_name, network_id):
-        self.vlan_id = vlan_id
-        self.vlan_name = vlan_name
-        self.network_id = network_id
-
-    def __repr__(self):
-        return "<VlanBinding(%d,%s,%s)>" % (self.vlan_id,
-                                            self.vlan_name,
-                                            self.network_id)
-
-
 class QoS(model_base.BASEV2, L2NetworkBase):
     """Represents QoS for a tenant."""
 
index f2acd95247155d9ef6d1a5709d621fd86fd5731d..568a0e8b64405e5db26f91044d41c9822aa15129 100644 (file)
@@ -33,7 +33,6 @@ from quantum.plugins.cisco.common import cisco_constants as const
 from quantum.plugins.cisco.common import cisco_credentials_v2 as cred
 from quantum.plugins.cisco.common import cisco_exceptions as cisco_exc
 from quantum.plugins.cisco.common import config as conf
-from quantum.plugins.cisco.db import network_db_v2 as cdb
 from quantum.plugins.cisco.db import nexus_db_v2 as nxos_db
 from quantum.plugins.cisco.l2device_plugin_base import L2DevicePluginBase
 
@@ -347,12 +346,6 @@ class NexusPlugin(L2DevicePluginBase):
         """
         LOG.debug(_("NexusPlugin:unplug_interface() called"))
 
-    def _get_vlan_id_for_network(self, tenant_id, network_id, context,
-                                 base_plugin_ref):
-        """Obtain the VLAN ID given the Network ID."""
-        vlan = cdb.get_vlan_binding(network_id)
-        return vlan.vlan_id
-
     def _get_network(self, tenant_id, network_id, context, base_plugin_ref):
         """Get the Network ID."""
         network = base_plugin_ref._get_network(context, network_id)