Last active
February 12, 2016 14:53
-
-
Save d0ugal/74fd03a9cfafcb5f4951 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from heatclient.v1.client import Client as heat_client | |
from keystoneclient.v2_0 import client as ksclient | |
def keystoneclient(): | |
return ksclient.Client( | |
username=os.environ.get('OS_USERNAME'), | |
tenant_name=os.environ.get('OS_TENANT_NAME'), | |
password=os.environ.get('OS_PASSWORD'), | |
auth_url=os.environ.get('OS_AUTH_URL'), | |
auth_version=2, | |
insecure=True | |
) | |
def heatclient(): | |
keystone = keystoneclient() | |
endpoint = keystone.service_catalog.url_for( | |
service_type='orchestration', | |
endpoint_type='publicURL' | |
) | |
return heat_client( | |
endpoint=endpoint, | |
token=keystone.auth_token, | |
username=os.environ.get('OS_USERNAME'), | |
password=os.environ.get('OS_PASSWORD')) | |
heat_client = heatclient() | |
FAILED_STATUSES = set(['CREATE_FAILED', 'UPDATE_FAILED']) | |
all_resources = heat_client.resources.list("overcloud", nested_depth=5) | |
failed = (resource for resource in all_resources | |
if resource.resource_status in FAILED_STATUSES) | |
print "*** STACK STATUS REASON ***" | |
print heat_client.stacks.get("overcloud").stack_status_reason | |
for resource in failed: | |
print "*** RESOURCE STATUS REASON ***" | |
print resource.resource_name | |
print resource.resource_status_reason | |
deploy_id = resource.physical_resource_id | |
try: | |
deploy = heat_client.software_deployments.get(deployment_id=deploy_id) | |
print "*** DEPLOY STATUS REASON ***" | |
print deploy.status_reason | |
except: | |
print "No deployment" | |
print "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment