Allow to use parent input more than once in CR

Change-Id: I740ec54e62c2deb4607ca357f0b7e3dbf7cb575c
This commit is contained in:
Łukasz Oleś 2016-04-27 14:02:12 +02:00
parent 5ef0be35ca
commit 51869a2057
2 changed files with 18 additions and 2 deletions

View File

@ -252,8 +252,10 @@ def update_inputs(child, inputs):
connections, assignments, computable = parse_inputs(inputs) connections, assignments, computable = parse_inputs(inputs)
parents = defaultdict(lambda: defaultdict(dict)) parents = defaultdict(lambda: defaultdict(dict))
for c in connections: for c in connections:
mapping = {c['parent_input']: c['child_input']} if not parents[c['parent']]['mapping'].get(c['parent_input']):
parents[c['parent']]['mapping'].update(mapping) parents[c['parent']]['mapping'][c['parent_input']] = []
mapping = parents[c['parent']]['mapping']
mapping[c['parent_input']].append(c['child_input'])
if parents[c['parent']].get('events', None) is None: if parents[c['parent']].get('events', None) is None:
parents[c['parent']]['events'] = c['events'] parents[c['parent']]['events'] = c['events']

View File

@ -174,6 +174,20 @@ def test_add_list_values(mocker, resources):
assert mocked_signals.call_count == 1 assert mocked_signals.call_count == 1
def test_double_parent_input(mocker, resources):
mocked_signals = mocker.patch(
'solar.core.resource.resource.Resource.connect_with_events')
args = {'ip': 'node1::ip',
'servers': ['server1', 'server2'],
'alias': 'ser1',
'private_ip': 'node1::ip'
}
cr.update_inputs('service1', args)
call_args = mocked_signals.call_args[0][1]
assert 'ip' in call_args['ip']
assert 'private_ip' in call_args['ip']
def test_parse_connection(): def test_parse_connection():
correct_connection = {'child_input': 'ip', correct_connection = {'child_input': 'ip',
'parent': 'node1', 'parent': 'node1',