def create_volume(client,
                  rg=TEST_RG,
                  account_name=TEST_ACC_1,
                  pool_name=TEST_POOL_1,
                  volume_name=TEST_VOL_1,
                  location=LOCATION,
                  vnet=VNET,
                  volume_only=False,
                  live=False):
    if not volume_only:
        create_pool(client, rg, account_name, pool_name, location, False)
        if live:
            time.sleep(10)

    volume_body = create_volume_body(volume_name, location, rg, vnet)
    volume = client.volumes.begin_create_or_update(rg, account_name, pool_name,
                                                   volume_name,
                                                   volume_body).result()

    return volume
def create_dp_volume(client,
                     source_volume,
                     rg=TEST_REPL_REMOTE_RG,
                     account_name=TEST_ACC_2,
                     pool_name=TEST_POOL_2,
                     volume_name=TEST_VOL_2,
                     location=REMOTE_LOCATION,
                     volume_only=False,
                     live=False):
    if not volume_only:
        create_pool(client, rg, account_name, pool_name, location, False)
        if live:
            time.sleep(10)

    # data protection and replication object
    replication = ReplicationObject(endpoint_type="dst",
                                    remote_volume_resource_id=source_volume.id,
                                    replication_schedule="_10minutely")

    data_protection = VolumePropertiesDataProtection(replication=replication)

    default_protocol_type = ["NFSv3"]

    volume_body = Volume(
        location=location,
        usage_threshold=100 * GIGABYTE,
        protocol_types=default_protocol_type,
        creation_token=volume_name,
        subnet_id="/subscriptions/" + SUBSID + "/resourceGroups/" + rg +
        "/providers/Microsoft.Network/virtualNetworks/" + REMOTE_VNET +
        "/subnets/default",
        volume_type="DataProtection",
        data_protection=data_protection)

    destination_volume = client.volumes.begin_create_or_update(
        rg, account_name, pool_name, volume_name, volume_body).result()

    return destination_volume
Example #3
0
def create_volume(client, rg=TEST_RG, account_name=TEST_ACC_1, pool_name=TEST_POOL_1, volume_name=TEST_VOL_1, location=LOCATION, volume_only=False):
    if not volume_only:
        pool = create_pool(client)
        time.sleep(10)

    volume_body = create_volume_body(volume_name, location)
    volume = client.volumes.create_or_update(
        volume_body,
        rg,
        account_name,
        pool_name,
        volume_name
    ).result()

    return volume
    def test_pool_change(self):
        # this can be reverted to set_bodiless_matcher() after tests are re-recorded and don't contain these headers
        set_custom_default_matcher(
            compare_bodies=False,
            excluded_headers=
            "Authorization,Content-Length,x-ms-client-request-id,x-ms-request-id"
        )
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        pool2 = create_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_2,
                            LOCATION, True)
        if self.is_live:
            time.sleep(10)

        body = PoolChangeRequest(new_pool_resource_id=pool2.id)
        self.client.volumes.begin_pool_change(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                              TEST_VOL_1, body).wait()
        volume = self.client.volumes.get(TEST_RG, TEST_ACC_1, TEST_POOL_2,
                                         TEST_VOL_1)
        assert volume.name == TEST_ACC_1 + "/" + TEST_POOL_2 + "/" + TEST_VOL_1

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        assert len(list(volume_list)) == 0

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_2,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_2,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)
    def test_pool_change(self):
        create_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_1,
                      TEST_VOL_1,
                      live=self.is_live)
        pool2 = create_pool(self.client, TEST_RG, TEST_ACC_1, TEST_POOL_2,
                            LOCATION, True)
        if self.is_live:
            time.sleep(10)

        body = PoolChangeRequest(new_pool_resource_id=pool2.id)
        self.client.volumes.begin_pool_change(TEST_RG, TEST_ACC_1, TEST_POOL_1,
                                              TEST_VOL_1, body).wait()
        volume = self.client.volumes.get(TEST_RG, TEST_ACC_1, TEST_POOL_2,
                                         TEST_VOL_1)
        self.assertEqual(volume.name,
                         TEST_ACC_1 + "/" + TEST_POOL_2 + "/" + TEST_VOL_1)

        volume_list = self.client.volumes.list(TEST_RG, TEST_ACC_1,
                                               TEST_POOL_1)
        self.assertEqual(len(list(volume_list)), 0)

        delete_volume(self.client,
                      TEST_RG,
                      TEST_ACC_1,
                      TEST_POOL_2,
                      TEST_VOL_1,
                      live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_1,
                    live=self.is_live)
        delete_pool(self.client,
                    TEST_RG,
                    TEST_ACC_1,
                    TEST_POOL_2,
                    live=self.is_live)
        delete_account(self.client, TEST_RG, TEST_ACC_1, live=self.is_live)