Exemple #1
0
def block_blob_tier_validator(namespace):
    if not namespace.tier:
        return

    if namespace.blob_type != 'block' and namespace.tier:
        raise ValueError('Blob tier is only applicable to block blobs on standard storage accounts.')

    try:
        namespace.tier = getattr(get_sdk(ResourceType.DATA_STORAGE, 'blob.models#StandardBlobTier'), namespace.tier)
    except AttributeError:
        from azure.cli.command_modules.storage.util import get_blob_tier_names
        raise ValueError('Unknown block blob tier name. Choose among {}'.format(', '.join(
            get_blob_tier_names('StandardBlobTier'))))
Exemple #2
0
def block_blob_tier_validator(namespace):
    if not namespace.tier:
        return

    if namespace.blob_type != 'block' and namespace.tier:
        raise ValueError(
            'Blob tier is only applicable to block blobs on standard storage accounts.'
        )

    try:
        namespace.tier = getattr(
            get_sdk(ResourceType.DATA_STORAGE, 'blob.models#StandardBlobTier'),
            namespace.tier)
    except AttributeError:
        from azure.cli.command_modules.storage.util import get_blob_tier_names
        raise ValueError(
            'Unknown block blob tier name. Choose among {}'.format(', '.join(
                get_blob_tier_names('StandardBlobTier'))))
Exemple #3
0
              options_list=('--type', '-t'), validator=validate_blob_type, **enum_choice_list(blob_types.keys()))
    c.reg_arg('maxsize_condition', help='The max length in bytes permitted for an append blob.')
    c.reg_arg('validate_content',
              help='Specifies that an MD5 hash shall be calculated for each chunk of the blob and verified by the '
                   'service when the chunk has arrived.',
              resource_type=ResourceType.DATA_STORAGE,
              min_api='2016-05-31')

    from azure.cli.command_modules.storage.util import get_blob_tier_names
    c.reg_arg('tier',
              help='A page blob tier value to set the blob to. The tier correlates to the size of the blob and number '
                   'of allowed IOPS. This is only applicable to page blobs on premium storage accounts.',
              resource_type=ResourceType.DATA_STORAGE,
              min_api='2017-04-17',
              validator=page_blob_tier_validator,
              **enum_choice_list(get_blob_tier_names('PremiumPageBlobTier')))

with CommandContext('storage blob set-tier') as c:
    c.reg_arg('blob_type', help="The blob's type", options_list=('--type', '-t'), **enum_choice_list(['block', 'page']))
    c.reg_arg('tier', help='The tier value to set the blob to.', validator=blob_tier_validator)
    c.reg_arg('timeout', help='The timeout parameter is expressed in seconds. This method may make multiple calls to '
                              'the Azure service and the timeout will apply to each call individually.',
              type=int)


# TODO: Remove once #807 is complete. Smart Create Generation requires this parameter.
register_extra_cli_argument('storage blob upload', '_subscription_id', options_list=('--subscription',), help=argparse.SUPPRESS)

# BLOB DOWNLOAD-BATCH PARAMETERS
register_cli_argument('storage blob download-batch', 'destination', options_list=('--destination', '-d'))
register_cli_argument('storage blob download-batch', 'source', options_list=('--source', '-s'),