本文整理汇总了Python中kamaki.clients.astakos.AstakosClient类的典型用法代码示例。如果您正苦于以下问题:Python AstakosClient类的具体用法?Python AstakosClient怎么用?Python AstakosClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AstakosClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: authenticate_clients
def authenticate_clients():
"""
function to instantiate Clients (astakos, cyclades, compute)
"""
try:
astakos_client = AstakosClient(AUTHENTICATION_URL,
TOKEN)
astakos_client.authenticate()
logging.info('Successful authentication')
except ClientError:
logging.info('\n Failed to authenticate user token')
print 'Failed to authenticate user token'
try:
endpoints = astakos_client.get_endpoints()
cyclades_base_url = parse_astakos_endpoints(endpoints,
'cyclades_compute')
cyclades_network_base_url = parse_astakos_endpoints(endpoints,
'cyclades_network')
except ClientError:
print('Failed to get endpoints for cyclades')
try:
cyclades_client = CycladesClient(cyclades_base_url, TOKEN)
compute_client = ComputeClient(cyclades_base_url, TOKEN)
network_client = CycladesNetworkClient(cyclades_network_base_url,
TOKEN)
return cyclades_client, compute_client, network_client, astakos_client
except ClientError:
print 'Failed to initialize Cyclades client'
示例2: check_credentials
def check_credentials(token, auth_url=auth_url):
"""Identity,Account/Astakos. Test authentication credentials"""
logging.log(REPORT, ' Test the credentials')
try:
auth = AstakosClient(auth_url, token)
auth.authenticate()
except ClientError:
msg = ' Authentication failed with url %s and token %s'\
% (auth_url, token)
raise ClientError(msg, error_authentication)
return auth
示例3: check_credentials
def check_credentials(auth_url, token):
print(' Test the credentials')
try:
auth = AstakosClient(auth_url, token)
auth.authenticate()
except ClientError:
print('Authentication failed with url %s and token %s' % (
auth_url, token))
raise
print 'Authentication verified'
return auth
示例4: check_credentials
def check_credentials(token, auth_url='https://accounts.okeanos.grnet.gr'
'/identity/v2.0'):
'''Identity,Account/Astakos. Test authentication credentials'''
logging.log(REPORT, ' Test the credentials')
try:
auth = AstakosClient(auth_url, token)
auth.authenticate()
except ClientError:
logging.error('Authentication failed with url %s and token %s' % (
auth_url, token))
sys.exit(error_authentication)
logging.log(REPORT, ' Authentication verified')
return auth
示例5: check_user_credentials
def check_user_credentials(token, auth_url='https://accounts.okeanos.grnet.gr'
'/identity/v2.0'):
'''Identity,Account/Astakos. Test ~okeanos authentication credentials'''
logging.info(' Test the credentials')
try:
auth = AstakosClient(auth_url, token)
auth.authenticate()
logging.info(' Authentication verified')
return AUTHENTICATED
except ClientError:
logging.error('Authentication failed with url %s and token %s' % (
auth_url, token))
return NOT_AUTHENTICATED
示例6: __init__
def __init__(self, config):
self.config = config
cloud_name = self.config.get('global', 'default_cloud')
self.auth_token = self.config.get_cloud(cloud_name, 'token')
cacerts_path = self.config.get('global', 'ca_certs')
https.patch_with_certs(cacerts_path)
auth_url = self.config.get_cloud(cloud_name, 'url')
auth = AstakosClient(auth_url, self.auth_token)
self.endpoints = dict(
astakos=auth_url,
cyclades=auth.get_endpoint_url(CycladesComputeClient.service_type),
network=auth.get_endpoint_url(CycladesNetworkClient.service_type),
plankton=auth.get_endpoint_url(ImageClient.service_type)
)
self.user_id = auth.user_info['id']
示例7: SynnefoClient
class SynnefoClient(object):
"""Synnefo Client
Wrapper class around clients of kamaki's clients for various Synnefo
services:
* astakos: Astakos client
* compute: Cyclades Compute client
* network: Cyclades Network client
* image: Cyclades Plankton client
"""
def __init__(self, cloud=None, auth_url=None, token=None):
if cloud is not None:
auth_url, token = utils.get_cloud_credentials(cloud)
self.auth_url, self.token = auth_url, token
self.astakos = AstakosClient(self.auth_url, self.token)
self.endpoints = self.get_api_endpoints()
self.volume = BlockStorageClient(self.endpoints["cyclades_volume"],
token)
self.compute = CycladesClient(self.endpoints["cyclades_compute"],
token)
self.cyclades_networks = CycladesNetworkClient(self.endpoints["cyclades_network"],
token)
self.network = NetworkClient(self.endpoints["cyclades_network"], token)
self.image = ImageClient(self.endpoints["cyclades_plankton"], token)
def get_api_endpoints(self):
"""Get service endpoints from Astakos"""
_endpoints = self.astakos.get_endpoints()["access"]
endpoints = {}
for service in _endpoints["serviceCatalog"]:
endpoints[service["name"]] = service["endpoints"][0]["publicURL"]
return endpoints
示例8: initialize_clients
def initialize_clients(self):
"""Initialize all the Kamaki Clients"""
self.astakos = AstakosClient(self.auth_url, self.token)
self.astakos.CONNECTION_RETRY_LIMIT = self.retry
endpoints = self.astakos.authenticate()
self.compute_url = _get_endpoint_url(endpoints, "compute")
self.compute = ComputeClient(self.compute_url, self.token)
self.compute.CONNECTION_RETRY_LIMIT = self.retry
self.cyclades = CycladesClient(self.compute_url, self.token)
self.cyclades.CONNECTION_RETRY_LIMIT = self.retry
self.network_url = _get_endpoint_url(endpoints, "network")
self.network = CycladesNetworkClient(self.network_url, self.token)
self.network.CONNECTION_RETRY_LIMIT = self.retry
self.pithos_url = _get_endpoint_url(endpoints, "object-store")
self.pithos = PithosClient(self.pithos_url, self.token)
self.pithos.CONNECTION_RETRY_LIMIT = self.retry
self.image_url = _get_endpoint_url(endpoints, "image")
self.image = ImageClient(self.image_url, self.token)
self.image.CONNECTION_RETRY_LIMIT = self.retry
示例9: setUp
def setUp(self):
print
with open(self['cmpimage', 'details']) as f:
self.img_details = eval(f.read())
self.img = self.img_details['id']
with open(self['flavor', 'details']) as f:
self._flavor_details = eval(f.read())
self.PROFILES = ('ENABLED', 'DISABLED', 'PROTECTED')
self.servers = {}
self.now = time.mktime(time.gmtime())
self.servname1 = 'serv' + unicode(self.now)
self.servname2 = self.servname1 + '_v2'
self.servname1 += '_v1'
self.flavorid = self._flavor_details['id']
#servers have to be created at the begining...
self.networks = {}
self.netname1 = 'net' + unicode(self.now)
self.netname2 = 'net' + unicode(self.now) + '_v2'
self.cloud = 'cloud.%s' % self['testcloud']
aurl, self.token = self[self.cloud, 'url'], self[self.cloud, 'token']
self.auth_base = AstakosClient(aurl, self.token)
curl = self.auth_base.get_service_endpoints('compute')['publicURL']
self.client = CycladesClient(curl, self.token)
示例10: _get_pithos_client
def _get_pithos_client(self, auth_url, token, container):
try:
astakos = AstakosClient(auth_url, token)
except ClientError:
logger.error("Failed to authenticate user token")
raise
try:
PITHOS_URL = astakos.get_endpoint_url(
AgkyraPithosClient.service_type)
except ClientError:
logger.error("Failed to get endpoints for Pithos")
raise
try:
account = astakos.user_info['id']
return AgkyraPithosClient(PITHOS_URL, token, account, container)
except ClientError:
logger.error("Failed to initialize Pithos client")
raise
示例11: authenticate
def authenticate(self, authentication=None):
"""
:param authentication:
:return:
"""
if self.__cyclades is not None:
return True
try:
authcl = AstakosClient(authentication['URL'], authentication['TOKEN'])
authcl.authenticate()
self.__cyclades = CycladesClient(authcl.get_service_endpoints('compute')['publicURL'],
authentication['TOKEN'])
self.__network_client = CycladesNetworkClient(authcl.get_service_endpoints('network')['publicURL'],
authentication['TOKEN'])
except ClientError:
stderr.write('Connector initialization failed')
return False
return True
示例12: list_pithos_files
def list_pithos_files(self):
""" Method for listing pithos+ files available to the user """
auth_url = self.opts['auth_url']
token = self.opts['token']
try:
auth = AstakosClient(auth_url, token)
auth.authenticate()
except ClientError:
msg = ' Authentication error: Invalid Token'
logging.error(msg)
exit(error_fatal)
pithos_endpoint = auth.get_endpoint_url('object-store')
pithos_container = self.opts.get('pithos_container','pithos')
user_id = auth.user_info['id']
pithos_client = PithosClient(pithos_endpoint,self.opts['token'], user_id, pithos_container)
objects = pithos_client.list_objects()
for object in objects:
is_dir = 'application/directory' in object.get('content_type', object.get('content-type', ''))
if not is_dir:
print u"{:>12s} \"pithos:/{:s}/{:s}\"".format(bytes_to_shorthand(object['bytes']),
pithos_container,object['name'])
示例13: check_auth_token
def check_auth_token(auth_token, auth_url=None):
"""
Checks the validity of a user authentication token.
:param auth_token: User authentication token
:param auth_url: Authentication url
:return: tuple(Success status, details)
"""
if not auth_url:
auth_url = "https://accounts.okeanos.grnet.gr/identity/v2.0"
patch_certs()
cl = AstakosClient(auth_url, auth_token)
try:
user_info = cl.authenticate()
except ClientError as ex:
if ex.message == 'UNAUTHORIZED':
return False, ex.details
else:
raise
return True, user_info
示例14: __init__
def __init__(self, cloud=None, auth_url=None, token=None):
if cloud is not None:
auth_url, token = utils.get_cloud_credentials(cloud)
self.auth_url, self.token = auth_url, token
self.astakos = AstakosClient(self.auth_url, self.token)
self.endpoints = self.get_api_endpoints()
self.volume = BlockStorageClient(self.endpoints["cyclades_volume"],
token)
self.compute = CycladesClient(self.endpoints["cyclades_compute"],
token)
self.cyclades_networks = CycladesNetworkClient(self.endpoints["cyclades_network"],
token)
self.network = NetworkClient(self.endpoints["cyclades_network"], token)
self.image = ImageClient(self.endpoints["cyclades_plankton"], token)
示例15: Clients
class Clients(object):
"""Our kamaki clients"""
auth_url = None
token = None
# Astakos
astakos = None
retry = CONNECTION_RETRY_LIMIT
# Compute
compute = None
compute_url = None
# Cyclades
cyclades = None
# Network
network = None
network_url = None
# Pithos
pithos = None
pithos_url = None
# Image
image = None
image_url = None
def initialize_clients(self):
"""Initialize all the Kamaki Clients"""
self.astakos = AstakosClient(self.auth_url, self.token)
self.astakos.CONNECTION_RETRY_LIMIT = self.retry
endpoints = self.astakos.authenticate()
self.compute_url = _get_endpoint_url(endpoints, "compute")
self.compute = ComputeClient(self.compute_url, self.token)
self.compute.CONNECTION_RETRY_LIMIT = self.retry
self.cyclades = CycladesClient(self.compute_url, self.token)
self.cyclades.CONNECTION_RETRY_LIMIT = self.retry
self.network_url = _get_endpoint_url(endpoints, "network")
self.network = CycladesNetworkClient(self.network_url, self.token)
self.network.CONNECTION_RETRY_LIMIT = self.retry
self.pithos_url = _get_endpoint_url(endpoints, "object-store")
self.pithos = PithosClient(self.pithos_url, self.token)
self.pithos.CONNECTION_RETRY_LIMIT = self.retry
self.image_url = _get_endpoint_url(endpoints, "image")
self.image = ImageClient(self.image_url, self.token)
self.image.CONNECTION_RETRY_LIMIT = self.retry