Beispiel #1
0
def heat_client(context):
    endpoint = "%s/%s/" % (HEAT_URL, context.tenant)
    client = HeatClient.Client(username=context.user,
                               password="******",
                               token=context.auth_token,
                               os_no_client_auth=True,
                               endpoint=endpoint)
    return client
Beispiel #2
0
 def hclient(self):
     if self._hclient is None:
         ksclient = self.ksclient
         endpoint = ksclient.service_catalog.url_for(
             service_type='orchestration', endpoint_type='publicURL')
         self._hclient = heat_client.Client(endpoint=endpoint,
                                            token=ksclient.auth_token)
     return self._hclient
Beispiel #3
0
 def __init__(self, name='', args=None):
     super(HeatV1Driver, self).__init__(name, args=args)
     datasource_driver.ExecutionDriver.__init__(self)
     self.creds = args
     session = ds_utils.get_keystone_session(self.creds)
     endpoint = session.get_endpoint(service_type='orchestration',
                                     interface='publicURL')
     self.heat = heatclient.Client(session=session, endpoint=endpoint)
     self.initialize_update_methods()
     self._init_end_start_poll()
Beispiel #4
0
    def get_orchestration_client(self, context):
        heat_endpoint = keystone_utils.get_endpoint_for_project('heat')

        endpoint_url = keystone_utils.format_url(
            heat_endpoint.url, {'tenant_id': context.project_id})

        return heatclient.Client(endpoint_url,
                                 region_name=heat_endpoint.region,
                                 token=context.auth_token,
                                 username=context.user_name)
Beispiel #5
0
 def _connect_heat(self):
     if self._heat_connection_tried:
         return
     self._heat_connection_tried = True
     try:
         heat_endpoint = self._keystone.service_catalog.url_for(
             service_type='orchestration')
         self._heat = heatclient.Client(heat_endpoint,
                                        token=self._keystone.auth_token)
         self.logger.info('heat connected')
     except keystone_exceptions.EndpointNotFound as e:
         self._heat = None
         self.logger.warn(e)
 def hclient(self):
     if self._hclient is None:
         ksclient = self.ksclient
         endpoint = ksclient.service_catalog.url_for(
             service_type='orchestration', endpoint_type='publicURL')
         try:
             self._hclient = heat_client.Client(
                 endpoint=endpoint,
                 token=ksclient.auth_token)
         except Exception as e:
             print("Error connecting to Heat: {}".format(e.message),
                   file=sys.stderr)
             sys.exit(1)
     return self._hclient
Beispiel #7
0
def get_hclient():
    ksclient = get_ksclient()

    heat_url = os.getenv('HEAT_URL')
    if not heat_url:
        heat_url = ksclient.service_catalog.url_for(
            service_type='orchestration',
            attr='region',
            filter_value=os.getenv('OS_REGION_NAME'),
            endpoint_type='publicURL')

    token = os.getenv('OS_AUTH_TOKEN', ksclient.auth_token)

    return heatclient.Client(endpoint=heat_url, token=token)
Beispiel #8
0
def heat_client(context):
    if CONF.heat_url:
        url = '%(heat_url)s%(tenant)s' % {
            'heat_url': normalize_url(CONF.heat_url),
            'tenant': context.tenant
        }
    else:
        url = get_endpoint(context.service_catalog,
                           service_type=CONF.heat_service_type,
                           endpoint_region=CONF.os_region_name)

    client = HeatClient.Client(token=context.auth_token,
                               os_no_client_auth=True,
                               endpoint=url)
    return client
Beispiel #9
0
    def get_orchestration_client(self):
        """Return the orchestration (heat) client.

        This method will return a client object using the legacy library. Upon
        the creation of a successful client creation, the client object will
        be stored in the `self.client_cache object`, should this method be
        called more than once, the cached object will automatically return,
        resulting in fewer authentications and faster API interactions.

        :returns: Object
        """

        if 'heatclient' in self.client_cache:
            return self.client_cache['heatclient']
        else:
            self.client_cache['heatclient'] = \
                heatclient.Client(session=self.sess)
            return self.client_cache['heatclient']
