def __init__(self, username, password, tenant_id, auth_url, api_protocol, api_host, api_port, api_resource): """ Init a new Client for CLOTO component. :param username (string): The username (OpenStack) :param password (string): The password :param tenant_id (string): TenantID :param auth_url (string): Keystone/IdM auth URL :param api_protocol (string): API protocol :param api_host (string): API host :param api_port (string): API port :param api_resource (string): API base resource :return: None """ __logger__.info("Init CLOTO Client") __logger__.debug("Client parameters: Username: %s, Password: %s, TenantId: %s, API protocol: %s, API host: %s, " "API port: %s, Base resource: %s", username, password, tenant_id, api_protocol, api_host, api_port, api_resource) self.headers = dict() self.api_protocol = api_protocol self.api_host = api_host self.api_port = api_port self.api_resource = api_resource set_representation_headers(self.headers, content_type=HEADER_REPRESENTATION_JSON, accept=HEADER_REPRESENTATION_JSON) self._init_keystone_client(username, password, tenant_id, auth_url) self.token = self._get_auth_token() __logger__.debug("Token: %s", self.token) self.headers.update({X_AUTH_TOKEN: self.token}) self.headers.update({TENANT_ID: tenant_id}) __logger__.debug("Headers with OpenStack credentials: %s", self.headers)
def update_representation_headers(self, content_type, accept): """ Update headers with the given representations. :param content_type (string): Content-Type header value. :param accept (string): Accept header value. :return: None """ set_representation_headers(self.headers, content_type=content_type, accept=accept)
def __init__(self, protocol, host, port, base_resource): """ Contructor of the class. Inits API parameters and headers. :param protocol (string): Protocol. :param host (string): Host. :param port (string): Port. :param base_resource(string): Base resource. :return: None """ self.protocol = protocol self.host = host self.port = port self.base_resource = base_resource self.headers = {} set_representation_headers(self.headers, content_type=HTTP_REPRESENTATION_HEADER_TEXT, accept=HTTP_REPRESENTATION_HEADER_TEXT)
def __init__(self, username, password, tenant_id, auth_url, api_protocol, api_host, api_port, api_base_resource): """ Init Client and request new token. :param username (string): The username (OpenStack) :param password (string): The password :param tenant_id (string): TenantID :param auth_url (string): Keystone/IdM auth URL :param api_protocol (string): Protocol. :param api_host (string): Host. :param api_port (string): Port. :param api_base_resource (string): Base resource. :return: None. """ super(GlanceSyncApiClient, self).__init__(api_protocol, api_host, api_port, api_base_resource) __logger__.info("Init GlanceSync API Client") __logger__.debug( "Client parameters: Username: %s, Password: %s, TenantId: %s, " "API protocol: %s, API host: %s, " "API port: %s, Base resource: %s", username, password, tenant_id, api_protocol, api_host, api_port, api_base_resource) self.headers = dict() set_representation_headers(self.headers, content_type=HEADER_REPRESENTATION_JSON, accept=HEADER_REPRESENTATION_JSON) self._init_keystone_client(username, password, tenant_id, auth_url) self.token = self._get_auth_token() __logger__.debug("Token: %s", self.token) self.headers.update({HEADER_X_AUTH_TOKEN: self.token}) __logger__.debug("Headers with OpenStack credentials: %s", self.headers) self.protocol = api_protocol self.host = api_host self.port = api_port self.base_resource = api_base_resource
def __init__(self, protocol, host, port, base_resource): """ Contructor of the class. Inits API parameters and headers. :param protocol (string): Protocol. :param host (string): Host. :param port (string): Port. :param base_resource(string): Base resource. :return: None """ self.protocol = protocol self.host = host self.port = port self.base_resource = base_resource self.headers = {} set_representation_headers( self.headers, content_type=HTTP_REPRESENTATION_HEADER_TEXT, accept=HTTP_REPRESENTATION_HEADER_TEXT)
def __init__(self, username, password, tenant_id, auth_url, api_protocol, api_host, api_port, api_base_resource): """ Init Client and request new token. :param username (string): The username (OpenStack) :param password (string): The password :param tenant_id (string): TenantID :param auth_url (string): Keystone/IdM auth URL :param api_protocol (string): Protocol. :param api_host (string): Host. :param api_port (string): Port. :param api_base_resource (string): Base resource. :return: None. """ super(GlanceSyncApiClient, self).__init__(api_protocol, api_host, api_port, api_base_resource) __logger__.info("Init GlanceSync API Client") __logger__.debug("Client parameters: Username: %s, Password: %s, TenantId: %s, " "API protocol: %s, API host: %s, " "API port: %s, Base resource: %s", username, password, tenant_id, api_protocol, api_host, api_port, api_base_resource) self.headers = dict() set_representation_headers(self.headers, content_type=HEADER_REPRESENTATION_JSON, accept=HEADER_REPRESENTATION_JSON) self._init_keystone_client(username, password, tenant_id, auth_url) self.token = self._get_auth_token() __logger__.debug("Token: %s", self.token) self.headers.update({HEADER_X_AUTH_TOKEN: self.token}) __logger__.debug("Headers with OpenStack credentials: %s", self.headers) self.protocol = api_protocol self.host = api_host self.port = api_port self.base_resource = api_base_resource
def __init__(self, username, password, tenant_id, auth_url, api_protocol, api_host, api_port, api_resource): """ Init a new Client for CLOTO component. :param username (string): The username (OpenStack) :param password (string): The password :param tenant_id (string): TenantID :param auth_url (string): Keystone/IdM auth URL :param api_protocol (string): API protocol :param api_host (string): API host :param api_port (string): API port :param api_resource (string): API base resource :return: None """ __logger__.info("Init CLOTO Client") __logger__.debug( "Client parameters: Username: %s, Password: %s, TenantId: %s, API protocol: %s, API host: %s, " "API port: %s, Base resource: %s", username, password, tenant_id, api_protocol, api_host, api_port, api_resource) self.headers = dict() self.api_protocol = api_protocol self.api_host = api_host self.api_port = api_port self.api_resource = api_resource set_representation_headers(self.headers, content_type=HEADER_REPRESENTATION_JSON, accept=HEADER_REPRESENTATION_JSON) self._init_keystone_client(username, password, tenant_id, auth_url) self.token = self._get_auth_token() __logger__.debug("Token: %s", self.token) self.headers.update({X_AUTH_TOKEN: self.token}) self.headers.update({TENANT_ID: tenant_id}) __logger__.debug("Headers with OpenStack credentials: %s", self.headers)