def create_snapshot(client, rg=TEST_RG, account_name=TEST_ACC_1, pool_name=TEST_POOL_1, volume_name=TEST_VOL_1, snapshot_name=TEST_SNAPSHOT_1, location=LOCATION, snapshot_only=False): if not snapshot_only: volume = create_volume(client, rg, account_name, pool_name, volume_name) # be sure the volume is really available wait_for_volume(client, rg, account_name, pool_name, volume_name) else: # we need to get the volume id if we didn't just create it volume = client.volumes.get(rg, account_name, pool_name, volume_name) snapshot = client.snapshots.create( rg, account_name, pool_name, volume_name, snapshot_name, location=location, file_system_id=volume.file_system_id).result() return snapshot
def create_snapshot(client, rg=TEST_RG, account_name=TEST_ACC_1, pool_name=TEST_POOL_1, volume_name=TEST_VOL_1, snapshot_name=TEST_SNAPSHOT_1, location=LOCATION, snapshot_only=False): if not snapshot_only: volume = create_volume(client, rg, account_name, pool_name, volume_name) # be sure the volume is really available wait_for_volume(client, rg, account_name, pool_name, volume_name) else: # we need to get the volume id if we didn't just create it volume = client.volumes.get(rg, account_name, pool_name, volume_name) snapshot_body = Snapshot(location=location, file_system_id=volume.file_system_id) snapshot = client.snapshots.create(snapshot_body, rg, account_name, pool_name, volume_name, snapshot_name).result() return snapshot
def create_backup(client, backup_name=TEST_BACKUP_1, rg=BACKUP_RG, account_name=TEST_ACC_1, pool_name=TEST_POOL_1, volume_name=TEST_VOL_1, location=BACKUP_LOCATION, backup_only=False, live=False): if not backup_only: create_volume(client, rg, account_name, pool_name, volume_name, location, vnet=BACKUP_VNET, live=live) wait_for_volume(client, rg, account_name, pool_name, volume_name, live) vaults = client.vaults.list(rg, account_name) volume_patch = VolumePatch(data_protection={ "backup": { "vaultId": vaults.next().id, "backupEnabled": True } }) client.volumes.begin_update(BACKUP_RG, TEST_ACC_1, TEST_POOL_1, TEST_VOL_1, volume_patch).result() backup_body = Backup(location=location) backup = client.backups.begin_create(rg, account_name, pool_name, volume_name, backup_name, backup_body).result() wait_for_backup_created(client, rg, account_name, pool_name, volume_name, backup_name, live) return backup