X-Git-Url: https://code.grnet.gr/git/snf-image-creator/blobdiff_plain/88f83027df65608a70e1a88f96b4a3055427dd52..71b0ab283eeef37c3d3ecd98fbafa6eaa50b58d8:/image_creator/kamaki_wrapper.py diff --git a/image_creator/kamaki_wrapper.py b/image_creator/kamaki_wrapper.py index 654a933..e2012d2 100644 --- a/image_creator/kamaki_wrapper.py +++ b/image_creator/kamaki_wrapper.py @@ -61,7 +61,7 @@ class Kamaki(object): def get_account(token): """Return the account corresponding to this token""" config = Config() - astakos = AstakosClient(config.get('astakos', 'url'), token) + astakos = AstakosClient(config.get('user', 'url'), token) try: account = astakos.info() except ClientError as e: @@ -78,7 +78,7 @@ class Kamaki(object): config = Config() - pithos_url = config.get('store', 'url') + pithos_url = config.get('file', 'url') self.pithos_client = PithosClient( pithos_url, self.account['auth_token'], self.account['uuid'], self.CONTAINER) @@ -117,4 +117,21 @@ class Kamaki(object): params = {'is_public': is_public, 'disk_format': 'diskdump'} self.image_client.register(name, location, params, str_metadata) + def share(self, location): + """Share this file with all the users""" + + self.pithos_client.set_object_sharing(location, "*") + + def object_exists(self, location): + """Check if an object exists in pythos""" + + try: + self.pithos_client.get_object_info(location) + except ClientError as e: + if e.status == 404: # Object not found error + return False + else: + raise + return True + # vim: set sta sts=4 shiftwidth=4 sw=4 et ai :