Fix update service chain spec db
Config param names retrieved from nodes was getting duplicated
on a spec update. Clearing the field now before adding it back.
Change-Id: I8a12e1a841a8eccd10e9573e5da7cae6b15f2f2a
Closes-bug:1460186
(cherry picked from commit 0c5352aa85)
This commit is contained in:
@@ -307,9 +307,9 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
|
||||
|
||||
def _set_nodes_for_spec(self, context, spec_db, nodes_id_list,
|
||||
set_params=True):
|
||||
|
||||
if not nodes_id_list:
|
||||
spec_db.nodes = []
|
||||
spec_db.config_param_names = '[]'
|
||||
return
|
||||
with context.session.begin(subtransactions=True):
|
||||
# We will first check if the new list of nodes is valid
|
||||
@@ -327,6 +327,8 @@ class ServiceChainDbPlugin(schain.ServiceChainPluginBase,
|
||||
# Note that the list could be empty in which case we interpret
|
||||
# it as clearing existing nodes.
|
||||
spec_db.nodes = []
|
||||
if set_params:
|
||||
spec_db.config_param_names = '[]'
|
||||
for node_id in nodes_id_list:
|
||||
if set_params:
|
||||
sc_node = self.get_servicechain_node(context, node_id)
|
||||
|
||||
@@ -232,14 +232,23 @@ class TestGroupPolicyPluginGroupResources(
|
||||
collections.Counter(params_node_1 + params_node_2),
|
||||
collections.Counter(ast.literal_eval(spec['config_param_names'])))
|
||||
|
||||
# REVISIT(ivar): update verification fails because of bug/1460186
|
||||
|
||||
# Update the spec removing one node
|
||||
#self.update_servicechain_spec(spec['id'], nodes=[node1['id']],
|
||||
# expected_res_status=200)
|
||||
self.update_servicechain_spec(spec['id'], nodes=[node1['id']],
|
||||
expected_res_status=200)
|
||||
|
||||
#spec = self.show_servicechain_spec(spec['id'])['servicechain_spec']
|
||||
spec = self.show_servicechain_spec(spec['id'])['servicechain_spec']
|
||||
# Verify param names correspondence
|
||||
#self.assertEqual(
|
||||
# collections.Counter(params_node_1),
|
||||
# collections.Counter(ast.literal_eval(spec['config_param_names'])))
|
||||
self.assertEqual(
|
||||
collections.Counter(params_node_1),
|
||||
collections.Counter(ast.literal_eval(spec['config_param_names'])))
|
||||
|
||||
# Update the spec without modifying the node list
|
||||
self.update_servicechain_spec(spec['id'],
|
||||
name='new_name',
|
||||
expected_res_status=200)
|
||||
|
||||
spec = self.show_servicechain_spec(spec['id'])['servicechain_spec']
|
||||
# Verify param names correspondence
|
||||
self.assertEqual(
|
||||
collections.Counter(params_node_1),
|
||||
collections.Counter(ast.literal_eval(spec['config_param_names'])))
|
||||
|
||||
Reference in New Issue
Block a user