示例#1
0
def wait_for_no_anf_resource(client, resourceId, intervalInSec=10, retries=60):
    for i in range(0, retries):
        time.sleep(intervalInSec)
        try:
            if resource_uri_utils.is_anf_snapshot(resourceId):
                client.snapshots.get(
                    resource_uri_utils.get_resource_group(resourceId),
                    resource_uri_utils.get_anf_account(resourceId),
                    resource_uri_utils.get_anf_capacity_pool(resourceId),
                    resource_uri_utils.get_anf_volume(resourceId),
                    resource_uri_utils.get_anf_snapshot(resourceId)
                )
            elif resource_uri_utils.is_anf_volume(resourceId):
                client.volumes.get(
                    resource_uri_utils.get_resource_group(resourceId),
                    resource_uri_utils.get_anf_account(resourceId),
                    resource_uri_utils.get_anf_capacity_pool(resourceId),
                    resource_uri_utils.get_anf_volume(resourceId)
                )
            elif resource_uri_utils.is_anf_capacity_pool(resourceId):
                client.pools.get(
                    resource_uri_utils.get_resource_group(resourceId),
                    resource_uri_utils.get_anf_account(resourceId),
                    resource_uri_utils.get_anf_capacity_pool(resourceId)
                )
            elif resource_uri_utils.is_anf_account(resourceId):
                client.accounts.get(
                    resource_uri_utils.get_resource_group(resourceId),
                    resource_uri_utils.get_anf_account(resourceId)
                )
        except CloudError as ex:
            break
示例#2
0
def wait_for_anf_resource(client,
                          resource_id,
                          interval_in_sec=10,
                          retries=60,
                          replication=None):
    """Waits for specific anf resource start existing

    This function checks if a specific ANF resource that was recently created
    is already being able to be polled. It breaks the wait if resource is found
    or if polling reached out maximum retries.

    Args:
        client (NetAppManagementClient): Azure Resource Provider
            Client designed to interact with ANF resources
        resource_id (string): Resource Id of the resource to be checked upon
        interval_in_sec (int): Interval used between checks
        retires (int): Number of times a poll will be performed
    """

    for i in range(0, retries):
        time.sleep(interval_in_sec)
        try:
            if resource_uri_utils.is_anf_snapshot(resource_id):
                client.snapshots.get(
                    resource_uri_utils.get_resource_group(resource_id),
                    resource_uri_utils.get_anf_account(resource_id),
                    resource_uri_utils.get_anf_capacity_pool(resource_id),
                    resource_uri_utils.get_anf_volume(resource_id),
                    resource_uri_utils.get_anf_snapshot(resource_id))
            elif resource_uri_utils.is_anf_volume(resource_id):
                volume = client.volumes.get(
                    resource_uri_utils.get_resource_group(resource_id),
                    resource_uri_utils.get_anf_account(resource_id),
                    resource_uri_utils.get_anf_capacity_pool(resource_id),
                    resource_uri_utils.get_anf_volume(resource_id))

                if replication == True:
                    if volume.data_protection == None:
                        continue
            elif resource_uri_utils.is_anf_capacity_pool(resource_id):
                client.pools.get(
                    resource_uri_utils.get_resource_group(resource_id),
                    resource_uri_utils.get_anf_account(resource_id),
                    resource_uri_utils.get_anf_capacity_pool(resource_id))
            elif resource_uri_utils.is_anf_account(resource_id):
                client.accounts.get(
                    resource_uri_utils.get_resource_group(resource_id),
                    resource_uri_utils.get_anf_account(resource_id))

            break
        except ResourceNotFoundError as ex:
            pass
示例#3
0
def wait_for_no_anf_resource(client, resource_id, interval_in_sec=10,
                             retries=60):
    """Waits for specific anf resource don't exist

    This function checks if a specific ANF resource that was recently delete
    stops existing. It breaks the wait if resource is not found anymore or
    if polling reached out maximum retries.

    Args:
        client (AzureNetAppFilesManagementClient): Azure Resource Provider
            Client designed to interact with ANF resources
        resource_id (string): Resource Id of the resource to be checked upon
        interval_in_sec (int): Interval used between checks
        retires (int): Number of times a poll will be performed
    """

    for i in range(0, retries):
        time.sleep(interval_in_sec)
        try:
            if resource_uri_utils.is_anf_snapshot(resource_id):
                client.snapshots.get(
                    resource_uri_utils.get_resource_group(resource_id),
                    resource_uri_utils.get_anf_account(resource_id),
                    resource_uri_utils.get_anf_capacity_pool(resource_id),
                    resource_uri_utils.get_anf_volume(resource_id),
                    resource_uri_utils.get_anf_snapshot(resource_id)
                )
            elif resource_uri_utils.is_anf_volume(resource_id):
                client.volumes.get(
                    resource_uri_utils.get_resource_group(resource_id),
                    resource_uri_utils.get_anf_account(resource_id),
                    resource_uri_utils.get_anf_capacity_pool(resource_id),
                    resource_uri_utils.get_anf_volume(resource_id)
                )
            elif resource_uri_utils.is_anf_capacity_pool(resource_id):
                client.pools.get(
                    resource_uri_utils.get_resource_group(resource_id),
                    resource_uri_utils.get_anf_account(resource_id),
                    resource_uri_utils.get_anf_capacity_pool(resource_id)
                )
            elif resource_uri_utils.is_anf_account(resource_id):
                client.accounts.get(
                    resource_uri_utils.get_resource_group(resource_id),
                    resource_uri_utils.get_anf_account(resource_id)
                )
        except CloudError as ex:
            break