コード例 #1
0
def traverse(hc, stack_id, sc_list):
    global _HEAT_SOFTWARE_CONFIG_TYPE
    res_map = {}

    stack_id = stack_id.split('/')[0]

    resources = hc.resources.list(stack_id)
    for resource in resources:
        if 'resources' not in res_map:
            res_map['resources'] = {}

        log.debug("resource: type: %s" % resource.resource_type)

        res_info = {}
        nested_id = utils.resource_nested_identifier(resource)
        if nested_id:
            nested_id = nested_id.split('/')[0]
            nested_res_list = traverse(hc, nested_id, sc_list)
            res_info.update({'stacks': {nested_id: nested_res_list}})

        res_info.update({'type': resource.resource_type})
        if resource.resource_type == _HEAT_SOFTWARE_CONFIG_TYPE:
            for sc in sc_list:
                if resource.resource_name in sc.name:
                    res_info.update({'software_config': sc.name})
                    res_info.update({'group': sc.group})
                    break

        res_map['resources'].update({resource.resource_name: res_info})

    return res_map
コード例 #2
0
 def test_resource_nested_identifier_none(self):
     rsrc_info = {'resource_name': 'aresource',
                  'links': [{'href': u'http://foo/name/id/resources/0',
                             'rel': u'self'},
                            {'href': u'http://foo/name/id',
                             'rel': u'stack'}]}
     rsrc = hc_res.Resource(manager=None, info=rsrc_info)
     self.assertIsNone(utils.resource_nested_identifier(rsrc))
コード例 #3
0
 def test_resource_nested_identifier_none(self):
     rsrc_info = {'resource_name': 'aresource',
                  'links': [{'href': u'http://foo/name/id/resources/0',
                             'rel': u'self'},
                            {'href': u'http://foo/name/id',
                             'rel': u'stack'}]}
     rsrc = hc_res.Resource(manager=None, info=rsrc_info)
     self.assertIsNone(utils.resource_nested_identifier(rsrc))
コード例 #4
0
def _get_nested_ids(hc, stack_id):
    nested_ids = []
    try:
        resources = hc.resources.list(stack_id=stack_id)
    except exc.HTTPNotFound:
        raise exc.CommandError(_('Stack not found: %s') % stack_id)
    for r in resources:
        nested_id = utils.resource_nested_identifier(r)
        if nested_id:
            nested_ids.append(nested_id)
    return nested_ids
コード例 #5
0
def _get_nested_ids(hc, stack_id):
    nested_ids = []
    try:
        resources = hc.resources.list(stack_id=stack_id)
    except exc.HTTPNotFound:
        raise exc.CommandError(_('Stack not found: %s') % stack_id)
    for r in resources:
        nested_id = utils.resource_nested_identifier(r)
        if nested_id:
            nested_ids.append(nested_id)
    return nested_ids