]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Make Neutron service flavor save service_type
authorJames Arendt <james.arendt@hp.com>
Fri, 28 Aug 2015 23:33:44 +0000 (16:33 -0700)
committerArmando Migliaccio <armamig@gmail.com>
Wed, 2 Sep 2015 16:44:43 +0000 (16:44 +0000)
While the service_type exists in the resource attributes and as
a database field for a Flavor, the creation dictionary did not
pass the value so the service_type was not being persisted
in the database nor returned.

Enhanced unit test to show problem.  Test fails on old code
to save or return the input service_type.

Change-Id: I4dba287f5972ecebd193d65e7f542dd0a65f055b
Closes-Bug: 1490063

neutron/db/flavors_db.py
neutron/tests/unit/extensions/test_flavors.py

index 8dc3f2edf3a962179609fe029e73dbe63079cbab..e6c3bed8cabd6814f0c2ea4d07a7a6ad15e49f3c 100644 (file)
@@ -151,6 +151,7 @@ class FlavorManager(common_db_mixin.CommonDbMixin):
         res = {'id': flavor_db['id'],
                'name': flavor_db['name'],
                'description': flavor_db['description'],
+               'service_type': flavor_db['service_type'],
                'enabled': flavor_db['enabled'],
                'service_profiles': []}
         if flavor_db.service_profiles:
@@ -190,6 +191,7 @@ class FlavorManager(common_db_mixin.CommonDbMixin):
             fl_db = Flavor(id=uuidutils.generate_uuid(),
                            name=fl['name'],
                            description=fl['description'],
+                           service_type=fl['service_type'],
                            enabled=fl['enabled'])
             context.session.add(fl_db)
         return self._make_flavor_dict(fl_db)
index 8de2cf5cacc3b14083a2e9753705cb8c3c570408..be2b92e84e372fd64c6fb7c4f0f5c179e47dc2a1 100644 (file)
@@ -306,6 +306,7 @@ class FlavorManagerTestCase(test_db_base_plugin_v2.NeutronDbPluginV2TestCase,
         res = self.ctx.session.query(flavors_db.Flavor).all()
         self.assertEqual(1, len(res))
         self.assertEqual('GOLD', res[0]['name'])
+        self.assertEqual(constants.LOADBALANCER, res[0]['service_type'])
 
     def test_update_flavor(self):
         fl, flavor = self._create_flavor()