tripleo-validations/lookup_plugins/stack_resources.py
Gael Chamoulaud d289816733 Migrating Undercloud playbooks to their own Ansible Role
The validations should be in the form of Ansible roles, in order to be
easily accessed from the CLI but also from Mistral (as it is currently
the case). It will also allow to get a proper documentation, canvas and
gives the possibility to validate the role before running it by ensuring
there are metadata, output and so on.

Note that all the custom modules/lookup have been copied into the their
top-level directory.

Change-Id: If08678a18165ad12b8fa85f201541fe60c928e1b
Implements: blueprint validation-framework
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
2019-03-15 10:36:04 +01:00

49 lines
1.7 KiB
Python

#!/usr/bin/env python
# Copyright 2017 Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from ansible.plugins.lookup import LookupBase
from tripleo_validations import utils
class LookupModule(LookupBase):
def run(self, terms, variables=None, **kwargs):
"""Returns the current plan's stack resources.
:return: A list of dicts
"""
ret = []
heat = utils.get_heat_client(variables)
resource_list = heat.resources.list(variables['plan'])
for resource in resource_list:
ret.append(dict(
resource_name=resource.resource_name,
resource_status=resource.resource_status,
logical_resource_id=resource.logical_resource_id,
links=resource.links,
creation_time=resource.creation_time,
resource_status_reason=resource.resource_status_reason,
updated_time=resource.updated_time,
required_by=resource.required_by,
physical_resource_id=resource.physical_resource_id,
resource_type=resource.resource_type
))
return ret