def __init__(self, controller_ip, user='******', password='******', tenant='admin', cert=None, env=None, proxy_session=None): logger.debug('Init OpenStack clients on {0}'.format(controller_ip)) self.controller_ip = controller_ip self.username = user self.password = password self.tenant = tenant if cert is None: auth_url = 'http://{0}:5000/v2.0/'.format(self.controller_ip) self.path_to_cert = None self.insecure = True else: auth_url = 'https://{0}:5000/v2.0/'.format(self.controller_ip) with gen_temp_file(prefix="fuel_cert_", suffix=".pem") as f: f.write(cert) self.path_to_cert = f.name self.insecure = False logger.debug('Auth URL is {0}'.format(auth_url)) auth = KeystonePassword(username=user, password=password, auth_url=auth_url, tenant_name=tenant) self.session = session.Session(auth=auth, verify=self.path_to_cert) self.keystone = KeystoneClient(session=self.session) self.keystone.management_url = auth_url self.nova = nova_client.Client(version=2, session=self.session) self.cinder = cinderclient.Client(version=2, session=self.session) self.neutron = neutron_client.Client(session=self.session) self.glance = GlanceClient(session=self.session) endpoint_url = self.session.get_endpoint(service_type='orchestration', endpoint_type='publicURL') token = self.session.get_token() self.heat = HeatClient(endpoint=endpoint_url, token=token) self.env = env
def create_heat_client(host_ip): """ 创建heat客户端 """ rc_data = get_rc(host_ip) auth = identity.Password(user_domain_name=rc_data.user_domain_name, username=rc_data.username, password=rc_data.password, project_domain_name=rc_data.project_domain_name, project_name=rc_data.project_name, auth_url=rc_data.auth_url) sess = session.Session(auth=auth, verify=config.server_ca_verify) return HeatClient(session=sess, endpoint_override=rc_data.heat_url)
def get_overcloud_stack(): os_auth_url, os_tenant_name, os_username, os_password = \ CredentialHelper.get_undercloud_creds() try: keystone_client = clients.get_keystone_client( os_username, os_password, os_tenant_name, os_auth_url) heat_url = keystone_client.service_catalog.url_for( service_type='orchestration', endpoint_type='publicURL') heat_client = HeatClient(endpoint=heat_url, token=keystone_client.auth_token) # There can be only one overcloud stack, so if there is one it # will be the first in the list. return next(heat_client.stacks.list(), None) except: return None
def heat(self): if not self._heat_client: endpoints = self.keystone.service_catalog.get_endpoints() endpoint = endpoints['orchestration'][0]['publicURL'] self._heat_client = HeatClient(endpoint, **self.credentials) return self._heat_client
def heat(self): endpoint = self.__make_endpoint( self._get_url_for_svc(service_type='orchestration')) # TODO: parameter endpoint_override when heatclient will be fixed return HeatClient(session=self.keystone_session, endpoint=endpoint)