Esempio n. 1
0
class FileShare(object):
    """
        Information from Azure files service
    """
    def __init__(self, account):
        self.account_name = account.storage_name()
        self.account_key = account.storage_key()
        self.files = FileService(
            self.account_name, self.account_key
        )

    def list(self):
        """
            list file shares
        """
        result = []
        try:
            for share in self.files.list_shares():
                result.append(format(share.name))
        except Exception as e:
            raise AzureFileShareListError(
                '%s: %s' % (type(e).__name__, format(e))
            )
        return result

    def create(self, share_name):
        """
            create a file share
        """
        try:
            self.files.create_share(share_name)
        except Exception as e:
            raise AzureFileShareCreateError(
                '%s: %s' % (type(e).__name__, format(e))
            )

    def delete(self, share_name):
        """
            delete a file share
        """
        try:
            self.files.delete_share(share_name)
        except Exception as e:
            raise AzureFileShareDeleteError(
                '%s: %s' % (type(e).__name__, format(e))
            )