Esempio n. 1
0
    def filter(self, resource_manager, **params):
        """Query a set of resources."""
        m = self.resolve(resource_manager.resource_type)  # type: ChildTypeInfo

        parents = resource_manager.get_parent_manager()

        # Have to query separately for each parent's children.
        results = []
        for parent in parents.resources():
            try:
                vault_url = None
                if m.keyvault_child:
                    vault_url = generate_key_vault_url(parent['name'])
                subset = resource_manager.enumerate_resources(
                    parent, m, vault_url=vault_url, **params)

                if subset:
                    # If required, append parent resource ID to all child resources
                    if m.annotate_parent:
                        for r in subset:
                            r[m.parent_key] = parent[parents.resource_type.id]

                    results.extend(subset)

            except Exception as e:
                log.warning('Child enumeration failed for {0}. {1}'.format(
                    parent[parents.resource_type.id], e))
                if m.raise_on_exception:
                    raise e

        return results
Esempio n. 2
0
 def extra_args(cls, parent_resource):
     return {
         'vault_base_url':
         generate_key_vault_url(parent_resource['name'])
     }