Beispiel #10
0
    def _get_heat(self, username, password, project, auth_url,
                 auth_token, insecure, keystone):
        kwargs = {
                  'insecure': False,
                  'ca_file': None,
                  'username': username,
                  'insecure': insecure,
                  'auth_url': auth_url,
                  'tenant_id': project,
                  'token':auth_token
                  }

        heat = heat_client.Client(keystone.service_catalog.url_for(service_type='orchestration',
                                                                   endpoint_type='publicURL'),
                                  **kwargs)
        management_url = keystone.service_catalog.url_for(service_type='orchestration',
                                                          endpoint_type='publicURL')
        # heat.client.auth_token = auth_token
        # cinder.client.management_url = management_url

        return heat
Beispiel #11
0
def get_orchestration_client():
    OS_AUTH_URL = os.environ['OS_AUTH_URL']
    OS_USERNAME = os.environ['OS_USERNAME']
    OS_TENANT_NAME = os.environ['OS_TENANT_NAME']
    OS_PASSWORD = os.environ['OS_PASSWORD']
    auth = v2.Password(auth_url=OS_AUTH_URL,
                       username=OS_USERNAME,
                       password=OS_PASSWORD,
                       tenant_name=OS_TENANT_NAME)
    sess = session.Session(auth=auth)
    keystone = client.Client(session=sess)

    token = auth.get_token(session=sess)
    #log.info("KRS: token: %s" % token)

    endpoint = auth.get_endpoint(sess,
                                 service_name='heat',
                                 service_type='orchestration')
    #log.info("KRS: endpoint: %s" % endpoint)
    return heatclient.Client(
        endpoint=endpoint,
        token=token,
    )
Beispiel #12
0
    def heat(self):
        if self._heat:
            return self._heat

        endpoint_type = self._get_client_option('heat', 'endpoint_type')
        region_name = self._get_client_option('heat', 'region_name')
        endpoint = self.url_for(service_type='orchestration',
                                endpoint_type=endpoint_type,
                                region_name=region_name)

        args = {
            'endpoint': endpoint,
            'auth_url': self.auth_url,
            'token': self.auth_token,
            'username': None,
            'password': None,
            'ca_file': self._get_client_option('heat', 'ca_file'),
            'cert_file': self._get_client_option('heat', 'cert_file'),
            'key_file': self._get_client_option('heat', 'key_file'),
            'insecure': self._get_client_option('heat', 'insecure')
        }
        self._heat = heatclient.Client(**args)

        return self._heat
Beispiel #13
0
 def decorator_method(*args, **kwargs):
     '''
     Authenticate request and format return data
     '''
     connection_args = {'profile': kwargs.get('profile', None)}
     nkwargs = {}
     for kwarg in kwargs:
         if 'connection_' in kwarg:
             connection_args.update({kwarg: kwargs[kwarg]})
         elif '__' not in kwarg:
             nkwargs.update({kwarg: kwargs[kwarg]})
     kstone = __salt__['keystone.auth'](**connection_args)
     token = kstone.auth_token
     endpoint = kstone.service_catalog.url_for(
         service_type='orchestration',
         endpoint_type='publicURL')
     heat_interface = client.Client(
         endpoint_url=endpoint, token=token)
     return_data = func_name(heat_interface, *args, **nkwargs)
     if isinstance(return_data, list):
         # format list as a dict for rendering
         return {data.get('name', None) or data['id']: data
                 for data in return_data}
     return return_data
Beispiel #14
0
 def test_init_with_client(self):
     session = keystone.get_keystone_session()
     self.test_init(client=heatclient.Client(session=session))
Beispiel #15
0
 def authenticate_heat_admin(self, keystone):
     """Authenticates the admin user with heat."""
     self.log.debug('Authenticating heat admin...')
     ep = keystone.service_catalog.url_for(service_type='orchestration',
                                           endpoint_type='publicURL')
     return heat_client.Client(endpoint=ep, token=keystone.auth_token)
Beispiel #16
0
def heat_client(context):
    endpoint = "%s/%s" % (HEAT_URL, context.tenant)
    client = HeatClient.Client(token=context.auth_token,
                               os_no_client_auth=True,
                               endpoint=endpoint)
    return client
Beispiel #17
0
 def init_client(self, session) -> HeatClient:
     return v1_client.Client(session=session,
                             endpoint_type='public',
                             service_type='orchestration')
Beispiel #18
0
def get_heat_client(**kwargs):
    return heatclient.Client('')