当前位置: 首页>>代码示例>>Python>>正文


Python astakos.AstakosClient类代码示例

本文整理汇总了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'
开发者ID:themiszamani,项目名称:kamaki-examples,代码行数:29,代码来源:createvm.py

示例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
开发者ID:themiszamani,项目名称:e-science,代码行数:11,代码来源:okeanos_utils.py

示例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
开发者ID:TheoniPetropoulou,项目名称:e-science-1,代码行数:12,代码来源:create_cluster.py

示例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
开发者ID:MariosLogothetis,项目名称:e-science,代码行数:13,代码来源:ansible_create_yarn_cluster.py

示例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
开发者ID:nvrionis,项目名称:e-science,代码行数:13,代码来源:authenticate_user.py

示例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']
开发者ID:ktsakalozos,项目名称:juju-okeanos-provider,代码行数:15,代码来源:provider.py

示例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
开发者ID:cstavr,项目名称:SynnefoSSH,代码行数:34,代码来源:client.py

示例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
开发者ID:antonis-m,项目名称:synnefo,代码行数:25,代码来源:common.py

示例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)
开发者ID:Erethon,项目名称:kamaki,代码行数:25,代码来源:cyclades.py

示例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
开发者ID:jaeko44,项目名称:agkyra,代码行数:18,代码来源:setup.py

示例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
开发者ID:vpapaioannou,项目名称:IReS-Platform,代码行数:19,代码来源:okeanos.py

示例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'])
开发者ID:themiszamani,项目名称:e-science,代码行数:21,代码来源:orka.py

示例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
开发者ID:grnet,项目名称:okeanos-LoD,代码行数:21,代码来源:utils.py

示例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)
开发者ID:cstavr,项目名称:SynnefoSSH,代码行数:14,代码来源:client.py

示例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
开发者ID:antonis-m,项目名称:synnefo,代码行数:47,代码来源:common.py


注:本文中的kamaki.clients.astakos.AstakosClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。