def _init_pithos(self):
        uuid, token = self.astakos.user_term('id'), self.astakos.token
        service_type = pithos.PithosClient.service_type
        pithos_url = self.astakos.get_endpoint_url(service_type)
        container = self.config_dict['container']['name']
        self.pithos = pithos.PithosClient(pithos_url, token, uuid, container)

        # Create container if not exist, or reassign to named project
        project = self.config_dict['container'].get('project', None)
        try:
            c = self.pithos.get_container_info()
        except ClientError as ce:
            if ce.status not in (404, ):
                raise
            c = self.pithos.create_container(project_id=project)
            return
        if project and c.get('x-container-policy-project') != project:
            self.pithos.reassign_container(project)
示例#2
0
TOKEN = cnf.get_cloud(CLOUD, 'token')

from kamaki.cli import logger

logger.add_stream_logger('kamaki.clients.recv', fmt='< %(message)s')
logger.add_stream_logger('kamaki.clients.send', fmt='> %(message)s')

from kamaki.clients import astakos, pithos, cyclades, image
from kamaki.clients.utils import https

https.patch_with_certs('/etc/ssl/certs/ca-certificates.crt')

identity_client = astakos.AstakosClient(URL, TOKEN)

pithosURL = identity_client.get_endpoint_url(pithos.PithosClient.service_type)
storage_client = pithos.PithosClient(pithosURL, TOKEN)
storage_client.account = identity_client.user_info['id']
storage_client.container = 'pithos'

imageURL = identity_client.get_endpoint_url(image.ImageClient.service_type)
image_client = image.ImageClient(imageURL, TOKEN)

computeURL = identity_client.get_endpoint_url(
    cyclades.CycladesComputeClient.service_type)
compute_client = cyclades.CycladesComputeClient(computeURL, TOKEN)

networkURL = identity_client.get_endpoint_url(
    cyclades.CycladesNetworkClient.service_type)
network_client = cyclades.CycladesNetworkClient(networkURL, TOKEN)

volumeURL = identity_client.get_endpoint_url(