]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Cleanup rule models and objects
authorJohn Schwarz <jschwarz@redhat.com>
Thu, 2 Jul 2015 09:40:11 +0000 (12:40 +0300)
committerIhar Hrachyshka <ihrachys@redhat.com>
Fri, 10 Jul 2015 17:59:48 +0000 (17:59 +0000)
- drop tenant_id for base and bandwidth_limit rules;
- added 'to_dict' function to convert objects into dicts.

Change-Id: I28167e356e70235304b166c997df52ca1b28f836

neutron/db/migration/alembic_migrations/versions/48153cb5f051_qos_db_changes.py
neutron/db/qos/models.py
neutron/objects/base.py
neutron/objects/qos/rule.py

index b0a020a89b09cb79b7328c76d6d1a321cf7a54df..d042ef83ff7b5fcb5b2563ce499d771139d04b51 100755 (executable)
@@ -65,9 +65,7 @@ def upgrade():
         sa.Column('qos_policy_id', sa.String(length=36),
                   sa.ForeignKey('qos_policies.id', ondelete='CASCADE'),
                   nullable=False),
-        sa.Column('type', sa.String(length=255)),
-        sa.Column('tenant_id', sa.String(length=attrs.TENANT_ID_MAX_LEN),
-                  index=True))
+        sa.Column('type', sa.String(length=255)))
 
     op.create_table(
         'qos_bandwidth_limit_rules',
index 90ffe08d33ef0a95a1c1ea7302871f1d6c9539c3..a34b9367b17c4183b885327bcb03de5313585ee1 100755 (executable)
@@ -61,7 +61,7 @@ class QosPortPolicyBinding(model_base.BASEV2):
                         primary_key=True)
 
 
-class QosRule(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
+class QosRule(model_base.BASEV2, models_v2.HasId):
     __tablename__ = 'qos_rules'
     type = sa.Column(sa.String(255))
     qos_policy_id = sa.Column(sa.String(36),
@@ -70,7 +70,7 @@ class QosRule(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant):
                               nullable=False)
 
 
-class QosBandwidthLimitRule(QosRule):
+class QosBandwidthLimitRule(model_base.BASEV2):
     __tablename__ = 'qos_bandwidth_limit_rules'
     max_kbps = sa.Column(sa.Integer)
     max_burst_kbps = sa.Column(sa.Integer)
index 57f785ea41fc24b845a51d40e1b48b72df77476d..86d4e5bbd7779da8f9d25bcbcdc8f76c16d46ea0 100644 (file)
@@ -36,6 +36,10 @@ class NeutronObject(obj_base.VersionedObject,
                 break
         self.obj_reset_changes()
 
+    # TODO(QoS): this should be revisited on how we plan to work with dicts
+    def to_dict(self):
+        return dict(self.items())
+
     @classmethod
     def get_by_id(cls, context, id):
         db_obj = db_api.get_object(context, cls.db_model, id)
index 55189c628647cecfbd9b638d840b3fb49721a5d6..53965194f5af7e874c4d5e3b0344f48120ceabaa 100644 (file)
@@ -31,7 +31,6 @@ class QosRule(base.NeutronObject):
 
     fields = {
         'id': obj_fields.UUIDField(),
-        'tenant_id': obj_fields.UUIDField(),
         'type': obj_fields.StringField(),
         'qos_policy_id': obj_fields.UUIDField()
     }