Example #1
0
    help='the resource group where the policy will be applied')
register_cli_argument('policy definition',
                      'policy_definition_name',
                      arg_type=existing_policy_definition_name_type)
register_cli_argument('policy definition create',
                      'name',
                      options_list=('--name', '-n'),
                      help='name of the new policy definition')
register_cli_argument(
    'policy definition',
    'rules',
    help='JSON formatted string or a path to a file or uri with such content',
    type=file_type,
    completer=FilesCompleter())

with VersionConstraint(ResourceType.MGMT_RESOURCE_POLICY,
                       min_api='2016-12-01') as c:
    from azure.mgmt.resource.policy.models import PolicyMode
    c.register_cli_argument(
        'policy definition',
        'params',
        help=
        'JSON formatted string or a path to a file or uri with parameter definitions',
        type=file_type,
        completer=FilesCompleter())
    c.register_cli_argument('policy definition create',
                            'mode',
                            options_list=('--mode', '-m'),
                            help='mode of the new policy definition.',
                            **enum_choice_list(PolicyMode))

register_cli_argument('policy definition',
Example #2
0
register_cli_argument('vmss create', 'vmss_name', name_arg_type, id_part=None, help='Name of the virtual machine scale set.', validator=process_vmss_create_namespace)
register_cli_argument('vmss create', 'load_balancer', help='Name to use when creating a new load balancer (default) or referencing an existing one. Can also reference an existing load balancer by ID or specify "" for none.', options_list=['--load-balancer', '--lb'], arg_group='Network Balancer')
register_cli_argument('vmss create', 'application_gateway', help='Name to use when creating a new application gateway (default) or referencing an existing one. Can also reference an existing application gateway by ID or specify "" for none.', options_list=['--app-gateway'], arg_group='Network Balancer')
register_cli_argument('vmss create', 'backend_pool_name', help='Name to use for the backend pool when creating a new load balancer or application gateway.', arg_group='Network Balancer')
register_cli_argument('vmss create', 'nat_pool_name', help='Name to use for the NAT pool when creating a new load balancer.', options_list=['--lb-nat-pool-name', '--nat-pool-name'], arg_group='Network Balancer')
register_cli_argument('vmss create', 'backend_port', help='When creating a new load balancer, backend port to open with NAT rules (Defaults to 22 on Linux and 3389 on Windows). When creating an application gateway, the backend port to use for the backend HTTP settings.', type=int, arg_group='Network Balancer')
register_cli_argument('vmss create', 'app_gateway_subnet_address_prefix', help='The subnet IP address prefix to use when creating a new application gateway in CIDR format.', arg_group='Network Balancer')
register_cli_argument('vmss create', 'app_gateway_sku', help='SKU when creating a new application gateway.', arg_group='Network Balancer')
register_cli_argument('vmss create', 'app_gateway_capacity', help='The number of instances to use when creating a new application gateway.', arg_group='Network Balancer')
register_cli_argument('vmss create', 'instance_count', help='Number of VMs in the scale set.', type=int)
register_cli_argument('vmss create', 'disable_overprovision', help='Overprovision option (see https://azure.microsoft.com/en-us/documentation/articles/virtual-machine-scale-sets-overview/ for details).', action='store_true')
register_cli_argument('vmss create', 'upgrade_policy_mode', help=None, **enum_choice_list(UpgradeMode))
register_cli_argument('vmss create', 'vm_sku', help='Size of VMs in the scale set.  See https://azure.microsoft.com/en-us/pricing/details/virtual-machines/ for size info.')
register_cli_argument('vmss create', 'nsg', help='reference to an existing Network Security Group by ID, or name if in the same resource group', arg_group='Network')
with VersionConstraint(ResourceType.MGMT_NETWORK, min_api='2017-08-01') as c:
    c.register_cli_argument('vmss create', 'load_balancer_sku', help='SKU when creating a new Load Balancer.', arg_group='Network Balancer', options_list=['--lb-sku'], default='Basic')  # **model_choice_list(ResourceType.MGMT_NETWORK, 'LoadBalancerSkuName'))

with VersionConstraint(ResourceType.MGMT_COMPUTE, min_api='2017-03-30') as c:
    c.register_cli_argument('vmss create', 'public_ip_per_vm', action='store_true', help="Each VM instance will have a public ip. For security, you can use '--nsg' to apply appropriate rules", arg_group='Network')
    c.register_cli_argument('vmss create', 'vm_domain_name', help="domain name of VM instances, once configured, the FQDN is 'vm<vm-index>.<vm-domain-name>.<..rest..>'", arg_group='Network')
    c.register_cli_argument('vmss create', 'dns_servers', nargs='+', help="space separated IP addresses of DNS servers, e.g. 10.0.0.5 10.0.0.6", arg_group='Network')

register_cli_argument('vm encryption', 'volume_type', help='Type of volume that the encryption operation is performed on', **enum_choice_list(['DATA', 'OS', 'ALL']))
register_cli_argument('vm encryption', 'force', action='store_true', help='continue with encryption operations regardless of the warnings')
register_cli_argument('vm encryption', 'disk_encryption_keyvault', validator=process_disk_encryption_namespace)

existing_disk_name = CliArgumentType(overrides=name_arg_type, help='The name of the managed disk', completer=get_resource_name_completion_list('Microsoft.Compute/disks'), id_part='name')
register_cli_argument('disk', 'disk_name', existing_disk_name, completer=get_resource_name_completion_list('Microsoft.Compute/disks'))
register_cli_argument('disk', 'name', arg_type=name_arg_type)
register_cli_argument('disk', 'sku', arg_type=disk_sku)
Example #3
0
register_cli_argument('storage blob incremental-copy start', 'source_lease_id', arg_group='Copy Source')

register_cli_argument('storage blob delete', 'delete_snapshots', **enum_choice_list(list(delete_snapshot_types.keys())))

register_cli_argument('storage blob exists', 'blob_name', required=True)

with CommandContext('storage blob list') as c:
    c.reg_arg('include',
              help='Specifies additional datasets to include: (c)opy-info, (m)etadata, (s)napshots. Can be combined.',
              validator=validate_included_datasets)
    c.reg_arg('num_results', type=int)

for item in ['download', 'upload']:
    register_cli_argument('storage blob {}'.format(item), 'file_path', options_list=('--file', '-f'), type=file_type, completer=FilesCompleter())
    register_cli_argument('storage blob {}'.format(item), 'max_connections', type=int)
    with VersionConstraint(ResourceType.DATA_STORAGE, min_api='2016-05-31') as c:
        c.register_cli_argument('storage blob {}'.format(item), 'validate_content', action='store_true')

for item in ['update', 'upload', 'upload-batch']:
    register_content_settings_argument('storage blob {}'.format(item), BlobContentSettings, item == 'update')

register_cli_argument('storage blob upload', 'blob_type', help="Defaults to 'page' for *.vhd files, or 'block' otherwise.", options_list=('--type', '-t'), validator=validate_blob_type, **enum_choice_list(blob_types.keys()))
register_cli_argument('storage blob upload', 'maxsize_condition', help='The max length in bytes permitted for an append blob.')
with VersionConstraint(ResourceType.DATA_STORAGE, min_api='2016-05-31') as c:
    c.register_cli_argument('storage blob upload', '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.')

# 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'))
Example #4
0
    cli_command(__name__, 'network application-gateway {} delete'.format(alias), 'azure.cli.command_modules.network._util#{}'.format(delete_network_resource_property_entry('application_gateways', subresource)), no_wait_param='no_wait')
    cli_command(__name__, 'network application-gateway {} create'.format(alias), custom_path + 'create_ag_{}'.format(_make_singular(subresource)), no_wait_param='no_wait')
    cli_generic_update_command(__name__, 'network application-gateway {} update'.format(alias),
                               ag_path + 'get', ag_path + 'create_or_update', cf_application_gateways,
                               no_wait_param='raw',
                               custom_function_op=custom_path + 'update_ag_{}'.format(_make_singular(subresource)),
                               child_collection_prop_name=subresource)

if supported_api_version(ResourceType.MGMT_NETWORK, min_api='2017-06-01'):
    cli_command(__name__, 'network application-gateway ssl-policy set', custom_path + 'set_ag_ssl_policy_2017_06_01', no_wait_param='no_wait')
else:
    cli_command(__name__, 'network application-gateway ssl-policy set', custom_path + 'set_ag_ssl_policy_2017_03_01', no_wait_param='no_wait')

cli_command(__name__, 'network application-gateway ssl-policy show', custom_path + 'show_ag_ssl_policy', exception_handler=empty_on_404)

with VersionConstraint(ResourceType.MGMT_NETWORK, min_api='2017-06-01') as c:
    c.cli_command(__name__, 'network application-gateway ssl-policy list-options', ag_path + 'list_available_ssl_options', cf_application_gateways)
    c.cli_command(__name__, 'network application-gateway ssl-policy predefined list', ag_path + 'list_available_ssl_predefined_policies', cf_application_gateways)
    c.cli_command(__name__, 'network application-gateway ssl-policy predefined show', ag_path + 'get_ssl_predefined_policy', cf_application_gateways)

cli_command(__name__, 'network application-gateway url-path-map rule create', custom_path + 'create_ag_url_path_map_rule', no_wait_param='no_wait')
cli_command(__name__, 'network application-gateway url-path-map rule delete', custom_path + 'delete_ag_url_path_map_rule', no_wait_param='no_wait')

if supported_api_version(ResourceType.MGMT_NETWORK, min_api='2017-03-01'):
    cli_command(__name__, 'network application-gateway waf-config set', custom_path + 'set_ag_waf_config_2017_03_01', no_wait_param='no_wait')
else:
    cli_command(__name__, 'network application-gateway waf-config set', custom_path + 'set_ag_waf_config_2016_09_01', no_wait_param='no_wait')

cli_command(__name__, 'network application-gateway waf-config show', custom_path + 'show_ag_waf_config', exception_handler=empty_on_404)

if supported_api_version(ResourceType.MGMT_NETWORK, min_api='2017-03-01'):
Example #5
0
cli_command(__name__, 'storage account show-usage',
            custom_path + 'show_storage_account_usage')
cli_command(__name__, 'storage account show-connection-string',
            custom_path + 'show_storage_account_connection_string')
cli_command(__name__,
            'storage account keys renew',
            mgmt_path + 'regenerate_key',
            factory,
            transform=lambda x: getattr(x, 'keys', x))
cli_command(__name__,
            'storage account keys list',
            mgmt_path + 'list_keys',
            factory,
            transform=lambda x: getattr(x, 'keys', x))

with VersionConstraint(ResourceType.MGMT_STORAGE, min_api='2017-06-01') as c:
    c.cli_command(__name__, 'storage account network-rule add',
                  custom_path + 'add_network_rule', factory)
    c.cli_command(__name__, 'storage account network-rule remove',
                  custom_path + 'remove_network_rule', factory)
    c.cli_command(__name__, 'storage account network-rule list',
                  custom_path + 'list_network_rules', factory)

if supported_api_version(ResourceType.MGMT_STORAGE, max_api='2015-06-15'):
    cli_command(__name__, 'storage account create',
                custom_path + 'create_storage_account_with_account_type')
else:
    cli_command(__name__, 'storage account create',
                custom_path + 'create_storage_account')

if supported_api_version(ResourceType.MGMT_STORAGE, min_api='2016-12-01'):
Example #6
0
    "Scale set name. You can configure the default using `az configure --defaults vmss=<name>`",
    id_part='name')
