From: James Arendt Date: Fri, 28 Aug 2015 23:33:44 +0000 (-0700) Subject: Make Neutron service flavor save service_type X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c43cc3eb20101b2d2b19344690fed9892383621b;p=openstack-build%2Fneutron-build.git Make Neutron service flavor save service_type 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 --- diff --git a/neutron/db/flavors_db.py b/neutron/db/flavors_db.py index 8dc3f2edf..e6c3bed8c 100644 --- a/neutron/db/flavors_db.py +++ b/neutron/db/flavors_db.py @@ -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) diff --git a/neutron/tests/unit/extensions/test_flavors.py b/neutron/tests/unit/extensions/test_flavors.py index 8de2cf5ca..be2b92e84 100644 --- a/neutron/tests/unit/extensions/test_flavors.py +++ b/neutron/tests/unit/extensions/test_flavors.py @@ -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()