Don't rely on overcloudrc
We were reading overcloudrc for the openstack-endpoints validation. However, the name of tha file may differ if the deployment plan is called something else than "overcloud" and more importantly, the GUI deployments don't create the file on the undercloud at all. This updates the Ansible inventory to read the admin password and keystone url for the specified plan if available and the validation to use those values instead of relying on overcloudrc. Change-Id: I9ff26016c43888267968ef2588f686f7de95bda3 Closes-Bug: #1643808
This commit is contained in:
parent
e7192c38d1
commit
8927704efa
|
@ -27,6 +27,8 @@ import sys
|
|||
|
||||
from heatclient.v1 import client as heat_client
|
||||
from keystoneclient.v3 import client as keystone_client
|
||||
import mistralclient.api.base
|
||||
import mistralclient.api.client
|
||||
from novaclient import client as nova_client
|
||||
from oslo_config import cfg
|
||||
|
||||
|
@ -68,6 +70,7 @@ class TripleoInventory(object):
|
|||
self.configs = configs
|
||||
self._ksclient = None
|
||||
self._hclient = None
|
||||
self._mclient = None
|
||||
self._nclient = None
|
||||
|
||||
def fetch_stack_resources(self, resource_name):
|
||||
|
@ -99,6 +102,13 @@ class TripleoInventory(object):
|
|||
except Exception:
|
||||
return None
|
||||
|
||||
def get_overcloud_environment(self):
|
||||
try:
|
||||
environment = self.mclient.environments.get(self.configs.plan)
|
||||
return environment.variables
|
||||
except mistralclient.api.base.APIException:
|
||||
return {}
|
||||
|
||||
def list(self):
|
||||
ret = {
|
||||
'undercloud': {
|
||||
|
@ -111,7 +121,20 @@ class TripleoInventory(object):
|
|||
|
||||
public_vip = self.get_overcloud_output('PublicVip')
|
||||
if public_vip:
|
||||
ret['undercloud']['vars']['public_vip'] = public_vip
|
||||
ret['undercloud']['vars']['overcloud_public_vip'] = public_vip
|
||||
keystone_url = self.get_overcloud_output('KeystoneURL')
|
||||
if public_vip:
|
||||
ret['undercloud']['vars']['overcloud_keystone_url'] = keystone_url
|
||||
overcloud_environment = self.get_overcloud_environment()
|
||||
passwords = overcloud_environment.get('passwords', {})
|
||||
admin_password = passwords.get('AdminPassword', '')
|
||||
if admin_password:
|
||||
ret['undercloud']['vars']['overcloud_admin_password'] = admin_password
|
||||
endpoint_map = self.get_overcloud_output('EndpointMap')
|
||||
if endpoint_map:
|
||||
horizon_endpoint = endpoint_map.get('HorizonPublic', {}).get('uri')
|
||||
if horizon_endpoint:
|
||||
ret['undercloud']['vars']['overcloud_horizon_url'] = horizon_endpoint
|
||||
|
||||
controller_group = self.fetch_stack_resources('Controller')
|
||||
if controller_group:
|
||||
|
@ -199,6 +222,23 @@ class TripleoInventory(object):
|
|||
sys.exit(1)
|
||||
return self._nclient
|
||||
|
||||
@property
|
||||
def mclient(self):
|
||||
if self._mclient is None:
|
||||
ksclient = self.ksclient
|
||||
endpoint = ksclient.service_catalog.url_for(
|
||||
service_type='workflowv2', endpoint_type='publicURL')
|
||||
try:
|
||||
self._mclient = mistralclient.api.client.client(
|
||||
mistral_url=endpoint,
|
||||
auth_token=ksclient.auth_token)
|
||||
except Exception as e:
|
||||
print("Error connecting to Mistral: {}".format(e.message),
|
||||
file=sys.stderr)
|
||||
sys.exit(1)
|
||||
return self._mclient
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
configs = _parse_config()
|
||||
|
|
|
@ -10,31 +10,31 @@
|
|||
groups:
|
||||
- post-deployment
|
||||
tasks:
|
||||
- name: Get the path of tripleo user home directory
|
||||
become: true
|
||||
hiera: name="tripleo_install_user"
|
||||
|
||||
- name: Load the overcloud credentials
|
||||
overcloudrc: path=~{{ tripleo_install_user }}/overcloudrc
|
||||
|
||||
# Check connectivity to horizon
|
||||
- name: Check Horizon
|
||||
# TODO(shadower): get Horizon endpoint from Keystone
|
||||
uri: url=http://{{public_vip}}
|
||||
uri: url={{ overcloud_horizon_url }}
|
||||
when: overcloud_horizon_url|default('')
|
||||
|
||||
- fail: msg="The `HorizonPublic` endpoint is not defined in the `EndpointMap` of the deployed stack. This means Horizon may not have been deployed correctly."
|
||||
when: overcloud_horizon_url|default('') == ''
|
||||
|
||||
# Check that we can obtain an auth token from horizon
|
||||
- name: Check Keystone
|
||||
uri:
|
||||
url: "{{ overcloudrc.OS_AUTH_URL }}/tokens"
|
||||
url: "{{ overcloud_keystone_url }}/tokens"
|
||||
method: POST
|
||||
body_format: json
|
||||
body:
|
||||
auth:
|
||||
passwordCredentials:
|
||||
username: "{{ overcloudrc.OS_USERNAME }}"
|
||||
password: "{{ overcloudrc.OS_PASSWORD }}"
|
||||
tenantName: "{{ overcloudrc.OS_TENANT_NAME }}"
|
||||
username: admin
|
||||
password: "{{ overcloud_admin_password }}"
|
||||
tenantName: admin
|
||||
return_content: yes
|
||||
register: auth_token
|
||||
when: overcloud_keystone_url|default('')
|
||||
|
||||
- fail: msg="The `KeystoneURL` output is not available in the deployed stack."
|
||||
when: overcloud_keystone_url|default('') == ''
|
||||
|
||||
# TODO(shadower): other endpoints
|
||||
|
|
Loading…
Reference in New Issue