disk_sku = CliArgumentType(required=False,
                           help='underlying storage sku',
                           **enum_choice_list(['Premium_LRS', 'Standard_LRS']))

# ARGUMENT REGISTRATION

register_cli_argument('vm', 'vm_name', existing_vm_name)
register_cli_argument('vm', 'size', completer=get_vm_size_completion_list)
for scope in ['vm', 'disk', 'snapshot', 'image']:
    register_cli_argument(scope, 'tags', tags_type)
register_cli_argument('vm', 'name', arg_type=name_arg_type)

with VersionConstraint(ResourceType.MGMT_COMPUTE,
                       min_api='2017-03-30',
                       operation_group='virtual_machines') as c:
    c.register_cli_argument('vm', 'zone', zone_type)

with VersionConstraint(ResourceType.MGMT_COMPUTE,
                       min_api='2017-03-30',
                       operation_group='disks') as c:
    c.register_cli_argument(
        'disk', 'zone', zone_type, options_list=['--zone']
    )  # TODO: --size-gb currently has claimed -z. We can do a breaking change later if we want to.

with VersionConstraint(ResourceType.MGMT_COMPUTE,
                       min_api='2017-03-30',
                       operation_group='virtual_machine_scale_sets') as c:
    c.register_cli_argument('vmss', 'zones', zones_type)