當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。