Пример #1
0
def create_acl_policy(
        client, container_name, policy_name, start=None, expiry=None, permission=None, **kwargs):
    ''' Create a stored access policy on the containing object '''
    from azure.storage.models import AccessPolicy
    acl = _get_acl(client, container_name, **kwargs)
    acl[policy_name] = AccessPolicy(permission, expiry, start)
    return _set_acl(client, container_name, acl, **kwargs)
Пример #2
0
    def test_table_ops_ignore_encryption(self):
        table_name = self.get_resource_name('EncryptionTableOps')
        try:
            # Arrange
            self.ts.require_encryption = True
            self.ts.key_encryption_key = KeyWrapper('key1')

            # Act
            self.assertTrue(self.ts.create_table(table_name))

            self.assertTrue(self.ts.exists(table_name))

            list_tables = self.ts.list_tables()
            test_table_exists = False
            for table in list_tables:
                if table.name == table_name:
                    test_table_exists = True
            self.assertTrue(test_table_exists)

            permissions = self.ts.get_table_acl(table_name)
            new_policy = AccessPolicy(TablePermissions(_str='r'),
                                      expiry=datetime(2017, 9, 9))
            permissions['samplePolicy'] = new_policy
            self.ts.set_table_acl(table_name, permissions)
            permissions = self.ts.get_table_acl(table_name)
            permissions['samplePolicy']
            self.ts.key_encryption_key = None
            permissions = self.ts.get_table_acl(table_name)
            permissions['samplePolicy']

            self.ts.delete_table(table_name)
            self.assertFalse(self.ts.exists(table_name))
        finally:
            self.ts.delete_table(table_name)
Пример #3
0
 def _dict_to_signed_identifiers(self, signed_identifiers):
     result = SignedIdentifiers()
     for _id, policy in signed_identifiers.iteritems():
         identifier = SignedIdentifier()
         identifier.id = _id
         identifier.access_policy = AccessPolicy(
             start=policy['start'],
             expiry=policy['expiry'],
             permission=policy['permissions'])
         result.signed_identifiers.append(identifier)
     return result
Пример #4
0
def copyBlobToBlob(sourceUrl, sourceKey, destUrl, destKey):
    blobservice = BlobService(destUrl, destkey)
    srcblobservice = BlobService(SourceUrl, srckey)
    today = datetime.datetime.utcnow()
    todayPlusMonth = today + datetime.timedelta(1)
    todayPlusMonthISO = todayPlusMonth.replace(microsecond=0).isoformat() + 'Z'
    srcSasParam = srcblobservice.generate_shared_access_signature(container,
            filename, SharedAccessPolicy(AccessPolicy(None, todayPlusMonthISO, "r"), None))
    srcUrl = srcblobservice.make_blob_url(container, filename,
            sas_token=srcSasParam)
    print srcUrl
    blobservice.copy_blob(container, filename, srcUrl)
Пример #5
0
def create_acl_policy(client,
                      container_name,
                      policy_name,
                      start=None,
                      expiry=None,
                      permission=None,
                      **kwargs):
    """Create a stored access policy on the containing object"""
    from azure.storage.models import AccessPolicy
    acl = _get_acl(client, container_name, **kwargs)
    acl[policy_name] = AccessPolicy(permission, expiry, start)
    if hasattr(acl, 'public_access'):
        kwargs['public_access'] = getattr(acl, 'public_access')

    return _set_acl(client, container_name, acl, **kwargs)
Пример #6
0
def create_acl_policy(client,
                      container_name,
                      policy_name,
                      start=None,
                      expiry=None,
                      permission=None):
    ''' Create a stored access policy on the containing object '''
    from azure.storage.models import AccessPolicy
    # TODO: Remove workaround once SDK issue fixed (Pivotal #120873795)
    if not (start or expiry or permission):
        raise CLIError(
            'Must specify at least one property (permission, start or expiry) '
            'when creating an access policy.')

    acl = _get_acl(client, container_name)
    acl[policy_name] = AccessPolicy(permission, expiry, start)
    return _set_acl(client, container_name, acl)
Пример #7
0
def set_acl_policy(client,
                   container_name,
                   policy_name,
                   start=None,
                   expiry=None,
                   permission=None):
    ''' Set a stored access policy on a containing object '''
    from azure.storage.models import AccessPolicy
    if not (start or expiry or permission):
        raise CLIError(
            'Must specify at least one property when updating an access policy.'
        )

    acl = _get_acl(client, container_name)
    try:
        acl[policy_name] = AccessPolicy(permission, expiry, start)
    except KeyError:
        raise CLIError('ACL does not contain {}'.format(policy_name))
    return _set_acl(client, container_name, acl)