Merge "Parse stack output value for bay"
This commit is contained in:
commit
bbb4c7f0b5
@ -83,6 +83,22 @@ def _create_stack(ctxt, osc, bay):
|
|||||||
return created_stack
|
return created_stack
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_stack_outputs(outputs):
|
||||||
|
parsed_outputs = {}
|
||||||
|
|
||||||
|
for output in outputs:
|
||||||
|
output_key = output["output_key"]
|
||||||
|
output_value = output["output_value"]
|
||||||
|
if output_key == "kube_minions_external":
|
||||||
|
parsed_outputs["kube_minions_external"] = output_value
|
||||||
|
if output_key == "kube_minions":
|
||||||
|
parsed_outputs["kube_minions"] = output_value
|
||||||
|
if output_key == "kube_master":
|
||||||
|
parsed_outputs["kube_master"] = output_value
|
||||||
|
|
||||||
|
return parsed_outputs
|
||||||
|
|
||||||
|
|
||||||
class Handler(object):
|
class Handler(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Handler, self).__init__()
|
super(Handler, self).__init__()
|
||||||
@ -104,10 +120,11 @@ class Handler(object):
|
|||||||
def poll_and_check():
|
def poll_and_check():
|
||||||
stack = osc.heat().stacks.get(bay.stack_id)
|
stack = osc.heat().stacks.get(bay.stack_id)
|
||||||
if stack.stack_status == 'CREATE_COMPLETE':
|
if stack.stack_status == 'CREATE_COMPLETE':
|
||||||
master_address = stack.outputs[0]['output_value']
|
parsed_outputs = _parse_stack_outputs(stack.outputs)
|
||||||
minion_addresses = stack.outputs[2]['output_value']
|
master_address = parsed_outputs["kube_master"]
|
||||||
|
minion_address = parsed_outputs["kube_minions_external"]
|
||||||
bay.master_address = master_address
|
bay.master_address = master_address
|
||||||
bay.minions_address = minion_addresses
|
bay.minions_address = minion_address
|
||||||
bay.save()
|
bay.save()
|
||||||
raise loopingcall.LoopingCallDone()
|
raise loopingcall.LoopingCallDone()
|
||||||
# poll_and_check is detached and polling long time to check status,
|
# poll_and_check is detached and polling long time to check status,
|
||||||
|
@ -106,6 +106,37 @@ class TestBayK8sHeat(base.BaseTestCase):
|
|||||||
}
|
}
|
||||||
self.assertEqual(expected, bay_definition)
|
self.assertEqual(expected, bay_definition)
|
||||||
|
|
||||||
|
def test_parse_stack_outputs(self):
|
||||||
|
expected_master_address = 'master_address'
|
||||||
|
expected_minion_address = ['minion', 'address']
|
||||||
|
expected_minion_external_address = ['ex_minion', 'address']
|
||||||
|
expected_return_value = {
|
||||||
|
'kube_master': expected_master_address,
|
||||||
|
'kube_minions': expected_minion_address,
|
||||||
|
'kube_minions_external': expected_minion_external_address
|
||||||
|
}
|
||||||
|
|
||||||
|
outputs = [
|
||||||
|
{
|
||||||
|
"output_value": expected_minion_external_address,
|
||||||
|
"description": "No description given",
|
||||||
|
"output_key": "kube_minions_external"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"output_value": expected_minion_address,
|
||||||
|
"description": "No description given",
|
||||||
|
"output_key": "kube_minions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"output_value": expected_master_address,
|
||||||
|
"description": "No description given",
|
||||||
|
"output_key": "kube_master"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
parsed_outputs = bay_k8s_heat._parse_stack_outputs(outputs)
|
||||||
|
self.assertEqual(expected_return_value, parsed_outputs)
|
||||||
|
|
||||||
@patch('heatclient.common.template_utils.get_template_contents')
|
@patch('heatclient.common.template_utils.get_template_contents')
|
||||||
@patch('magnum.objects.BayModel.get_by_uuid')
|
@patch('magnum.objects.BayModel.get_by_uuid')
|
||||||
@patch('magnum.conductor.handlers.bay_k8s_heat._extract_bay_definition')
|
@patch('magnum.conductor.handlers.bay_k8s_heat._extract_bay_definition')
|
||||||
|
Loading…
Reference in New Issue
Block a user