def transform_vpn_connection_create_output(result): from azure.cli.core.commands import DeploymentOutputLongRunningOperation from msrest.pipeline import ClientRawResponse from msrestazure.azure_operation import AzureOperationPoller if isinstance(result, AzureOperationPoller): # normally returns a LRO poller result = DeploymentOutputLongRunningOperation('Starting network vpn-connection create')(result) return result['resource'] elif isinstance(result, ClientRawResponse): # returns a raw response if --no-wait used return # returns a plain response (not a poller) if --validate used return result
__name__, 'vmss list-skus', mgmt_path.format('virtual_machine_scale_sets_operations', 'VirtualMachineScaleSetsOperations', 'list_skus'), cf_vmss) cli_command( __name__, 'vmss list-instances', mgmt_path.format('virtual_machine_scale_set_vms_operations', 'VirtualMachineScaleSetVMsOperations', 'list'), cf_vmss_vm) cli_command( __name__, 'vmss create', custom_path.format('create_vmss'), transform=DeploymentOutputLongRunningOperation('Starting vmss create'), no_wait_param='no_wait', exception_handler=handle_long_running_operation_exception, table_transformer=deployment_validate_table_format) cli_command(__name__, 'vmss deallocate', custom_path.format('deallocate_vmss'), no_wait_param='no_wait') cli_command(__name__, 'vmss delete-instances', custom_path.format('delete_vmss_instances'), no_wait_param='no_wait') cli_command( __name__, 'vmss get-instance-view', custom_path.format('get_vmss_instance_view'),
remove_dns_txt_record, remove_dns_mx_record, list_traffic_manager_endpoints, export_zone, import_zone) from ._factory import _network_client_factory # pylint: disable=line-too-long # Application gateways factory = lambda _: _network_client_factory().application_gateways cli_command('network application-gateway delete', ApplicationGatewaysOperations.delete, factory) cli_command('network application-gateway show', ApplicationGatewaysOperations.get, factory) cli_command('network application-gateway list', list_application_gateways) cli_command('network application-gateway start', ApplicationGatewaysOperations.start, factory) cli_command('network application-gateway stop', ApplicationGatewaysOperations.stop, factory) cli_generic_update_command('network application-gateway update', ApplicationGatewaysOperations.get, ApplicationGatewaysOperations.create_or_update, factory) factory = lambda _: get_mgmt_service_client(AppGatewayClient).app_gateway cli_command('network application-gateway create', AppGatewayOperations.create_or_update, factory, transform=DeploymentOutputLongRunningOperation('Starting network application-gateway create')) property_map = { 'ssl_certificates': 'ssl-cert', 'frontend_ip_configurations': 'frontend-ip', 'frontend_ports': 'frontend-port', 'backend_address_pools': 'address-pool', 'backend_http_settings_collection': 'http-settings', 'http_listeners': 'http-listener', 'request_routing_rules': 'rule', 'probes': 'probe', 'url_path_maps': 'url-path-map' } for subresource, alias in property_map.items(): cli_command('network application-gateway {} list'.format(alias), list_network_resource_property('application_gateways', subresource)) cli_command('network application-gateway {} show'.format(alias), get_network_resource_property_entry('application_gateways', subresource))
def load_command_table(self, _): # region Command Types network_ag_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.{}', client_factory=cf_application_gateways ) network_util = CliCommandType( operations_tmpl='azure.cli.command_modules.network._util#{}', client_factory=None ) network_asg_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.application_security_groups_operations#ApplicationSecurityGroupsOperations.{}', client_factory=cf_application_security_groups ) network_ddos_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.ddos_protection_plans_operations#DdosProtectionPlansOperations.{}', client_factory=cf_ddos_protection_plans ) network_dns_zone_sdk = CliCommandType( operations_tmpl='azure.mgmt.dns.operations.zones_operations#ZonesOperations.{}', client_factory=cf_dns_mgmt_zones, resource_type=ResourceType.MGMT_NETWORK_DNS ) network_dns_record_set_sdk = CliCommandType( operations_tmpl='azure.mgmt.dns.operations.record_sets_operations#RecordSetsOperations.{}', client_factory=cf_dns_mgmt_record_sets, resource_type=ResourceType.MGMT_NETWORK_DNS ) network_dns_reference_sdk = CliCommandType( operations_tmpl='azure.mgmt.dns.operations.dns_resource_reference_operations#DnsResourceReferenceOperations.{}', client_factory=cf_dns_references, resource_type=ResourceType.MGMT_NETWORK_DNS, min_api='2018-05-01' ) network_endpoint_service_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.available_endpoint_services_operations#AvailableEndpointServicesOperations.{}', client_factory=cf_endpoint_services, min_api='2017-06-01' ) network_er_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.express_route_circuits_operations#ExpressRouteCircuitsOperations.{}', client_factory=cf_express_route_circuits, min_api='2016-09-01' ) network_erca_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.express_route_circuit_authorizations_operations#ExpressRouteCircuitAuthorizationsOperations.{}', client_factory=cf_express_route_circuit_authorizations, min_api='2016-09-01' ) network_erconn_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.express_route_circuit_connections_operations#ExpressRouteCircuitConnectionsOperations.{}', client_factory=cf_express_route_circuit_connections, min_api='2018-07-01' ) network_ersp_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.express_route_service_providers_operations#ExpressRouteServiceProvidersOperations.{}', client_factory=cf_express_route_service_providers, min_api='2016-09-01' ) network_er_peering_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.express_route_circuit_peerings_operations#ExpressRouteCircuitPeeringsOperations.{}', client_factory=cf_express_route_circuit_peerings ) network_interface_endpoint_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.interface_endpoints_operations#InterfaceEndpointsOperations.{}', client_factory=cf_interface_endpoints, min_api='2018-08-01' ) network_lb_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.load_balancers_operations#LoadBalancersOperations.{}', client_factory=cf_load_balancers ) network_lgw_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.local_network_gateways_operations#LocalNetworkGatewaysOperations.{}', client_factory=cf_local_network_gateways ) network_nic_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.network_interfaces_operations#NetworkInterfacesOperations.{}', client_factory=cf_network_interfaces ) network_profile_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.network_profiles_operations#NetworkProfilesOperations.{}', client_factory=cf_network_profiles, min_api='2018-08-01' ) network_nsg_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.network_security_groups_operations#NetworkSecurityGroupsOperations.{}', client_factory=cf_network_security_groups ) network_nsg_rule_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.security_rules_operations#SecurityRulesOperations.{}', client_factory=cf_security_rules ) network_public_ip_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.public_ip_addresses_operations#PublicIPAddressesOperations.{}', client_factory=cf_public_ip_addresses ) network_public_ip_prefix_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.public_ip_prefixes_operations#PublicIPPrefixesOperations.{}', client_factory=cf_public_ip_prefixes, min_api='2018-07-01' ) network_rf_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations#RouteFiltersOperations.{}', client_factory=cf_route_filters, min_api='2016-12-01' ) network_rfr_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations#RouteFilterRulesOperations.{}', client_factory=cf_route_filter_rules, min_api='2016-12-01' ) network_rt_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.route_tables_operations#RouteTablesOperations.{}', client_factory=cf_route_tables ) network_subnet_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.subnets_operations#SubnetsOperations.{}', client_factory=cf_subnets ) network_tmp_sdk = CliCommandType( operations_tmpl='azure.mgmt.trafficmanager.operations.profiles_operations#ProfilesOperations.{}', client_factory=cf_traffic_manager_mgmt_profiles ) network_tme_sdk = CliCommandType( operations_tmpl='azure.mgmt.trafficmanager.operations.endpoints_operations#EndpointsOperations.{}', client_factory=cf_traffic_manager_mgmt_endpoints ) network_vgw_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.virtual_network_gateways_operations#VirtualNetworkGatewaysOperations.{}', client_factory=cf_virtual_network_gateways ) network_vnet_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.virtual_networks_operations#VirtualNetworksOperations.{}', client_factory=cf_virtual_networks ) network_vnet_peering_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.virtual_network_peerings_operations#VirtualNetworkPeeringsOperations.{}', client_factory=cf_virtual_network_peerings ) network_vpn_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.virtual_network_gateway_connections_operations#VirtualNetworkGatewayConnectionsOperations.{}', client_factory=cf_virtual_network_gateway_connections ) network_watcher_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.network_watchers_operations#NetworkWatchersOperations.{}', client_factory=cf_network_watcher ) network_watcher_cm_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.connection_monitors_operations#ConnectionMonitorsOperations.{}', client_factory=cf_connection_monitor ) network_watcher_pc_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.packet_captures_operations#PacketCapturesOperations.{}', client_factory=cf_packet_capture ) network_sepd_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.service_endpoint_policy_definitions_operations#ServiceEndpointPolicyDefinitionsOperations.{}', client_factory=cf_service_endpoint_policy_definitions, min_api='2018-07-01' ) network_sepp_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.service_endpoint_policies_operations#ServiceEndpointPoliciesOperations.{}', client_factory=cf_service_endpoint_policies, min_api='2018-07-01' ) network_custom = CliCommandType(operations_tmpl='azure.cli.command_modules.network.custom#{}') # endregion # region NetworkRoot usage_path = 'azure.mgmt.network.operations.usages_operations#UsagesOperations.{}' with self.command_group('network') as g: g.command('list-usages', 'list', operations_tmpl=usage_path, client_factory=cf_usages, transform=transform_network_usage_list, table_transformer=transform_network_usage_table) # endregion # region ApplicationGateways with self.command_group('network application-gateway', network_ag_sdk) as g: g.custom_command('create', 'create_application_gateway', transform=DeploymentOutputLongRunningOperation(self.cli_ctx), supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_ag_create_namespace, exception_handler=handle_template_based_exception) g.command('delete', 'delete', supports_no_wait=True) g.show_command('show', 'get') g.custom_command('list', 'list_application_gateways') g.command('start', 'start') g.command('stop', 'stop') g.command('show-backend-health', 'backend_health', min_api='2016-09-01') g.generic_update_command('update', supports_no_wait=True, custom_func_name='update_application_gateway') g.wait_command('wait') subresource_properties = [ {'prop': 'authentication_certificates', 'name': 'auth-cert'}, {'prop': 'ssl_certificates', 'name': 'ssl-cert'}, {'prop': 'frontend_ip_configurations', 'name': 'frontend-ip'}, {'prop': 'frontend_ports', 'name': 'frontend-port'}, {'prop': 'backend_address_pools', 'name': 'address-pool'}, {'prop': 'backend_http_settings_collection', 'name': 'http-settings', 'validator': process_ag_http_settings_create_namespace}, {'prop': 'http_listeners', 'name': 'http-listener', 'validator': process_ag_listener_create_namespace}, {'prop': 'request_routing_rules', 'name': 'rule', 'validator': process_ag_rule_create_namespace}, {'prop': 'probes', 'name': 'probe'}, {'prop': 'url_path_maps', 'name': 'url-path-map', 'validator': process_ag_url_path_map_create_namespace} ] def _make_singular(value): try: if value.endswith('ies'): value = value[:-3] + 'y' elif value.endswith('s'): value = value[:-1] return value except AttributeError: return value for kwargs in subresource_properties: alias = kwargs['name'] subresource = kwargs['prop'] create_validator = kwargs.get('validator', None) with self.command_group('network application-gateway {}'.format(alias), network_util) as g: g.command('list', list_network_resource_property('application_gateways', subresource)) g.show_command('show', get_network_resource_property_entry('application_gateways', subresource)) g.command('delete', delete_network_resource_property_entry('application_gateways', subresource), supports_no_wait=True) g.custom_command('create', 'create_ag_{}'.format(_make_singular(subresource)), supports_no_wait=True, validator=create_validator) g.generic_update_command('update', command_type=network_ag_sdk, supports_no_wait=True, custom_func_name='update_ag_{}'.format(_make_singular(subresource)), child_collection_prop_name=subresource, validator=create_validator) with self.command_group('network application-gateway redirect-config', network_util, min_api='2017-06-01') as g: subresource = 'redirect_configurations' g.command('list', list_network_resource_property('application_gateways', subresource)) g.show_command('show', get_network_resource_property_entry('application_gateways', subresource)) g.command('delete', delete_network_resource_property_entry('application_gateways', subresource), supports_no_wait=True) g.custom_command('create', 'create_ag_{}'.format(_make_singular(subresource)), supports_no_wait=True, doc_string_source='ApplicationGatewayRedirectConfiguration') g.generic_update_command('update', command_type=network_ag_sdk, client_factory=cf_application_gateways, supports_no_wait=True, custom_func_name='update_ag_{}'.format(_make_singular(subresource)), child_collection_prop_name=subresource, doc_string_source='ApplicationGatewayRedirectConfiguration') with self.command_group('network application-gateway ssl-policy') as g: g.custom_command('set', 'set_ag_ssl_policy_2017_06_01', min_api='2017-06-01', supports_no_wait=True, validator=process_ag_ssl_policy_set_namespace, doc_string_source='ApplicationGatewaySslPolicy') g.custom_command('set', 'set_ag_ssl_policy_2017_03_01', max_api='2017-03-01', supports_no_wait=True, validator=process_ag_ssl_policy_set_namespace) g.custom_show_command('show', 'show_ag_ssl_policy') with self.command_group('network application-gateway ssl-policy', network_ag_sdk, min_api='2017-06-01') as g: g.command('list-options', 'list_available_ssl_options') g.command('predefined list', 'list_available_ssl_predefined_policies') g.show_command('predefined show', 'get_ssl_predefined_policy') with self.command_group('network application-gateway url-path-map rule') as g: g.custom_command('create', 'create_ag_url_path_map_rule', supports_no_wait=True, validator=process_ag_url_path_map_rule_create_namespace) g.custom_command('delete', 'delete_ag_url_path_map_rule', supports_no_wait=True) with self.command_group('network application-gateway waf-config') as g: g.custom_command('set', 'set_ag_waf_config_2017_03_01', min_api='2017-03-01', supports_no_wait=True) g.custom_command('set', 'set_ag_waf_config_2016_09_01', max_api='2016-09-01', supports_no_wait=True) g.custom_show_command('show', 'show_ag_waf_config') g.custom_command('list-rule-sets', 'list_ag_waf_rule_sets', min_api='2017-03-01', client_factory=cf_application_gateways, table_transformer=transform_waf_rule_sets_table_output) # endregion # region ApplicationSecurityGroups with self.command_group('network asg', network_asg_sdk, client_factory=cf_application_security_groups, min_api='2017-09-01') as g: g.custom_command('create', 'create_asg') g.show_command('show', 'get') g.command('list', 'list_all') g.command('delete', 'delete') g.generic_update_command('update', custom_func_name='update_asg') # endregion # region DdosProtectionPlans with self.command_group('network ddos-protection', network_ddos_sdk, min_api='2018-02-01') as g: g.custom_command('create', 'create_ddos_plan') g.command('delete', 'delete') g.custom_command('list', 'list_ddos_plans') g.show_command('show', 'get') g.generic_update_command('update', custom_func_name='update_ddos_plan') # endregion # region DNS with self.command_group('network dns', network_dns_reference_sdk) as g: g.command('list-references', 'get_by_target_resources') with self.command_group('network dns zone', network_dns_zone_sdk) as g: g.command('delete', 'delete', confirmation=True) g.show_command('show', 'get', table_transformer=transform_dns_zone_table_output) g.custom_command('list', 'list_dns_zones', table_transformer=transform_dns_zone_table_output) g.custom_command('import', 'import_zone') g.custom_command('export', 'export_zone') g.custom_command('create', 'create_dns_zone', client_factory=cf_dns_mgmt_zones) g.generic_update_command('update', custom_func_name='update_dns_zone') with self.command_group('network dns record-set') as g: g.custom_command('list', 'list_dns_record_set', client_factory=cf_dns_mgmt_record_sets, transform=transform_dns_record_set_output) api_version = str(get_api_version(self.cli_ctx, ResourceType.MGMT_NETWORK_DNS)) api_version = api_version.replace('-', '_') dns_doc_string = 'azure.mgmt.dns.v' + api_version + '.operations#RecordSetsOperations.create_or_update' supported_records = ['a', 'aaaa', 'mx', 'ns', 'ptr', 'srv', 'txt'] if self.supported_api_version(resource_type=ResourceType.MGMT_NETWORK_DNS, min_api='2018-02-01'): supported_records.append('caa') for record in supported_records: with self.command_group('network dns record-set {}'.format(record), network_dns_record_set_sdk, resource_type=ResourceType.MGMT_NETWORK_DNS) as g: g.show_command('show', 'get', transform=transform_dns_record_set_output) g.command('delete', 'delete', confirmation=True) g.custom_command('list', 'list_dns_record_set', client_factory=cf_dns_mgmt_record_sets, transform=transform_dns_record_set_output, table_transformer=transform_dns_record_set_table_output) g.custom_command('create', 'create_dns_record_set', transform=transform_dns_record_set_output, doc_string_source=dns_doc_string) g.custom_command('add-record', 'add_dns_{}_record'.format(record), transform=transform_dns_record_set_output) g.custom_command('remove-record', 'remove_dns_{}_record'.format(record), transform=transform_dns_record_set_output) g.generic_update_command('update', custom_func_name='update_dns_record_set', transform=transform_dns_record_set_output) with self.command_group('network dns record-set soa', network_dns_record_set_sdk) as g: g.show_command('show', 'get', transform=transform_dns_record_set_output) g.custom_command('update', 'update_dns_soa_record', transform=transform_dns_record_set_output) with self.command_group('network dns record-set cname', network_dns_record_set_sdk) as g: g.show_command('show', 'get', transform=transform_dns_record_set_output) g.command('delete', 'delete') g.custom_command('list', 'list_dns_record_set', client_factory=cf_dns_mgmt_record_sets, transform=transform_dns_record_set_output, table_transformer=transform_dns_record_set_table_output) g.custom_command('create', 'create_dns_record_set', transform=transform_dns_record_set_output, doc_string_source=dns_doc_string) g.custom_command('set-record', 'add_dns_cname_record', transform=transform_dns_record_set_output) g.custom_command('remove-record', 'remove_dns_cname_record', transform=transform_dns_record_set_output) # endregion # region ExpressRoutes with self.command_group('network express-route', network_er_sdk) as g: g.command('delete', 'delete', supports_no_wait=True) g.show_command('show', 'get') g.command('get-stats', 'get_stats') g.command('list-arp-tables', 'list_arp_table') g.command('list-route-tables', 'list_routes_table') g.custom_command('create', 'create_express_route', supports_no_wait=True) g.custom_command('list', 'list_express_route_circuits') g.command('list-service-providers', 'list', command_type=network_ersp_sdk) g.generic_update_command('update', custom_func_name='update_express_route', supports_no_wait=True) g.wait_command('wait') with self.command_group('network express-route auth', network_erca_sdk) as g: g.command('create', 'create_or_update', validator=process_auth_create_namespace) g.command('delete', 'delete') g.show_command('show', 'get') g.command('list', 'list') with self.command_group('network express-route peering', network_er_peering_sdk) as g: g.custom_command('create', 'create_express_route_peering', client_factory=cf_express_route_circuit_peerings) g.command('delete', 'delete') g.show_command('show', 'get') g.command('list', 'list') g.generic_update_command('update', setter_arg_name='peering_parameters', custom_func_name='update_express_route_peering') with self.command_group('network express-route peering connection', network_erconn_sdk) as g: g.custom_command('create', 'create_express_route_connection') g.command('delete', 'delete') g.show_command('show') # endregion # region InterfaceEndpoint with self.command_group('network interface-endpoint', network_interface_endpoint_sdk) as g: # TODO: Re-enable when service team asks. See issue #7271 # g.custom_command('create', 'create_interface_endpoint') # g.command('delete', 'delete') g.custom_command('list', 'list_interface_endpoints') g.show_command('show') # g.generic_update_command('update', custom_func_name='update_interface_endpoint') # endregion # region LoadBalancers with self.command_group('network lb', network_lb_sdk) as g: g.show_command('show', 'get') g.custom_command('create', 'create_load_balancer', transform=DeploymentOutputLongRunningOperation(self.cli_ctx), supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_lb_create_namespace, exception_handler=handle_template_based_exception) g.command('delete', 'delete') g.custom_command('list', 'list_lbs') g.generic_update_command('update') property_map = { 'frontend_ip_configurations': 'frontend-ip', 'inbound_nat_rules': 'inbound-nat-rule', 'inbound_nat_pools': 'inbound-nat-pool', 'backend_address_pools': 'address-pool', 'load_balancing_rules': 'rule', 'probes': 'probe', } for subresource, alias in property_map.items(): with self.command_group('network lb {}'.format(alias), network_util) as g: g.command('list', list_network_resource_property('load_balancers', subresource)) g.show_command('show', get_network_resource_property_entry('load_balancers', subresource)) g.command('delete', delete_network_resource_property_entry('load_balancers', subresource)) with self.command_group('network lb frontend-ip', network_lb_sdk) as g: g.custom_command('create', 'create_lb_frontend_ip_configuration', validator=process_lb_frontend_ip_namespace) g.generic_update_command('update', child_collection_prop_name='frontend_ip_configurations', custom_func_name='set_lb_frontend_ip_configuration', validator=process_lb_frontend_ip_namespace) with self.command_group('network lb inbound-nat-rule', network_lb_sdk) as g: g.custom_command('create', 'create_lb_inbound_nat_rule') g.generic_update_command('update', child_collection_prop_name='inbound_nat_rules', custom_func_name='set_lb_inbound_nat_rule') with self.command_group('network lb inbound-nat-pool', network_lb_sdk) as g: g.custom_command('create', 'create_lb_inbound_nat_pool') g.generic_update_command('update', child_collection_prop_name='inbound_nat_pools', custom_func_name='set_lb_inbound_nat_pool') with self.command_group('network lb address-pool', network_lb_sdk) as g: g.custom_command('create', 'create_lb_backend_address_pool') with self.command_group('network lb rule', network_lb_sdk) as g: g.custom_command('create', 'create_lb_rule') g.generic_update_command('update', child_collection_prop_name='load_balancing_rules', custom_func_name='set_lb_rule') with self.command_group('network lb probe', network_lb_sdk) as g: g.custom_command('create', 'create_lb_probe') g.generic_update_command('update', child_collection_prop_name='probes', custom_func_name='set_lb_probe') with self.command_group('network lb outbound-rule', network_lb_sdk, min_api='2018-07-01') as g: g.custom_command('create', 'create_lb_outbound_rule', validator=process_lb_outbound_rule_namespace) g.generic_update_command('update', child_collection_prop_name='outbound_rules', custom_func_name='set_lb_outbound_rule', validator=process_lb_outbound_rule_namespace) with self.command_group('network lb outbound-rule', network_util, min_api='2018-07-01') as g: g.command('list', list_network_resource_property('load_balancers', 'outbound_rules')) g.show_command('show', get_network_resource_property_entry('load_balancers', 'outbound_rules')) g.command('delete', delete_network_resource_property_entry('load_balancers', 'outbound_rules')) # endregion # region LocalGateways with self.command_group('network local-gateway', network_lgw_sdk) as g: g.command('delete', 'delete', supports_no_wait=True) g.show_command('show', 'get') g.command('list', 'list', table_transformer=transform_local_gateway_table_output) g.custom_command('create', 'create_local_gateway', supports_no_wait=True, validator=process_local_gateway_create_namespace) g.generic_update_command('update', custom_func_name='update_local_gateway', supports_no_wait=True) g.wait_command('wait') # endregion # region NetworkInterfaces: (NIC) with self.command_group('network nic', network_nic_sdk) as g: g.custom_command('create', 'create_nic', transform=transform_nic_create_output, validator=process_nic_create_namespace, supports_no_wait=True) g.command('delete', 'delete', supports_no_wait=True) g.show_command('show', 'get') g.custom_command('list', 'list_nics') g.command('show-effective-route-table', 'get_effective_route_table', min_api='2016-09-01') g.command('list-effective-nsg', 'list_effective_network_security_groups', min_api='2016-09-01') g.generic_update_command('update', custom_func_name='update_nic', supports_no_wait=True) g.wait_command('wait') resource = 'network_interfaces' subresource = 'ip_configurations' with self.command_group('network nic ip-config', network_nic_sdk) as g: g.custom_command('create', 'create_nic_ip_config') g.generic_update_command('update', child_collection_prop_name='ip_configurations', child_arg_name='ip_config_name', custom_func_name='set_nic_ip_config') g.command('list', list_network_resource_property(resource, subresource), command_type=network_util) g.show_command('show', get_network_resource_property_entry(resource, subresource), command_type=network_util) g.command('delete', delete_network_resource_property_entry(resource, subresource), command_type=network_util) with self.command_group('network nic ip-config address-pool') as g: g.custom_command('add', 'add_nic_ip_config_address_pool') g.custom_command('remove', 'remove_nic_ip_config_address_pool') with self.command_group('network nic ip-config inbound-nat-rule') as g: g.custom_command('add', 'add_nic_ip_config_inbound_nat_rule') g.custom_command('remove', 'remove_nic_ip_config_inbound_nat_rule') # endregion # region NetworkSecurityGroups with self.command_group('network nsg', network_nsg_sdk) as g: g.command('delete', 'delete') g.show_command('show', 'get') g.custom_command('list', 'list_nsgs') g.custom_command('create', 'create_nsg', transform=transform_nsg_create_output) g.generic_update_command('update') with self.command_group('network nsg rule', network_nsg_rule_sdk) as g: g.command('delete', 'delete') g.custom_command('list', 'list_nsg_rules', table_transformer=lambda x: [transform_nsg_rule_table_output(i) for i in x]) g.show_command('show', 'get', table_transformer=transform_nsg_rule_table_output) g.custom_command('create', 'create_nsg_rule_2017_06_01', min_api='2017-06-01') g.generic_update_command('update', setter_arg_name='security_rule_parameters', min_api='2017-06-01', custom_func_name='update_nsg_rule_2017_06_01', doc_string_source='SecurityRule') g.custom_command('create', 'create_nsg_rule_2017_03_01', max_api='2017-03-01') g.generic_update_command('update', max_api='2017-03-01', setter_arg_name='security_rule_parameters', custom_func_name='update_nsg_rule_2017_03_01', doc_string_source='SecurityRule') # endregion # region NetworkProfiles with self.command_group('network profile', network_profile_sdk) as g: g.command('delete', 'delete', confirmation=True) g.custom_command('list', 'list_network_profiles') g.show_command('show') # endregion # region NetworkWatchers with self.command_group('network watcher', network_watcher_sdk, client_factory=cf_network_watcher, min_api='2016-09-01') as g: g.custom_command('configure', 'configure_network_watcher') g.command('list', 'list_all') g.custom_command('test-ip-flow', 'check_nw_ip_flow', client_factory=cf_network_watcher) g.custom_command('test-connectivity', 'check_nw_connectivity', client_factory=cf_network_watcher, validator=process_nw_test_connectivity_namespace) g.custom_command('show-next-hop', 'show_nw_next_hop', client_factory=cf_network_watcher) g.custom_command('show-security-group-view', 'show_nw_security_view', client_factory=cf_network_watcher) g.custom_command('show-topology', 'show_topology_watcher', validator=process_nw_topology_namespace) g.custom_command('run-configuration-diagnostic', 'run_network_configuration_diagnostic', client_factory=cf_network_watcher, min_api='2018-06-01', validator=process_nw_config_diagnostic_namespace) with self.command_group('network watcher connection-monitor', network_watcher_cm_sdk, client_factory=cf_connection_monitor, min_api='2018-01-01') as g: g.custom_command('create', 'create_nw_connection_monitor', validator=process_nw_cm_create_namespace) g.command('delete', 'delete') g.show_command('show', 'get') g.command('stop', 'stop') g.command('start', 'start') g.command('query', 'query') g.command('list', 'list') with self.command_group('network watcher packet-capture', network_watcher_pc_sdk, min_api='2016-09-01') as g: g.custom_command('create', 'create_nw_packet_capture', client_factory=cf_packet_capture, validator=process_nw_packet_capture_create_namespace) g.show_command('show', 'get') g.command('show-status', 'get_status') g.command('delete', 'delete') g.command('stop', 'stop') g.command('list', 'list') with self.command_group('network watcher flow-log', client_factory=cf_network_watcher, min_api='2016-09-01') as g: g.custom_command('configure', 'set_nsg_flow_logging', validator=process_nw_flow_log_set_namespace) g.custom_show_command('show', 'show_nsg_flow_logging', validator=process_nw_flow_log_show_namespace) with self.command_group('network watcher troubleshooting', client_factory=cf_network_watcher, min_api='2016-09-01') as g: g.custom_command('start', 'start_nw_troubleshooting', supports_no_wait=True, validator=process_nw_troubleshooting_start_namespace) g.custom_show_command('show', 'show_nw_troubleshooting_result', validator=process_nw_troubleshooting_show_namespace) # endregion # region PublicIPAddresses public_ip_show_table_transform = '{Name:name, ResourceGroup:resourceGroup, Location:location, $zone$AddressVersion:publicIpAddressVersion, AllocationMethod:publicIpAllocationMethod, IdleTimeoutInMinutes:idleTimeoutInMinutes, ProvisioningState:provisioningState}' public_ip_show_table_transform = public_ip_show_table_transform.replace('$zone$', 'Zones: (!zones && \' \') || join(` `, zones), ' if self.supported_api_version(min_api='2017-06-01') else ' ') with self.command_group('network public-ip', network_public_ip_sdk) as g: g.command('delete', 'delete') g.show_command('show', 'get', table_transformer=public_ip_show_table_transform) g.custom_command('list', 'list_public_ips', table_transformer='[].' + public_ip_show_table_transform) g.custom_command('create', 'create_public_ip', transform=transform_public_ip_create_output, validator=process_public_ip_create_namespace) g.generic_update_command('update', custom_func_name='update_public_ip') with self.command_group('network public-ip prefix', network_public_ip_prefix_sdk, client_factory=cf_public_ip_prefixes) as g: g.custom_command('create', 'create_public_ip_prefix') g.command('delete', 'delete') g.custom_command('list', 'list_public_ip_prefixes') g.show_command('show') g.generic_update_command('update', custom_func_name='update_public_ip_prefix') # endregion # region RouteFilters with self.command_group('network route-filter', network_rf_sdk, min_api='2016-12-01') as g: g.custom_command('create', 'create_route_filter', client_factory=cf_route_filters) g.custom_command('list', 'list_route_filters', client_factory=cf_route_filters) g.show_command('show', 'get') g.command('delete', 'delete') g.generic_update_command('update', setter_arg_name='route_filter_parameters') with self.command_group('network route-filter rule', network_rfr_sdk, min_api='2016-12-01') as g: g.custom_command('create', 'create_route_filter_rule', client_factory=cf_route_filter_rules) g.command('list', 'list_by_route_filter') g.show_command('show', 'get') g.command('delete', 'delete') g.generic_update_command('update', setter_arg_name='route_filter_rule_parameters') sc_path = 'azure.mgmt.network.operations#BgpServiceCommunitiesOperations.{}' g.command('list-service-communities', 'list', operations_tmpl=sc_path, client_factory=cf_service_community, table_transformer=transform_service_community_table_output) # endregion # region RouteTables with self.command_group('network route-table', network_rt_sdk) as g: g.custom_command('create', 'create_route_table', validator=process_route_table_create_namespace) g.command('delete', 'delete') g.show_command('show', 'get') g.custom_command('list', 'list_route_tables') g.generic_update_command('update', custom_func_name='update_route_table') network_rtr_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations.routes_operations#RoutesOperations.{}', client_factory=cf_routes ) with self.command_group('network route-table route', network_rtr_sdk) as g: g.custom_command('create', 'create_route') g.command('delete', 'delete') g.show_command('show', 'get') g.command('list', 'list') g.generic_update_command('update', setter_arg_name='route_parameters', custom_func_name='update_route') # endregion # region ServiceEndpoint with self.command_group('network service-endpoint', network_endpoint_service_sdk) as g: g.command('list', 'list') with self.command_group('network service-endpoint policy', network_sepp_sdk) as g: g.custom_command('create', 'create_service_endpoint_policy') g.command('delete', 'delete') g.custom_command('list', 'list_service_endpoint_policies') g.show_command('show') g.generic_update_command('update', custom_func_name='update_service_endpoint_policy') with self.command_group('network service-endpoint policy-definition', network_sepd_sdk) as g: g.custom_command('create', 'create_service_endpoint_policy_definition') g.command('delete', 'delete') g.command('list', 'list_by_resource_group') g.show_command('show') g.generic_update_command('update', custom_func_name='update_service_endpoint_policy_definition', setter_arg_name='service_endpoint_policy_definitions') # endregion # region TrafficManagers with self.command_group('network traffic-manager profile', network_tmp_sdk) as g: g.command('check-dns', 'check_traffic_manager_relative_dns_name_availability') g.show_command('show', 'get') g.command('delete', 'delete') g.custom_command('list', 'list_traffic_manager_profiles') g.custom_command('create', 'create_traffic_manager_profile', transform=transform_traffic_manager_create_output) g.generic_update_command('update', custom_func_name='update_traffic_manager_profile') with self.command_group('network traffic-manager endpoint', network_tme_sdk) as g: g.show_command('show', 'get') g.command('delete', 'delete') g.custom_command('create', 'create_traffic_manager_endpoint', validator=process_tm_endpoint_create_namespace) g.custom_command('list', 'list_traffic_manager_endpoints') g.generic_update_command('update', custom_func_name='update_traffic_manager_endpoint') tm_geographic_path = 'azure.mgmt.trafficmanager.operations.geographic_hierarchies_operations#GeographicHierarchiesOperations.{}' g.command('show-geographic-hierarchy', 'get_default', client_factory=cf_tm_geographic, operations_tmpl=tm_geographic_path, table_transformer=transform_geographic_hierachy_table_output) # endregion # region VirtualNetworks with self.command_group('network vnet', network_vnet_sdk) as g: g.command('delete', 'delete') g.custom_command('list', 'list_vnet', table_transformer=transform_vnet_table_output) g.show_command('show', 'get') g.command('check-ip-address', 'check_ip_address_availability', min_api='2016-09-01') g.custom_command('create', 'create_vnet', transform=transform_vnet_create_output, validator=process_vnet_create_namespace) g.generic_update_command('update', custom_func_name='update_vnet') g.command('list-endpoint-services', 'list', command_type=network_endpoint_service_sdk) with self.command_group('network vnet peering', network_vnet_peering_sdk, min_api='2016-09-01') as g: g.custom_command('create', 'create_vnet_peering') g.show_command('show', 'get') g.command('list', 'list') g.command('delete', 'delete') g.generic_update_command('update', setter_name='update_vnet_peering', setter_type=network_custom) with self.command_group('network vnet subnet', network_subnet_sdk) as g: g.custom_command('create', 'create_subnet') g.command('delete', 'delete') g.show_command('show', 'get') g.command('list', 'list') g.generic_update_command('update', setter_arg_name='subnet_parameters', custom_func_name='update_subnet') g.custom_command('list-available-delegations', 'list_avail_subnet_delegations', min_api='2018-08-01', validator=process_list_delegations_namespace) # endregion # region VirtualNetworkGateways with self.command_group('network vnet-gateway', network_vgw_sdk, min_api='2016-09-01') as g: g.custom_command('create', 'create_vnet_gateway', supports_no_wait=True, transform=transform_vnet_gateway_create_output, validator=process_vnet_gateway_create_namespace) g.generic_update_command('update', custom_func_name='update_vnet_gateway', supports_no_wait=True, validator=process_vnet_gateway_update_namespace) g.wait_command('wait') g.command('delete', 'delete', supports_no_wait=True) g.show_command('show', 'get') g.command('list', 'list') g.command('reset', 'reset') g.command('list-bgp-peer-status', 'get_bgp_peer_status') g.command('list-advertised-routes', 'get_advertised_routes') g.command('list-learned-routes', 'get_learned_routes') with self.command_group('network vnet-gateway vpn-client', network_vgw_sdk, client_factory=cf_virtual_network_gateways) as g: g.custom_command('generate', 'generate_vpn_client') g.command('show-url', 'get_vpn_profile_package_url', min_api='2017-08-01') with self.command_group('network vnet-gateway revoked-cert', network_vgw_sdk) as g: g.custom_command('create', 'create_vnet_gateway_revoked_cert') g.custom_command('delete', 'delete_vnet_gateway_revoked_cert') with self.command_group('network vnet-gateway root-cert', network_vgw_sdk) as g: g.custom_command('create', 'create_vnet_gateway_root_cert') g.custom_command('delete', 'delete_vnet_gateway_root_cert') # endregion # region VirtualNetworkGatewayConnections with self.command_group('network vpn-connection', network_vpn_sdk) as g: g.custom_command('create', 'create_vpn_connection', transform=DeploymentOutputLongRunningOperation(self.cli_ctx), table_transformer=deployment_validate_table_format, validator=process_vpn_connection_create_namespace, exception_handler=handle_template_based_exception) g.command('delete', 'delete') g.show_command('show', 'get', transform=transform_vpn_connection) g.command('list', 'list', transform=transform_vpn_connection_list) g.generic_update_command('update', custom_func_name='update_vpn_connection') with self.command_group('network vpn-connection shared-key', network_vpn_sdk) as g: g.show_command('show', 'get_shared_key') g.command('reset', 'reset_shared_key') g.generic_update_command('update', setter_name='set_shared_key') with self.command_group('network vpn-connection ipsec-policy', network_vpn_sdk, min_api='2017-03-01') as g: g.custom_command('add', 'add_vpn_conn_ipsec_policy', supports_no_wait=True, doc_string_source='IpsecPolicy') g.custom_command('list', 'list_vpn_conn_ipsec_policies') g.custom_command('clear', 'clear_vpn_conn_ipsec_policies', supports_no_wait=True)
cli_command( __name__, 'network application-gateway stop', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.stop', cf_application_gateways) cli_generic_update_command( __name__, 'network application-gateway update', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.get', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.create_or_update', cf_application_gateways) cli_command( __name__, 'network application-gateway create', 'azure.cli.command_modules.network.mgmt_app_gateway.lib.operations.app_gateway_operations#AppGatewayOperations.create_or_update', cf_application_gateway_create, transform=DeploymentOutputLongRunningOperation( 'Starting network application-gateway create')) property_map = { 'ssl_certificates': 'ssl-cert', 'frontend_ip_configurations': 'frontend-ip', 'frontend_ports': 'frontend-port', 'backend_address_pools': 'address-pool', 'backend_http_settings_collection': 'http-settings', 'http_listeners': 'http-listener', 'request_routing_rules': 'rule', 'probes': 'probe', 'url_path_maps': 'url-path-map' } for subresource, alias in property_map.items(): cli_command( __name__, 'network application-gateway {} list'.format(alias),
cli_command(__name__, 'vm image list-publishers', mgmt_path.format(op_var, op_class, 'list_publishers'), cf_vm_image) cli_command(__name__, 'vm image list-skus', mgmt_path.format(op_var, op_class, 'list_skus'), cf_vm_image) cli_command(__name__, 'vm image list', custom_path.format('list_vm_images')) # VM Usage cli_command(__name__, 'vm list-usage', mgmt_path.format('usage_operations', 'UsageOperations', 'list'), cf_usage, transform=transform_vm_usage_list, table_transformer='[].{Name:localName, CurrentValue:currentValue, Limit:limit}') # VMSS vmss_show_table_transform = '{Name:name, ResourceGroup:resourceGroup, Location:location, Capacity:sku.capacity, Overprovision:overprovision, upgradePolicy:upgradePolicy.mode}' cli_command(__name__, 'vmss delete', mgmt_path.format('virtual_machine_scale_sets_operations', 'VirtualMachineScaleSetsOperations', 'delete'), cf_vmss, no_wait_param='raw') cli_command(__name__, 'vmss list-skus', mgmt_path.format('virtual_machine_scale_sets_operations', 'VirtualMachineScaleSetsOperations', 'list_skus'), cf_vmss) cli_command(__name__, 'vmss list-instances', mgmt_path.format('virtual_machine_scale_set_vms_operations', 'VirtualMachineScaleSetVMsOperations', 'list'), cf_vmss_vm) cli_command(__name__, 'vmss create', custom_path.format('create_vmss'), transform=DeploymentOutputLongRunningOperation('Starting vmss create'), no_wait_param='no_wait', exception_handler=handle_long_running_operation_exception, table_transformer=deployment_validate_table_format) cli_command(__name__, 'vmss deallocate', custom_path.format('deallocate_vmss'), no_wait_param='no_wait') cli_command(__name__, 'vmss delete-instances', custom_path.format('delete_vmss_instances'), no_wait_param='no_wait') cli_command(__name__, 'vmss get-instance-view', custom_path.format('get_vmss_instance_view'), table_transformer='{ProvisioningState:statuses[0].displayStatus, PowerState:statuses[1].displayStatus}') cli_command(__name__, 'vmss show', custom_path.format('show_vmss'), exception_handler=empty_on_404, table_transformer=vmss_show_table_transform) cli_command(__name__, 'vmss list', custom_path.format('list_vmss'), table_transformer='[].' + vmss_show_table_transform) cli_command(__name__, 'vmss stop', custom_path.format('stop_vmss'), no_wait_param='no_wait') cli_command(__name__, 'vmss restart', custom_path.format('restart_vmss'), no_wait_param='no_wait') cli_command(__name__, 'vmss start', custom_path.format('start_vmss'), no_wait_param='no_wait') cli_command(__name__, 'vmss update-instances', custom_path.format('update_vmss_instances'), no_wait_param='no_wait') cli_command(__name__, 'vmss reimage', custom_path.format('reimage_vmss'), no_wait_param='no_wait') cli_command(__name__, 'vmss scale', custom_path.format('scale_vmss'), no_wait_param='no_wait') cli_command(__name__, 'vmss list-instance-connection-info', custom_path.format('list_vmss_instance_connection_info')) if supported_api_version(ResourceType.MGMT_COMPUTE, min_api='2017-03-30'):
vmss_stop, vmss_reimage, vmss_scale, vmss_update_instances, vmss_show, vmss_list, set_vmss_diagnostics_extension, set_vmss_extension, get_vmss_extension, list_vmss_extensions, delete_vmss_extension, update_acs) from ._factory import _compute_client_factory # pylint: disable=line-too-long # VM def get_vm_client_with_shorter_polling_interval(_): client = get_mgmt_service_client(VMClient) client.config.long_running_operation_timeout = 5 #seconds return client.vm cli_command('vm create', VmOperations.create_or_update, get_vm_client_with_shorter_polling_interval, transform=DeploymentOutputLongRunningOperation('Starting vm create')) factory = lambda _: _compute_client_factory().virtual_machines cli_command('vm delete', VirtualMachinesOperations.delete, factory) cli_command('vm deallocate', VirtualMachinesOperations.deallocate, factory) cli_command('vm generalize', VirtualMachinesOperations.generalize, factory) cli_command('vm show', VirtualMachinesOperations.get, factory) cli_command('vm list-vm-resize-options', VirtualMachinesOperations.list_available_sizes, factory) cli_command('vm get-instance-view', get_instance_view) cli_command('vm stop', VirtualMachinesOperations.power_off, factory) cli_command('vm restart', VirtualMachinesOperations.restart, factory) cli_command('vm start', VirtualMachinesOperations.start, factory) cli_command('vm redeploy', VirtualMachinesOperations.redeploy, factory) cli_command('vm list-ip-addresses', list_ip_addresses) cli_command('vm list', list_vm)
def load_command_table(self, _): custom_tmpl = 'azure.cli.command_modules.vm.custom#{}' compute_custom = CliCommandType(operations_tmpl=custom_tmpl) compute_disk_encryption_custom = CliCommandType( operations_tmpl='azure.cli.command_modules.vm.disk_encryption#{}', operation_group='virtual_machines') compute_availset_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.availability_sets_operations#AvailabilitySetsOperations.{}', client_factory=cf_avail_set, operation_group='availability_sets') compute_disk_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.disks_operations#DisksOperations.{}', client_factory=cf_disks, operation_group='disks') compute_identity_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.msi.operations.user_assigned_identities_operations#UserAssignedIdentitiesOperations.{}', client_factory=cf_msi_user_identities_operations) compute_image_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.images_operations#ImagesOperations.{}', client_factory=cf_images) compute_snapshot_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.snapshots_operations#SnapshotsOperations.{}', client_factory=cf_snapshots) compute_vm_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.virtual_machines_operations#VirtualMachinesOperations.{}', client_factory=cf_vm) compute_vm_extension_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.virtual_machine_extensions_operations#VirtualMachineExtensionsOperations.{}', client_factory=cf_vm_ext) compute_vm_extension_image_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.virtual_machine_extension_images_operations#VirtualMachineExtensionImagesOperations.{}', client_factory=cf_vm_ext_image) compute_vm_image_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.virtual_machine_images_operations#VirtualMachineImagesOperations.{}', client_factory=cf_vm_image) compute_vm_usage_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.usage_operations#UsageOperations.{}', client_factory=cf_usage) compute_vm_run_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.virtual_machine_run_commands_operations#VirtualMachineRunCommandsOperations.{}', client_factory=cf_run_commands, min_api='2017-03-30', max_api='2017-03-30') compute_vm_size_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.virtual_machine_sizes_operations#VirtualMachineSizesOperations.{}', client_factory=cf_vm_sizes) compute_vmss_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.virtual_machine_scale_sets_operations#VirtualMachineScaleSetsOperations.{}', client_factory=cf_vmss, operation_group='virtual_machine_scale_sets') compute_vmss_rolling_upgrade_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.virtual_machine_scale_set_rolling_upgrades_operations#VirtualMachineScaleSetRollingUpgradesOperations.{}', client_factory=cf_rolling_upgrade_commands, operation_group='virtual_machine_scale_sets') compute_vmss_vm_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.compute.operations.virtual_machine_scale_set_vms_operations#VirtualMachineScaleSetVMsOperations.{}', client_factory=cf_vmss_vm, operation_group='virtual_machine_scale_sets') network_nic_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.network.operations.network_interfaces_operations#NetworkInterfacesOperations.{}', client_factory=cf_ni) with self.command_group('disk', compute_disk_sdk, operation_group='disks', min_api='2017-03-30') as g: g.custom_command('create', 'create_managed_disk', supports_no_wait=True, table_transformer=transform_disk_show_table_output, validator=process_disk_or_snapshot_create_namespace) g.command('delete', 'delete', supports_no_wait=True, confirmation=True) g.custom_command('grant-access', 'grant_disk_access') g.custom_command('list', 'list_managed_disks', table_transformer='[].' + transform_disk_show_table_output) g.command('revoke-access', 'revoke_access') g.command('show', 'get', exception_handler=empty_on_404, table_transformer=transform_disk_show_table_output) g.generic_update_command('update', custom_func_name='update_managed_disk', setter_arg_name='disk', supports_no_wait=True) g.generic_wait_command('wait') # TODO move to its own command module https://github.com/Azure/azure-cli/issues/5105 with self.command_group('identity', compute_identity_sdk, min_api='2017-12-01') as g: g.command('create', 'create_or_update', validator=process_msi_namespace) g.command('show', 'get') g.command('delete', 'delete') g.custom_command('list', 'list_user_assigned_identities') g.command('list-operations', 'list', operations_tmpl= 'azure.mgmt.msi.operations.operations#Operations.{}', client_factory=cf_msi_operations_operations) with self.command_group('image', compute_image_sdk, min_api='2016-04-30-preview') as g: g.custom_command('create', 'create_image', validator=process_image_create_namespace) g.custom_command('list', 'list_images') g.command('show', 'get', exception_handler=empty_on_404) g.command('delete', 'delete') with self.command_group('snapshot', compute_snapshot_sdk, operation_group='snapshots', min_api='2016-04-30-preview') as g: g.custom_command('create', 'create_snapshot', validator=process_disk_or_snapshot_create_namespace) g.command('delete', 'delete') g.custom_command('grant-access', 'grant_snapshot_access') g.custom_command('list', 'list_snapshots') g.command('revoke-access', 'revoke_access') g.command('show', 'get', exception_handler=empty_on_404) g.generic_update_command('update', custom_func_name='update_snapshot', setter_arg_name='snapshot') with self.command_group('vm', compute_vm_sdk) as g: g.custom_command('assign-identity', 'assign_vm_identity', validator=process_assign_identity_namespace, deprecate_info='az vm identity assign') g.custom_command('remove-identity', 'remove_vm_identity', validator=process_remove_identity_namespace, min_api='2017-12-01', deprecate_info='az vm identity remove') g.custom_command('identity assign', 'assign_vm_identity', validator=process_assign_identity_namespace) g.custom_command('identity remove', 'remove_vm_identity', validator=process_remove_identity_namespace, min_api='2017-12-01') g.custom_command('identity show', 'show_vm_identity') g.custom_command('capture', 'capture_vm') g.custom_command('create', 'create_vm', transform=transform_vm_create_output, supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_vm_create_namespace) g.command('convert', 'convert_to_managed_disks', min_api='2016-04-30-preview') g.command('deallocate', 'deallocate', supports_no_wait=True) g.command('delete', 'delete', confirmation=True, supports_no_wait=True) g.custom_command('format-secret', 'get_vm_format_secret', deprecate_info='az vm secret format') g.command('generalize', 'generalize', supports_no_wait=True) g.custom_command( 'get-instance-view', 'get_instance_view', table_transformer= '{Name:name, ResourceGroup:resourceGroup, Location:location, ProvisioningState:provisioningState, PowerState:instanceView.statuses[1].displayStatus}' ) g.custom_command('list', 'list_vm', table_transformer=transform_vm_list) g.custom_command('list-ip-addresses', 'list_vm_ip_addresses', table_transformer=transform_ip_addresses) g.command('list-sizes', 'list', command_type=compute_vm_size_sdk) g.custom_command('list-skus', 'list_skus', table_transformer=transform_sku_for_table_output, min_api='2017-03-30') g.command( 'list-usage', 'list', command_type=compute_vm_usage_sdk, transform=transform_vm_usage_list, table_transformer= '[].{Name:localName, CurrentValue:currentValue, Limit:limit}') g.command('list-vm-resize-options', 'list_available_sizes') g.custom_command('open-port', 'open_vm_port') g.command('perform-maintenance', 'perform_maintenance', min_api='2017-03-30') g.command('redeploy', 'redeploy', supports_no_wait=True) g.custom_command('resize', 'resize_vm', supports_no_wait=True) g.command('restart', 'restart', supports_no_wait=True) g.custom_command('show', 'show_vm', table_transformer=transform_vm, exception_handler=empty_on_404) g.command('start', 'start', supports_no_wait=True) g.command('stop', 'power_off', supports_no_wait=True) g.generic_update_command('update', setter_name='update_vm', setter_type=compute_custom, supports_no_wait=True) g.generic_wait_command('wait', getter_name='get_instance_view', getter_type=compute_custom) with self.command_group('vm availability-set', compute_availset_sdk) as g: g.custom_command('convert', 'convert_av_set_to_managed_disk', min_api='2016-04-30-preview') g.custom_command('create', 'create_av_set', table_transformer=deployment_validate_table_format, supports_no_wait=True) g.command('delete', 'delete') g.command('list', 'list') g.command('list-sizes', 'list_available_sizes') g.command('show', 'get', exception_handler=empty_on_404) g.generic_update_command('update') with self.command_group('vm boot-diagnostics', compute_vm_sdk) as g: g.custom_command('disable', 'disable_boot_diagnostics') g.custom_command('enable', 'enable_boot_diagnostics') g.custom_command('get-boot-log', 'get_boot_log') with self.command_group('vm diagnostics', compute_vm_sdk) as g: g.custom_command('set', 'set_diagnostics_extension') g.custom_command('get-default-config', 'show_default_diagnostics_configuration') with self.command_group('vm disk', compute_vm_sdk, min_api='2017-03-30') as g: g.custom_command('attach', 'attach_managed_data_disk') g.custom_command('detach', 'detach_data_disk') with self.command_group( 'vm encryption', custom_command_type=compute_disk_encryption_custom) as g: g.custom_command('enable', 'encrypt_vm', validator=process_disk_encryption_namespace) g.custom_command('disable', 'decrypt_vm') g.custom_command('show', 'show_vm_encryption_status', exception_handler=empty_on_404) with self.command_group('vm extension', compute_vm_extension_sdk) as g: g.command('delete', 'delete') g.command('show', 'get', exception_handler=empty_on_404, table_transformer=transform_extension_show_table_output) g.custom_command('set', 'set_extension') g.custom_command('list', 'list_extensions', table_transformer='[].' + transform_extension_show_table_output) with self.command_group('vm extension image', compute_vm_extension_image_sdk) as g: g.command('show', 'get', exception_handler=empty_on_404) g.command('list-names', 'list_types') g.command('list-versions', 'list_versions') g.custom_command('list', 'list_vm_extension_images') with self.command_group('vm image', compute_vm_image_sdk) as g: g.command('list-offers', 'list_offers') g.command('list-publishers', 'list_publishers') g.command('list-skus', 'list_skus') g.custom_command('list', 'list_vm_images') g.custom_command('accept-terms', 'accept_market_ordering_terms') g.custom_command('show', 'show_vm_image', exception_handler=empty_on_404) with self.command_group('vm nic', compute_vm_sdk) as g: g.custom_command('add', 'add_vm_nic') g.custom_command('remove', 'remove_vm_nic') g.custom_command('set', 'set_vm_nic') g.custom_command('show', 'show_vm_nic', exception_handler=empty_on_404) g.custom_command('list', 'list_vm_nics') with self.command_group( 'vm run-command', compute_vm_run_sdk, operation_group='virtual_machine_run_commands') as g: g.custom_command('invoke', 'run_command_invoke') g.command('list', 'list') g.command('show', 'get') with self.command_group('vm secret', compute_vm_sdk) as g: g.custom_command('format', 'get_vm_format_secret') g.custom_command('add', 'add_vm_secret', validator=process_vm_secret_namespace) g.custom_command('list', 'list_vm_secrets') g.custom_command('remove', 'remove_vm_secret', validator=process_vm_secret_namespace) with self.command_group('vm unmanaged-disk', compute_vm_sdk) as g: g.custom_command('attach', 'attach_unmanaged_data_disk') g.custom_command('detach', 'detach_data_disk') g.custom_command('list', 'list_unmanaged_disks') with self.command_group('vm user', compute_vm_sdk, supports_no_wait=True) as g: g.custom_command('update', 'set_user') g.custom_command('delete', 'delete_user') g.custom_command('reset-ssh', 'reset_linux_ssh') with self.command_group('vmss', compute_vmss_sdk, operation_group='virtual_machine_scale_sets') as g: g.custom_command('assign-identity', 'assign_vmss_identity', validator=process_assign_identity_namespace, deprecate_info='az vmss identity assign') g.custom_command('remove-identity', 'remove_vmss_identity', validator=process_remove_identity_namespace, min_api='2017-12-01', deprecate_info='az vmss identity remove') g.custom_command('identity assign', 'assign_vmss_identity', validator=process_assign_identity_namespace) g.custom_command('identity remove', 'remove_vmss_identity', validator=process_remove_identity_namespace, min_api='2017-12-01') g.custom_command('identity show', 'show_vmss_identity') g.custom_command('create', 'create_vmss', transform=DeploymentOutputLongRunningOperation( self.cli_ctx, 'Starting vmss create'), supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_vmss_create_namespace) g.custom_command('deallocate', 'deallocate_vmss', supports_no_wait=True) g.command('delete', 'delete', supports_no_wait=True) g.custom_command('delete-instances', 'delete_vmss_instances', supports_no_wait=True) g.custom_command( 'get-instance-view', 'get_vmss_instance_view', table_transformer= '{ProvisioningState:statuses[0].displayStatus, PowerState:statuses[1].displayStatus}' ) g.custom_command( 'list', 'list_vmss', table_transformer=get_vmss_table_output_transformer(self)) g.command('list-instances', 'list', command_type=compute_vmss_vm_sdk) g.custom_command('list-instance-connection-info', 'list_vmss_instance_connection_info') g.custom_command('list-instance-public-ips', 'list_vmss_instance_public_ips') g.command('list-skus', 'list_skus') g.custom_command('reimage', 'reimage_vmss', supports_no_wait=True, min_api='2017-03-30') g.custom_command('restart', 'restart_vmss', supports_no_wait=True) g.custom_command('scale', 'scale_vmss', supports_no_wait=True) g.custom_command('show', 'show_vmss', exception_handler=empty_on_404, table_transformer=get_vmss_table_output_transformer( self, False)) g.custom_command('start', 'start_vmss', supports_no_wait=True) g.custom_command('stop', 'stop_vmss', supports_no_wait=True) g.generic_update_command('update', getter_name='get_vmss', setter_name='set_vmss', supports_no_wait=True, command_type=compute_custom) g.custom_command('update-instances', 'update_vmss_instances', supports_no_wait=True) g.generic_wait_command('wait', getter_name='get_vmss', getter_type=compute_custom) with self.command_group('vmss diagnostics', compute_vmss_sdk) as g: g.custom_command('set', 'set_vmss_diagnostics_extension') g.custom_command('get-default-config', 'show_default_diagnostics_configuration') with self.command_group('vmss disk', compute_vmss_sdk, min_api='2017-03-30') as g: g.custom_command('attach', 'attach_managed_data_disk_to_vmss') g.custom_command('detach', 'detach_disk_from_vmss') with self.command_group('vmss encryption', custom_command_type=compute_disk_encryption_custom, min_api='2017-03-30') as g: g.custom_command('enable', 'encrypt_vmss', validator=process_disk_encryption_namespace) g.custom_command('disable', 'decrypt_vmss') g.custom_command('show', 'show_vmss_encryption_status', exception_handler=empty_on_404) with self.command_group('vmss extension', compute_vmss_sdk) as g: g.custom_command('delete', 'delete_vmss_extension') g.custom_command('show', 'get_vmss_extension', exception_handler=empty_on_404) g.custom_command('set', 'set_vmss_extension') g.custom_command('list', 'list_vmss_extensions') with self.command_group('vmss extension image', compute_vm_extension_image_sdk) as g: g.command('show', 'get', exception_handler=empty_on_404) g.command('list-names', 'list_types') g.command('list-versions', 'list_versions') g.custom_command('list', 'list_vm_extension_images') with self.command_group('vmss nic', network_nic_sdk) as g: g.command('list', 'list_virtual_machine_scale_set_network_interfaces') g.command('list-vm-nics', 'list_virtual_machine_scale_set_vm_network_interfaces') g.command('show', 'get_virtual_machine_scale_set_network_interface', exception_handler=empty_on_404) with self.command_group('vmss rolling-upgrade', compute_vmss_rolling_upgrade_sdk, min_api='2017-03-30') as g: g.command('cancel', 'cancel') g.command('get-latest', 'get_latest') g.command('start', 'start_os_upgrade')
(transform_local_gateway_table_output, transform_dns_record_set_output, transform_dns_record_set_table_output, transform_dns_zone_table_output, transform_vnet_create_output, transform_public_ip_create_output, transform_traffic_manager_create_output, transform_nic_create_output, transform_nsg_create_output, transform_vnet_gateway_create_output, transform_vpn_connection, transform_vpn_connection_list, transform_vpn_connection_create_output, transform_geographic_hierachy_table_output, transform_service_community_table_output, transform_waf_rule_sets_table_output, transform_network_usage_list, transform_network_usage_table) custom_path = 'azure.cli.command_modules.network.custom#' # Application gateways ag_path = 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.' cli_command(__name__, 'network application-gateway create', custom_path + 'create_application_gateway', transform=DeploymentOutputLongRunningOperation('Starting network application-gateway create'), no_wait_param='no_wait', exception_handler=handle_long_running_operation_exception, table_transformer=deployment_validate_table_format) cli_command(__name__, 'network application-gateway delete', ag_path + 'delete', cf_application_gateways, no_wait_param='raw') cli_command(__name__, 'network application-gateway show', ag_path + 'get', cf_application_gateways, exception_handler=empty_on_404) cli_command(__name__, 'network application-gateway list', custom_path + 'list_application_gateways') cli_command(__name__, 'network application-gateway start', ag_path + 'start', cf_application_gateways) cli_command(__name__, 'network application-gateway stop', ag_path + 'stop', cf_application_gateways) if supported_api_version(ResourceType.MGMT_NETWORK, min_api='2016-09-01'): cli_command(__name__, 'network application-gateway show-backend-health', ag_path + 'backend_health', cf_application_gateways) cli_generic_update_command(__name__, 'network application-gateway update', ag_path + 'get', ag_path + 'create_or_update', cf_application_gateways, no_wait_param='raw', custom_function_op=custom_path + 'update_application_gateway') cli_generic_wait_command(__name__, 'network application-gateway wait', ag_path + 'get', cf_application_gateways)
cli_command(__name__, 'network application-gateway list', custom_path.format('list_application_gateways')) cli_command(__name__, 'network application-gateway start', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.start', cf_application_gateways) cli_command(__name__, 'network application-gateway stop', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.stop', cf_application_gateways) cli_command(__name__, 'network application-gateway show-backend-health', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.backend_health', cf_application_gateways) cli_generic_update_command(__name__, 'network application-gateway update', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.get', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.create_or_update', cf_application_gateways, no_wait_param='raw', custom_function_op=custom_path.format('update_application_gateway')) cli_generic_wait_command(__name__, 'network application-gateway wait', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.get', cf_application_gateways) cli_command(__name__, 'network application-gateway create', 'azure.cli.command_modules.network.mgmt_app_gateway.lib.operations.app_gateway_operations#AppGatewayOperations.create_or_update', cf_application_gateway_create, transform=DeploymentOutputLongRunningOperation('Starting network application-gateway create'), no_wait_param='raw') property_map = { 'authentication_certificates': 'auth-cert', 'ssl_certificates': 'ssl-cert', 'frontend_ip_configurations': 'frontend-ip', 'frontend_ports': 'frontend-port', 'backend_address_pools': 'address-pool', 'backend_http_settings_collection': 'http-settings', 'http_listeners': 'http-listener', 'request_routing_rules': 'rule', 'probes': 'probe', 'url_path_maps': 'url-path-map', } def _make_singular(value):
def transform_vpn_connection_create_output(result): from azure.cli.core.commands import DeploymentOutputLongRunningOperation result = DeploymentOutputLongRunningOperation( 'Starting network vpn-connection create')(result) return result['resource']
cli_command(__name__, 'vm image show', mgmt_path.format(op_var, op_class, 'get'), cf_vm_image, exception_handler=empty_on_404) cli_command(__name__, 'vm image list-offers', mgmt_path.format(op_var, op_class, 'list_offers'), cf_vm_image) cli_command(__name__, 'vm image list-publishers', mgmt_path.format(op_var, op_class, 'list_publishers'), cf_vm_image) cli_command(__name__, 'vm image list-skus', mgmt_path.format(op_var, op_class, 'list_skus'), cf_vm_image) cli_command(__name__, 'vm image list', custom_path.format('list_vm_images')) # VM Usage cli_command(__name__, 'vm list-usage', mgmt_path.format('usage_operations', 'UsageOperations', 'list'), cf_usage) # VMSS cli_command(__name__, 'vmss delete', mgmt_path.format('virtual_machine_scale_sets_operations', 'VirtualMachineScaleSetsOperations', 'delete'), cf_vmss) cli_command(__name__, 'vmss list-skus', mgmt_path.format('virtual_machine_scale_sets_operations', 'VirtualMachineScaleSetsOperations', 'list_skus'), cf_vmss) cli_command(__name__, 'vmss list-instances', mgmt_path.format('virtual_machine_scale_set_vms_operations', 'VirtualMachineScaleSetVMsOperations', 'list'), cf_vmss_vm) cli_command(__name__, 'vmss create', custom_path.format('create_vmss'), transform=DeploymentOutputLongRunningOperation('Starting vmss create')) cli_command(__name__, 'vmss deallocate', custom_path.format('deallocate_vmss')) cli_command(__name__, 'vmss delete-instances', custom_path.format('delete_vmss_instances')) cli_command(__name__, 'vmss get-instance-view', custom_path.format('get_vmss_instance_view')) cli_command(__name__, 'vmss show', custom_path.format('show_vmss'), exception_handler=empty_on_404) cli_command(__name__, 'vmss list', custom_path.format('list_vmss')) cli_command(__name__, 'vmss stop', custom_path.format('stop_vmss')) cli_command(__name__, 'vmss restart', custom_path.format('restart_vmss')) cli_command(__name__, 'vmss start', custom_path.format('start_vmss')) cli_command(__name__, 'vmss update-instances', custom_path.format('update_vmss_instances')) cli_command(__name__, 'vmss reimage', custom_path.format('reimage_vmss')) cli_command(__name__, 'vmss scale', custom_path.format('scale_vmss')) cli_command(__name__, 'vmss list_instance_connection_info', custom_path.format('list_vmss_instance_connection_info')) # VM Size cli_command(__name__, 'vm list-sizes', mgmt_path.format('virtual_machine_sizes_operations', 'VirtualMachineSizesOperations', 'list'), cf_vm_sizes)
# pylint: disable=line-too-long # VM def get_vm_client_with_shorter_polling_interval(_): client = get_mgmt_service_client(VMClient) client.config.long_running_operation_timeout = 5 #seconds return client.vm cli_command( 'vm create', VmOperations.create_or_update, get_vm_client_with_shorter_polling_interval, transform=DeploymentOutputLongRunningOperation('Starting vm create')) factory = lambda _: _compute_client_factory().virtual_machines cli_command('vm delete', VirtualMachinesOperations.delete, factory) cli_command('vm deallocate', VirtualMachinesOperations.deallocate, factory) cli_command('vm generalize', VirtualMachinesOperations.generalize, factory) cli_command('vm show', VirtualMachinesOperations.get, factory) cli_command('vm list-vm-resize-options', VirtualMachinesOperations.list_available_sizes, factory) cli_command('vm get-instance-view', get_instance_view) cli_command('vm stop', VirtualMachinesOperations.power_off, factory) cli_command('vm restart', VirtualMachinesOperations.restart, factory) cli_command('vm start', VirtualMachinesOperations.start, factory) cli_command('vm redeploy', VirtualMachinesOperations.redeploy, factory) cli_command('vm list-ip-addresses', list_ip_addresses)
'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.get', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.create_or_update', cf_application_gateways, no_wait_param='raw', custom_function_op=custom_path.format('update_application_gateway')) cli_generic_wait_command( __name__, 'network application-gateway wait', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.get', cf_application_gateways) cli_command( __name__, 'network application-gateway create', 'azure.cli.command_modules.network.mgmt_app_gateway.lib.operations.app_gateway_operations#AppGatewayOperations.create_or_update', cf_application_gateway_create, transform=DeploymentOutputLongRunningOperation( 'Starting network application-gateway create'), no_wait_param='raw') property_map = { 'authentication_certificates': 'auth-cert', 'ssl_certificates': 'ssl-cert', 'frontend_ip_configurations': 'frontend-ip', 'frontend_ports': 'frontend-port', 'backend_address_pools': 'address-pool', 'backend_http_settings_collection': 'http-settings', 'http_listeners': 'http-listener', 'request_routing_rules': 'rule', 'probes': 'probe', 'url_path_maps': 'url-path-map', }
(transform_local_gateway_table_output, transform_dns_record_set_output, transform_dns_record_set_table_output, transform_dns_zone_table_output, transform_vnet_create_output, transform_public_ip_create_output, transform_traffic_manager_create_output, transform_nic_create_output, transform_nsg_create_output, transform_vnet_gateway_create_output, transform_vpn_connection, transform_vpn_connection_list, transform_vpn_connection_create_output, transform_geographic_hierachy_table_output, transform_service_community_table_output, transform_waf_rule_sets_table_output) from azure.cli.core.profiles import supported_api_version, ResourceType custom_path = 'azure.cli.command_modules.network.custom#' # Application gateways ag_path = 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.' cli_command(__name__, 'network application-gateway create', custom_path + 'create_application_gateway', transform=DeploymentOutputLongRunningOperation('Starting network application-gateway create'), no_wait_param='no_wait') cli_command(__name__, 'network application-gateway delete', ag_path + 'delete', cf_application_gateways, no_wait_param='raw') cli_command(__name__, 'network application-gateway show', ag_path + 'get', cf_application_gateways, exception_handler=empty_on_404) cli_command(__name__, 'network application-gateway list', custom_path + 'list_application_gateways') cli_command(__name__, 'network application-gateway start', ag_path + 'start', cf_application_gateways) cli_command(__name__, 'network application-gateway stop', ag_path + 'stop', cf_application_gateways) if supported_api_version(ResourceType.MGMT_NETWORK, min_api='2016-09-01'): cli_command(__name__, 'network application-gateway show-backend-health', ag_path + 'backend_health', cf_application_gateways) cli_generic_update_command(__name__, 'network application-gateway update', ag_path + 'get', ag_path + 'create_or_update', cf_application_gateways, no_wait_param='raw', custom_function_op=custom_path + 'update_application_gateway') cli_generic_wait_command(__name__, 'network application-gateway wait', ag_path + 'get', cf_application_gateways)
def create_domain( cmd, resource_group_name, hostname, contact_info, privacy=True, auto_renew=True, # pylint: disable=too-many-locals accept_terms=False, tags=None, dryrun=False, no_wait=False): from azure.cli.core.commands.arm import ArmTemplateBuilder from azure.cli.command_modules.appservice._template_builder import ( build_dns_zone, build_domain) from datetime import datetime import socket import json tags = tags or {} if not accept_terms and not dryrun: raise CLIError( "To purchase and create your custom domain '{}', you must view the terms and conditions " "using the command `az appservice domain show-terms`, and accept these terms and " "conditions using the --accept-terms flag".format(hostname)) try: contact_info = json.loads(contact_info) except Exception: raise CLIError( 'Unable to load contact info. Please verify the path to your contact info file, ' 'and that the format matches the sample found at the following link: ' 'https://github.com/AzureAppServiceCLI/appservice_domains_templates' '/blob/master/contact_info.json') contact_info = verify_contact_info_and_format(contact_info) current_time = str(datetime.utcnow()).replace('+00:00', 'Z') local_ip_address = '' try: local_ip_address = socket.gethostbyname(socket.gethostname()) except: raise CLIError("Unable to get IP address") web_client = web_client_factory(cmd.cli_ctx) hostname_availability = web_client.domains.check_availability( name=hostname) if dryrun: logger.warning( "Custom domain will be purchased with the below configuration. Re-run command " "without the --dryrun flag to purchase & create the custom domain") dry_run_params = contact_info.copy() dry_run_params.update({ "hostname": hostname, "resource_group_name": resource_group_name, "privacy": bool(privacy), "auto_renew": bool(auto_renew), "accept_terms": bool(accept_terms), "hostname_available": bool(hostname_availability.available), "price": "$11.99 USD" if hostname_availability.available else "N/A" }) dry_run_str = r""" { "hostname" : "%(hostname)s", "resource_group" : "%(resource_group_name)s", "contact_info": { "address1": "%(address1)s", "address2": "%(address2)s", "city": "%(city)s", "country": "%(country)s", "postal_code": "%(postal_code)s", "state": "%(state)s", "email": "%(email)s", "fax": "%(fax)s", "job_title": "%(job_title)s", "name_first": "%(name_first)s", "name_last": "%(name_last)s", "name_middle": "%(name_middle)s", "organization": "%(organization)s", "phone": "%(phone)s" }, "privacy": "%(privacy)s", "auto_renew": "%(auto_renew)s", "accepted_hostname_purchase_terms": "%(accept_terms)s", "hostname_available": "%(hostname_available)s", "price": "%(price)s" } """ % dry_run_params return json.loads(dry_run_str) if not hostname_availability.available: raise CLIError( "Custom domain name '{}' is not available. Please try again " "with a new hostname.".format(hostname)) tld = '.'.join(hostname.split('.')[1:]) agreements = web_client.top_level_domains.list_agreements( name=tld, include_privacy=privacy) agreement_keys = [agreement.agreement_key for agreement in agreements] dns_zone_id = "[resourceId('Microsoft.Network/dnszones', '{}')]".format( hostname) master_template = ArmTemplateBuilder() dns_zone_resource = build_dns_zone(hostname) domain_resource = build_domain(domain_name=hostname, local_ip_address=local_ip_address, current_time=current_time, address1=contact_info['address1'], address2=contact_info['address2'], city=contact_info['city'], country=contact_info['country'], postal_code=contact_info['postal_code'], state=contact_info['state'], email=contact_info['email'], fax=contact_info['fax'], job_title=contact_info['job_title'], name_first=contact_info['name_first'], name_last=contact_info['name_last'], name_middle=contact_info['name_middle'], organization=contact_info['organization'], phone=contact_info['phone'], dns_zone_id=dns_zone_id, privacy=privacy, auto_renew=auto_renew, agreement_keys=agreement_keys, tags=tags, dependencies=[dns_zone_id]) master_template.add_resource(dns_zone_resource) master_template.add_resource(domain_resource) template = master_template.build() # deploy ARM template deployment_name = 'domain_deploy_' + random_string(32) client = get_mgmt_service_client( cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES).deployments DeploymentProperties = cmd.get_models( 'DeploymentProperties', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) properties = DeploymentProperties(template=template, parameters={}, mode='incremental') if cmd.supported_api_version( min_api='2019-10-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES): Deployment = cmd.get_models( 'Deployment', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) deployment = Deployment(properties=properties) deployment_result = DeploymentOutputLongRunningOperation(cmd.cli_ctx)( sdk_no_wait(no_wait, client.create_or_update, resource_group_name, deployment_name, deployment)) else: deployment_result = DeploymentOutputLongRunningOperation(cmd.cli_ctx)( sdk_no_wait(no_wait, client.create_or_update, resource_group_name, deployment_name, properties)) return deployment_result
transform_dns_record_set_table_output, transform_dns_zone_table_output, transform_vnet_create_output, transform_public_ip_create_output, transform_traffic_manager_create_output, transform_nic_create_output, transform_nsg_create_output, transform_vnet_gateway_create_output, transform_vpn_connection, transform_vpn_connection_list, transform_vpn_connection_create_output) from azure.cli.core.profiles import supported_api_version, ResourceType custom_path = 'azure.cli.command_modules.network.custom#{}' # Application gateways cli_command(__name__, 'network application-gateway create', custom_path.format('create_application_gateway'), transform=DeploymentOutputLongRunningOperation( 'Starting network application-gateway create'), no_wait_param='no_wait') cli_command( __name__, 'network application-gateway delete', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.delete', cf_application_gateways, no_wait_param='raw') cli_command( __name__, 'network application-gateway show', 'azure.mgmt.network.operations.application_gateways_operations#ApplicationGatewaysOperations.get', cf_application_gateways, exception_handler=empty_on_404) cli_command(__name__, 'network application-gateway list', custom_path.format('list_application_gateways'))
def load_command_table(self, _): from azure.cli.core.commands.arm import deployment_validate_table_format resource_custom = CliCommandType( operations_tmpl='azure.cli.command_modules.resource.custom#{}') resource_group_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.resources.operations#ResourceGroupsOperations.{}', client_factory=cf_resource_groups, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) resource_provider_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.resources.operations#ProvidersOperations.{}', client_factory=cf_providers, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) resource_feature_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.features.operations#FeaturesOperations.{}', client_factory=cf_features, resource_type=ResourceType.MGMT_RESOURCE_FEATURES) resource_tag_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.resources.operations#TagsOperations.{}', client_factory=cf_tags, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) resource_deployment_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.resources.operations#DeploymentsOperations.{}', client_factory=cf_deployments, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) resource_deployment_operation_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.resources.operations#DeploymentOperations.{}', client_factory=cf_deployment_operations, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) resource_policy_definitions_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.policy.operations#PolicyDefinitionsOperations.{}', client_factory=cf_policy_definitions, resource_type=ResourceType.MGMT_RESOURCE_POLICY) resource_policy_set_definitions_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.policy.operations#PolicySetDefinitionsOperations.{}', client_factory=cf_policy_set_definitions, resource_type=ResourceType.MGMT_RESOURCE_POLICY) resource_lock_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.locks.operations#ManagementLocksOperations.{}', resource_type=ResourceType.MGMT_RESOURCE_LOCKS) resource_link_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.links.operations#ResourceLinksOperations.{}', client_factory=cf_resource_links, resource_type=ResourceType.MGMT_RESOURCE_LINKS) resource_deploymentscripts_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.deploymentscripts.operations#ResourceLinksOperations.{}', client_factory=cf_resource_deploymentscripts, resource_type=ResourceType.MGMT_RESOURCE_DEPLOYMENTSCRIPTS) resource_managedapp_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.managedapplications.operations#ApplicationsOperations.{}', client_factory=cf_resource_managedapplications, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) resource_managedapp_def_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.managedapplications.operations#ApplicationDefinitionsOperations.{}', client_factory=cf_resource_managedappdefinitions, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) resource_managementgroups_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.managementgroups.operations#ManagementGroupsOperations.{}', client_factory=cf_management_groups, exception_handler=managementgroups_exception_handler) resource_managementgroups_subscriptions_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.managementgroups.operations#ManagementGroupSubscriptionsOperations.{}', client_factory=cf_management_group_subscriptions, exception_handler=managementgroups_exception_handler) resource_managementgroups_update_type = CliCommandType( operations_tmpl='azure.cli.command_modules.resource.custom#{}', client_factory=cf_management_groups, exception_handler=managementgroups_exception_handler) resource_templatespecs_sdk = CliCommandType( operations_tmpl= 'azure.mgmt.resource.templatespecs.operations#ResourceLinksOperations.{}', client_factory=cf_resource_templatespecs, resource_type=ResourceType.MGMT_RESOURCE_TEMPLATESPECS) with self.command_group( 'account lock', resource_lock_sdk, resource_type=ResourceType.MGMT_RESOURCE_LOCKS) as g: g.custom_command('create', 'create_lock') g.custom_command('delete', 'delete_lock') g.custom_command('list', 'list_locks') g.custom_show_command('show', 'get_lock') g.custom_command('update', 'update_lock') with self.command_group( 'group', resource_group_sdk, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.command('delete', 'delete', supports_no_wait=True, confirmation=True) g.show_command('show', 'get') g.command('exists', 'check_existence') g.custom_command('list', 'list_resource_groups', table_transformer=transform_resource_group_list) g.custom_command('create', 'create_resource_group') g.custom_command('export', 'export_group_as_template') g.generic_update_command('update', custom_func_name='update_resource_group', custom_func_type=resource_custom) g.wait_command('wait') with self.command_group( 'group lock', resource_type=ResourceType.MGMT_RESOURCE_LOCKS) as g: g.custom_command('create', 'create_lock') g.custom_command('delete', 'delete_lock') g.custom_command('list', 'list_locks') g.custom_show_command('show', 'get_lock') g.custom_command('update', 'update_lock') with self.command_group( 'resource', resource_custom, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('create', 'create_resource') g.custom_command('delete', 'delete_resource') g.custom_show_command('show', 'show_resource') g.custom_command('list', 'list_resources', table_transformer=transform_resource_list) g.custom_command('tag', 'tag_resource') g.custom_command('move', 'move_resource') g.custom_command('invoke-action', 'invoke_resource_action', transform=DeploymentOutputLongRunningOperation( self.cli_ctx)) g.generic_update_command('update', getter_name='show_resource', setter_name='update_resource', client_factory=None) g.wait_command('wait', getter_name='show_resource') with self.command_group( 'resource lock', resource_type=ResourceType.MGMT_RESOURCE_LOCKS) as g: g.custom_command('create', 'create_lock') g.custom_command('delete', 'delete_lock') g.custom_command('list', 'list_locks') g.custom_show_command('show', 'get_lock') g.custom_command('update', 'update_lock') # Resource provider commands with self.command_group( 'provider', resource_provider_sdk, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.command('list', 'list') g.show_command('show', 'get') g.custom_command('register', 'register_provider') g.custom_command('unregister', 'unregister_provider') g.custom_command('operation list', 'list_provider_operations') g.custom_show_command('operation show', 'show_provider_operations') # Resource feature commands with self.command_group('feature', resource_feature_sdk, client_factory=cf_features, resource_type=PROFILE_TYPE, min_api='2019-03-02-hybrid') as g: feature_table_transform = '{Name:name, RegistrationState:properties.state}' g.custom_command('list', 'list_features', table_transformer='[].' + feature_table_transform) g.show_command('show', 'get', table_transformer=feature_table_transform) g.custom_command('register', 'register_feature') g.custom_command('unregister', 'unregister_feature') # Tag commands with self.command_group( 'tag', resource_tag_sdk, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'get_tag_at_scope') g.custom_command('create', 'create_or_update_tag_at_scope') g.custom_command('delete', 'delete_tag_at_scope', confirmation=True) g.custom_command('update', 'update_tag_at_scope', min_api='2019-10-01') g.command('add-value', 'create_or_update_value') g.command('remove-value', 'delete_value') # az group deployment with self.command_group('group deployment', resource_deployment_sdk, deprecate_info=self.deprecate( redirect='deployment group', hide=True)) as g: g.custom_command('create', 'deploy_arm_template', supports_no_wait=True, validator=process_deployment_create_namespace, table_transformer=transform_deployment, exception_handler=handle_template_based_exception) g.command('list', 'list_by_resource_group', table_transformer=transform_deployments_list, min_api='2017-05-10') g.command('list', 'list', table_transformer=transform_deployments_list, max_api='2016-09-01') g.show_command('show', 'get', table_transformer=transform_deployment) g.command('delete', 'delete', supports_no_wait=True) g.custom_command('validate', 'validate_arm_template', table_transformer=deployment_validate_table_format, exception_handler=handle_template_based_exception) g.custom_command('export', 'export_deployment_as_template') g.wait_command('wait') g.command('cancel', 'cancel') with self.command_group('group deployment operation', resource_deployment_operation_sdk, deprecate_info=self.deprecate( redirect='deployment operation group', hide=True)) as g: g.command('list', 'list') g.custom_show_command('show', 'get_deployment_operations', client_factory=cf_deployment_operations) # az deployment with self.command_group( 'deployment', resource_deployment_sdk, min_api='2018-05-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployments_at_subscription_scope', table_transformer=transform_deployments_list, deprecate_info=g.deprecate( redirect='deployment sub list', hide=True)) g.custom_show_command('show', 'get_deployment_at_subscription_scope', deprecate_info=g.deprecate( redirect='deployment sub show', hide=True)) g.custom_command('delete', 'delete_deployment_at_subscription_scope', supports_no_wait=True, deprecate_info=g.deprecate( redirect='deployment sub delete', hide=True)) g.custom_command('validate', 'validate_arm_template_at_subscription_scope', validator=process_deployment_create_namespace, table_transformer=deployment_validate_table_format, exception_handler=handle_template_based_exception, deprecate_info=g.deprecate( redirect='deployment sub validate', hide=True)) g.custom_command('create', 'deploy_arm_template_at_subscription_scope', supports_no_wait=True, validator=process_deployment_create_namespace, exception_handler=handle_template_based_exception, deprecate_info=g.deprecate( redirect='deployment sub create', hide=True)) g.custom_command('export', 'export_template_at_subscription_scope', deprecate_info=g.deprecate( redirect='deployment sub export', hide=True)) g.custom_wait_command('wait', 'get_deployment_at_subscription_scope', deprecate_info=g.deprecate( redirect='deployment sub wait', hide=True)) g.custom_command('cancel', 'cancel_deployment_at_subscription_scope', deprecate_info=g.deprecate( redirect='deployment sub cancel', hide=True)) with self.command_group( 'deployment operation', resource_deployment_operation_sdk, min_api='2018-05-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployment_operations_at_subscription_scope', deprecate_info=self.deprecate( redirect='deployment operation sub list', hide=True)) g.custom_show_command( 'show', 'get_deployment_operations_at_subscription_scope', client_factory=cf_deployment_operations, deprecate_info=self.deprecate( redirect='deployment operation sub show', hide=True)) # az deployment sub with self.command_group( 'deployment sub', resource_deployment_sdk, min_api='2018-05-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployments_at_subscription_scope', table_transformer=transform_deployments_list) g.custom_show_command('show', 'get_deployment_at_subscription_scope', table_transformer=transform_deployment) g.custom_command('delete', 'delete_deployment_at_subscription_scope', supports_no_wait=True) g.custom_command('validate', 'validate_arm_template_at_subscription_scope', validator=process_deployment_create_namespace, table_transformer=deployment_validate_table_format, exception_handler=handle_template_based_exception) g.custom_command('create', 'deploy_arm_template_at_subscription_scope', supports_no_wait=True, validator=process_deployment_create_namespace, table_transformer=transform_deployment, exception_handler=handle_template_based_exception) g.custom_command('what-if', 'what_if_deploy_arm_template_at_subscription_scope', validator=process_deployment_create_namespace, exception_handler=handle_template_based_exception, min_api='2019-07-01') g.custom_command('export', 'export_template_at_subscription_scope') g.custom_wait_command('wait', 'get_deployment_at_subscription_scope') g.custom_command('cancel', 'cancel_deployment_at_subscription_scope') with self.command_group( 'deployment operation sub', resource_deployment_operation_sdk, min_api='2018-05-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployment_operations_at_subscription_scope') g.custom_show_command( 'show', 'get_deployment_operations_at_subscription_scope', client_factory=cf_deployment_operations) with self.command_group( 'deployment-scripts', resource_deploymentscripts_sdk, resource_type=ResourceType.MGMT_RESOURCE_DEPLOYMENTSCRIPTS) as g: g.custom_command('list', 'list_deployment_scripts') g.custom_show_command('show', 'get_deployment_script') g.custom_command('show-log', 'get_deployment_script_logs') g.custom_command('delete', 'delete_deployment_script', confirmation=True) with self.command_group( 'ts', resource_templatespecs_sdk, resource_type=ResourceType.MGMT_RESOURCE_TEMPLATESPECS, is_preview=True, min_api='2019-06-01-preview') as g: g.custom_command('create', 'create_template_spec', validator=process_ts_create_or_update_namespace) g.custom_command('update', 'update_template_spec', validator=process_ts_create_or_update_namespace, confirmation=True) g.custom_command('export', 'export_template_spec', validator=_validate_template_spec_out) g.custom_show_command('show', 'get_template_spec', validator=_validate_template_spec) g.custom_command('list', 'list_template_specs') g.custom_command('delete', 'delete_template_spec', validator=_validate_template_spec, confirmation=True) # az deployment group with self.command_group( 'deployment group', resource_deployment_sdk, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployments_at_resource_group', table_transformer=transform_deployments_list) g.custom_show_command('show', 'get_deployment_at_resource_group', table_transformer=transform_deployment) g.custom_command('delete', 'delete_deployment_at_resource_group', supports_no_wait=True) g.custom_command('validate', 'validate_arm_template_at_resource_group', validator=process_deployment_create_namespace, table_transformer=deployment_validate_table_format, exception_handler=handle_template_based_exception) g.custom_command('create', 'deploy_arm_template_at_resource_group', supports_no_wait=True, validator=process_deployment_create_namespace, table_transformer=transform_deployment, exception_handler=handle_template_based_exception) g.custom_command('what-if', 'what_if_deploy_arm_template_at_resource_group', validator=process_deployment_create_namespace, exception_handler=handle_template_based_exception, min_api='2019-07-01') g.custom_command('export', 'export_template_at_resource_group') g.custom_wait_command('wait', 'get_deployment_at_resource_group') g.custom_command('cancel', 'cancel_deployment_at_resource_group') with self.command_group( 'deployment operation group', resource_deployment_operation_sdk, resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployment_operations_at_resource_group') g.custom_show_command('show', 'get_deployment_operations_at_resource_group', client_factory=cf_deployment_operations) # az deployment mg with self.command_group( 'deployment mg', resource_deployment_sdk, min_api='2019-07-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployments_at_management_group', table_transformer=transform_deployments_list) g.custom_show_command('show', 'get_deployment_at_management_group', table_transformer=transform_deployment) g.custom_command('delete', 'delete_deployment_at_management_group', supports_no_wait=True) g.custom_command('validate', 'validate_arm_template_at_management_group', validator=process_deployment_create_namespace, table_transformer=deployment_validate_table_format, exception_handler=handle_template_based_exception) g.custom_command('create', 'deploy_arm_template_at_management_group', supports_no_wait=True, validator=process_deployment_create_namespace, table_transformer=transform_deployment, exception_handler=handle_template_based_exception) g.custom_command('what-if', 'what_if_deploy_arm_template_at_management_group', validator=process_deployment_create_namespace, exception_handler=handle_template_based_exception, min_api='2019-10-01') g.custom_command('export', 'export_template_at_management_group') g.custom_wait_command('wait', 'get_deployment_at_management_group') g.custom_command('cancel', 'cancel_deployment_at_management_group') with self.command_group( 'deployment operation mg', resource_deployment_operation_sdk, min_api='2019-07-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployment_operations_at_management_group') g.custom_show_command('show', 'get_deployment_operations_at_management_group', client_factory=cf_deployment_operations) # az deployment tenant with self.command_group( 'deployment tenant', resource_deployment_sdk, min_api='2019-07-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployments_at_tenant_scope', table_transformer=transform_deployments_list) g.custom_show_command('show', 'get_deployment_at_tenant_scope', table_transformer=transform_deployment) g.custom_command('delete', 'delete_deployment_at_tenant_scope', supports_no_wait=True) g.custom_command('validate', 'validate_arm_template_at_tenant_scope', validator=process_deployment_create_namespace, table_transformer=deployment_validate_table_format, exception_handler=handle_template_based_exception) g.custom_command('create', 'deploy_arm_template_at_tenant_scope', supports_no_wait=True, validator=process_deployment_create_namespace, table_transformer=transform_deployment, exception_handler=handle_template_based_exception) g.custom_command('what-if', 'what_if_deploy_arm_template_at_tenant_scope', validator=process_deployment_create_namespace, exception_handler=handle_template_based_exception, min_api='2019-10-01') g.custom_command('export', 'export_template_at_tenant_scope') g.custom_wait_command('wait', 'get_deployment_at_tenant_scope') g.custom_command('cancel', 'cancel_deployment_at_tenant_scope') with self.command_group( 'deployment operation tenant', resource_deployment_operation_sdk, min_api='2019-07-01', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('list', 'list_deployment_operations_at_tenant_scope') g.custom_show_command('show', 'get_deployment_operations_at_tenant_scope', client_factory=cf_deployment_operations) with self.command_group( 'policy assignment', resource_type=ResourceType.MGMT_RESOURCE_POLICY) as g: g.custom_command('create', 'create_policy_assignment') g.custom_command('delete', 'delete_policy_assignment') g.custom_command('list', 'list_policy_assignment') g.custom_show_command('show', 'show_policy_assignment') with self.command_group('policy assignment identity', resource_type=ResourceType.MGMT_RESOURCE_POLICY, min_api='2018-05-01') as g: g.custom_command('assign', 'set_identity') g.custom_show_command('show', 'show_identity') g.custom_command('remove', 'remove_identity') with self.command_group( 'policy definition', resource_policy_definitions_sdk, resource_type=ResourceType.MGMT_RESOURCE_POLICY) as g: g.custom_command('create', 'create_policy_definition') g.custom_command('delete', 'delete_policy_definition') g.custom_command('list', 'list_policy_definition') g.custom_show_command('show', 'get_policy_definition') g.custom_command('update', 'update_policy_definition') with self.command_group('policy set-definition', resource_policy_set_definitions_sdk, resource_type=ResourceType.MGMT_RESOURCE_POLICY, min_api='2017-06-01-preview') as g: g.custom_command('create', 'create_policy_setdefinition') g.custom_command('delete', 'delete_policy_setdefinition') g.custom_command('list', 'list_policy_setdefinition') g.custom_show_command('show', 'get_policy_setdefinition') g.custom_command('update', 'update_policy_setdefinition') with self.command_group( 'lock', resource_type=ResourceType.MGMT_RESOURCE_LOCKS) as g: g.custom_command('create', 'create_lock') g.custom_command('delete', 'delete_lock') g.custom_command('list', 'list_locks') g.custom_show_command('show', 'get_lock') g.custom_command('update', 'update_lock') with self.command_group( 'resource link', resource_link_sdk, resource_type=ResourceType.MGMT_RESOURCE_LINKS) as g: g.custom_command('create', 'create_resource_link') g.command('delete', 'delete') g.show_command('show', 'get') g.custom_command('list', 'list_resource_links') g.custom_command('update', 'update_resource_link') with self.command_group( 'managedapp', resource_managedapp_sdk, min_api='2017-05-10', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('create', 'create_application') g.command('delete', 'delete') g.custom_show_command('show', 'show_application') g.custom_command('list', 'list_applications') with self.command_group( 'managedapp definition', resource_managedapp_def_sdk, min_api='2017-05-10', resource_type=ResourceType.MGMT_RESOURCE_RESOURCES) as g: g.custom_command('create', 'create_or_update_applicationdefinition') g.custom_command('update', 'create_or_update_applicationdefinition') g.command('delete', 'delete') g.custom_show_command('show', 'show_applicationdefinition') g.command('list', 'list_by_resource_group', exception_handler=empty_on_404) with self.command_group('account management-group', resource_managementgroups_sdk, client_factory=cf_management_groups) as g: g.custom_command('list', 'cli_managementgroups_group_list') g.custom_show_command('show', 'cli_managementgroups_group_show') g.custom_command('create', 'cli_managementgroups_group_create') g.custom_command('delete', 'cli_managementgroups_group_delete') g.generic_update_command( 'update', getter_name='cli_managementgroups_group_update_get', getter_type=resource_managementgroups_update_type, setter_name='cli_managementgroups_group_update_set', setter_type=resource_managementgroups_update_type, custom_func_name='cli_managementgroups_group_update_custom_func', custom_func_type=resource_managementgroups_update_type, exception_handler=managementgroups_exception_handler) with self.command_group( 'account management-group subscription', resource_managementgroups_subscriptions_sdk, client_factory=cf_management_group_subscriptions) as g: g.custom_command('add', 'cli_managementgroups_subscription_add') g.custom_command('remove', 'cli_managementgroups_subscription_remove') with self.command_group('bicep') as g: g.custom_command('install', 'install_bicep_cli') g.custom_command('upgrade', 'upgrade_bicep_cli') g.custom_command('build', 'build_bicep_file') g.custom_command('decompile', 'decompile_bicep_file') g.custom_command('version', 'show_bicep_cli_version') g.custom_command('list-versions', 'list_bicep_cli_versions')
def load_command_table(self, _): custom_tmpl = 'azure.cli.command_modules.vm.custom#{}' compute_custom = CliCommandType(operations_tmpl=custom_tmpl) compute_disk_encryption_custom = CliCommandType( operations_tmpl='azure.cli.command_modules.vm.disk_encryption#{}', operation_group='virtual_machines' ) image_builder_custom = CliCommandType( operations_tmpl='azure.cli.command_modules.vm._image_builder#{}', client_factory=image_builder_client_factory ) compute_availset_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#AvailabilitySetsOperations.{}', client_factory=cf_avail_set, operation_group='availability_sets' ) compute_disk_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#DisksOperations.{}', client_factory=cf_disks, operation_group='disks' ) compute_disk_access_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#DiskAccessesOperations.{}', client_factory=cf_disk_accesses, operation_group='disk_accesses' ) compute_image_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#ImagesOperations.{}', client_factory=cf_images ) compute_snapshot_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#SnapshotsOperations.{}', client_factory=cf_snapshots ) compute_vm_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#VirtualMachinesOperations.{}', client_factory=cf_vm ) compute_vm_extension_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#VirtualMachineExtensionsOperations.{}', client_factory=cf_vm_ext ) compute_vm_extension_image_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#VirtualMachineExtensionImagesOperations.{}', client_factory=cf_vm_ext_image ) compute_vm_image_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#VirtualMachineImagesOperations.{}', client_factory=cf_vm_image ) compute_vm_image_term_sdk = CliCommandType( operations_tmpl='azure.mgmt.marketplaceordering.operations#MarketplaceAgreementsOperations.{}', client_factory=cf_vm_image_term ) compute_vm_usage_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#UsageOperations.{}', client_factory=cf_usage ) compute_vm_run_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#VirtualMachineRunCommandsOperations.{}', client_factory=cf_run_commands ) compute_vm_size_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#VirtualMachineSizesOperations.{}', client_factory=cf_vm_sizes ) compute_vmss_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#VirtualMachineScaleSetsOperations.{}', client_factory=cf_vmss, operation_group='virtual_machine_scale_sets' ) compute_vmss_rolling_upgrade_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#VirtualMachineScaleSetRollingUpgradesOperations.{}', client_factory=cf_rolling_upgrade_commands, operation_group='virtual_machine_scale_sets' ) compute_vmss_vm_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#VirtualMachineScaleSetVMsOperations.{}', client_factory=cf_vmss_vm, operation_group='virtual_machine_scale_sets' ) network_nic_sdk = CliCommandType( operations_tmpl='azure.mgmt.network.operations#NetworkInterfacesOperations.{}', client_factory=cf_ni ) compute_galleries_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#GalleriesOperations.{}', client_factory=cf_galleries, ) compute_gallery_images_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#GalleryImagesOperations.{}', client_factory=cf_gallery_images, ) compute_gallery_image_versions_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#GalleryImageVersionsOperations.{}', client_factory=cf_gallery_image_versions, ) compute_proximity_placement_groups_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#ProximityPlacementGroupsOperations.{}', ) compute_dedicated_host_sdk = CliCommandType( operations_tmpl="azure.mgmt.compute.operations#DedicatedHostsOperations.{}", client_factory=cf_dedicated_hosts, ) compute_dedicated_host_groups_sdk = CliCommandType( operations_tmpl="azure.mgmt.compute.operations#DedicatedHostGroupsOperations.{}", client_factory=cf_dedicated_host_groups, ) image_builder_image_templates_sdk = CliCommandType( operations_tmpl="azure.mgmt.imagebuilder.operations#VirtualMachineImageTemplatesOperations.{}", client_factory=cf_img_bldr_image_templates, ) compute_disk_encryption_set_sdk = CliCommandType( operations_tmpl='azure.mgmt.compute.operations#DiskEncryptionSetsOperations.{}', client_factory=cf_disk_encryption_set ) monitor_custom = CliCommandType( operations_tmpl='azure.cli.command_modules.monitor.custom#{}', exception_handler=monitor_exception_handler) metric_definitions_sdk = CliCommandType( operations_tmpl='azure.mgmt.monitor.operations#MetricDefinitionsOperations.{}', resource_type=ResourceType.MGMT_MONITOR, client_factory=cf_metric_def, operation_group='metric_definitions', exception_handler=monitor_exception_handler) with self.command_group('disk', compute_disk_sdk, operation_group='disks', min_api='2017-03-30') as g: g.custom_command('create', 'create_managed_disk', supports_no_wait=True, table_transformer=transform_disk_show_table_output, validator=process_disk_or_snapshot_create_namespace) g.command('delete', 'delete', supports_no_wait=True, confirmation=True) g.custom_command('grant-access', 'grant_disk_access') g.custom_command('list', 'list_managed_disks', table_transformer='[].' + transform_disk_show_table_output) g.command('revoke-access', 'revoke_access') g.show_command('show', 'get', table_transformer=transform_disk_show_table_output) g.generic_update_command('update', custom_func_name='update_managed_disk', setter_arg_name='disk', supports_no_wait=True) g.wait_command('wait') with self.command_group('disk-encryption-set', compute_disk_encryption_set_sdk, operation_group='disk_encryption_sets', client_factory=cf_disk_encryption_set, min_api='2019-07-01') as g: g.custom_command('create', 'create_disk_encryption_set', supports_no_wait=True) g.command('delete', 'delete') g.generic_update_command('update', custom_func_name='update_disk_encryption_set', setter_arg_name='disk_encryption_set') g.show_command('show', 'get') g.custom_command('list', 'list_disk_encryption_sets') g.command('list-associated-resources', 'list_associated_resources', min_api='2020-06-30') with self.command_group('disk-access', compute_disk_access_sdk, operation_group='disk_accesses', client_factory=cf_disk_accesses, min_api='2020-05-01') as g: g.custom_command('create', 'create_disk_access', supports_no_wait=True) g.generic_update_command('update', setter_name='set_disk_access', setter_type=compute_custom, supports_no_wait=True) g.show_command('show', 'get') g.custom_command('list', 'list_disk_accesses') g.wait_command('wait') g.command('delete', 'delete') with self.command_group('image', compute_image_sdk, min_api='2016-04-30-preview') as g: g.custom_command('create', 'create_image', validator=process_image_create_namespace) g.custom_command('list', 'list_images') g.show_command('show', 'get') g.command('delete', 'delete') g.generic_update_command('update', custom_func_name='update_image') with self.command_group('image builder', image_builder_image_templates_sdk, custom_command_type=image_builder_custom) as g: g.custom_command('create', 'create_image_template', supports_no_wait=True, supports_local_cache=True, validator=process_image_template_create_namespace) g.custom_command('list', 'list_image_templates') g.show_command('show', 'get') g.command('delete', 'delete') g.generic_update_command('update', 'create_or_update', supports_local_cache=True) # todo Update fails for now as service does not support updates g.wait_command('wait') g.command('run', 'run', supports_no_wait=True) g.custom_command('show-runs', 'show_build_output') g.command('cancel', 'cancel') with self.command_group('image builder customizer', image_builder_image_templates_sdk, custom_command_type=image_builder_custom) as g: g.custom_command('add', 'add_template_customizer', supports_local_cache=True, validator=process_img_tmpl_customizer_add_namespace) g.custom_command('remove', 'remove_template_customizer', supports_local_cache=True) g.custom_command('clear', 'clear_template_customizer', supports_local_cache=True) with self.command_group('image builder output', image_builder_image_templates_sdk, custom_command_type=image_builder_custom) as g: g.custom_command('add', 'add_template_output', supports_local_cache=True, validator=process_img_tmpl_output_add_namespace) g.custom_command('remove', 'remove_template_output', supports_local_cache=True) g.custom_command('clear', 'clear_template_output', supports_local_cache=True) with self.command_group('snapshot', compute_snapshot_sdk, operation_group='snapshots', min_api='2016-04-30-preview') as g: g.custom_command('create', 'create_snapshot', validator=process_disk_or_snapshot_create_namespace, supports_no_wait=True) g.command('delete', 'delete') g.custom_command('grant-access', 'grant_snapshot_access') g.custom_command('list', 'list_snapshots') g.command('revoke-access', 'revoke_access') g.show_command('show', 'get') g.generic_update_command('update', custom_func_name='update_snapshot', setter_arg_name='snapshot', supports_no_wait=True) g.wait_command('wait') with self.command_group('vm', compute_vm_sdk) as g: g.custom_command('identity assign', 'assign_vm_identity', validator=process_assign_identity_namespace) g.custom_command('identity remove', 'remove_vm_identity', validator=process_remove_identity_namespace, min_api='2017-12-01') g.custom_show_command('identity show', 'show_vm_identity') g.custom_command('capture', 'capture_vm') g.custom_command('create', 'create_vm', transform=transform_vm_create_output, supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_vm_create_namespace, exception_handler=handle_template_based_exception) g.command('convert', 'convert_to_managed_disks', min_api='2016-04-30-preview') g.command('deallocate', 'deallocate', supports_no_wait=True) g.command('delete', 'delete', confirmation=True, supports_no_wait=True) g.command('generalize', 'generalize', supports_no_wait=True) g.custom_command('get-instance-view', 'get_instance_view', table_transformer='{Name:name, ResourceGroup:resourceGroup, Location:location, ProvisioningState:provisioningState, PowerState:instanceView.statuses[1].displayStatus}') g.custom_command('list', 'list_vm', table_transformer=transform_vm_list) g.custom_command('list-ip-addresses', 'list_vm_ip_addresses', table_transformer=transform_ip_addresses) g.command('list-sizes', 'list', command_type=compute_vm_size_sdk) g.custom_command('list-skus', 'list_skus', table_transformer=transform_sku_for_table_output, min_api='2017-03-30') g.command('list-usage', 'list', command_type=compute_vm_usage_sdk, transform=transform_vm_usage_list, table_transformer='[].{Name:localName, CurrentValue:currentValue, Limit:limit}') g.command('list-vm-resize-options', 'list_available_sizes') g.custom_command('open-port', 'open_vm_port') g.command('perform-maintenance', 'perform_maintenance', min_api='2017-03-30') g.command('redeploy', 'redeploy', supports_no_wait=True) g.custom_command('resize', 'resize_vm', supports_no_wait=True) g.custom_command('restart', 'restart_vm', supports_no_wait=True) g.custom_show_command('show', 'show_vm', table_transformer=transform_vm) g.command('simulate-eviction', 'simulate_eviction', min_api='2019-12-01') g.command('start', 'start', supports_no_wait=True) g.command('stop', 'power_off', supports_no_wait=True, validator=process_vm_vmss_stop) g.command('reapply', 'reapply', supports_no_wait=True, min_api='2019-07-01') g.generic_update_command('update', getter_name='get_vm_for_generic_update', setter_name='update_vm', setter_type=compute_custom, command_type=compute_custom, supports_no_wait=True) g.wait_command('wait', getter_name='get_instance_view', getter_type=compute_custom) g.custom_command('auto-shutdown', 'auto_shutdown_vm') g.command('assess-patches', 'assess_patches', min_api='2020-06-01') with self.command_group('vm availability-set', compute_availset_sdk) as g: g.custom_command('convert', 'convert_av_set_to_managed_disk', min_api='2016-04-30-preview') g.custom_command('create', 'create_av_set', table_transformer=deployment_validate_table_format, supports_no_wait=True, exception_handler=handle_template_based_exception) g.command('delete', 'delete') g.custom_command('list', 'list_av_sets') g.command('list-sizes', 'list_available_sizes') g.show_command('show', 'get') g.generic_update_command('update', custom_func_name='update_av_set') with self.command_group('vm boot-diagnostics', compute_vm_sdk) as g: g.custom_command('disable', 'disable_boot_diagnostics') g.custom_command('enable', 'enable_boot_diagnostics') g.custom_command('get-boot-log', 'get_boot_log') g.custom_command('get-boot-log-uris', 'get_boot_log_uris', min_api='2020-06-01') with self.command_group('vm diagnostics', compute_vm_sdk) as g: g.custom_command('set', 'set_diagnostics_extension') g.custom_command('get-default-config', 'show_default_diagnostics_configuration') with self.command_group('vm disk', compute_vm_sdk, min_api='2017-03-30') as g: g.custom_command('attach', 'attach_managed_data_disk') g.custom_command('detach', 'detach_data_disk') with self.command_group('vm encryption', custom_command_type=compute_disk_encryption_custom) as g: g.custom_command('enable', 'encrypt_vm', validator=process_disk_encryption_namespace) g.custom_command('disable', 'decrypt_vm') g.custom_show_command('show', 'show_vm_encryption_status', table_transformer=transform_vm_encryption_show_table_output) with self.command_group('vm extension', compute_vm_extension_sdk) as g: g.command('delete', 'delete', supports_no_wait=True) g.show_command('show', 'get', table_transformer=transform_extension_show_table_output) g.custom_command('set', 'set_extension', supports_no_wait=True) g.custom_command('list', 'list_extensions', table_transformer='[].' + transform_extension_show_table_output) g.wait_command('wait') with self.command_group('vm extension image', compute_vm_extension_image_sdk) as g: g.show_command('show', 'get') g.command('list-names', 'list_types') g.command('list-versions', 'list_versions') g.custom_command('list', 'list_vm_extension_images') with self.command_group('vm image', compute_vm_image_sdk) as g: g.command('list-offers', 'list_offers') g.command('list-publishers', 'list_publishers') g.command('list-skus', 'list_skus') g.custom_command('list', 'list_vm_images') g.custom_command('accept-terms', 'accept_market_ordering_terms', deprecate_info=g.deprecate(redirect='az vm image terms accept', expiration='3.0.0')) g.custom_show_command('show', 'show_vm_image') with self.command_group('vm image terms', compute_vm_image_term_sdk, validator=None) as g: g.custom_command('accept', 'accept_terms') g.custom_command('cancel', 'cancel_terms') g.custom_show_command('show', 'get_terms') with self.command_group('vm nic', compute_vm_sdk) as g: g.custom_command('add', 'add_vm_nic') g.custom_command('remove', 'remove_vm_nic') g.custom_command('set', 'set_vm_nic') g.custom_show_command('show', 'show_vm_nic') g.custom_command('list', 'list_vm_nics') with self.command_group('vm run-command', compute_vm_run_sdk, operation_group='virtual_machine_run_commands', min_api='2017-03-30') as g: g.custom_command('invoke', 'vm_run_command_invoke') g.command('list', 'list') g.show_command('show', 'get') with self.command_group('vm secret', compute_vm_sdk) as g: g.custom_command('format', 'get_vm_format_secret', validator=process_vm_secret_format) g.custom_command('add', 'add_vm_secret') g.custom_command('list', 'list_vm_secrets') g.custom_command('remove', 'remove_vm_secret') with self.command_group('vm unmanaged-disk', compute_vm_sdk) as g: g.custom_command('attach', 'attach_unmanaged_data_disk') g.custom_command('detach', 'detach_data_disk') g.custom_command('list', 'list_unmanaged_disks') with self.command_group('vm user', compute_vm_sdk, supports_no_wait=True) as g: g.custom_command('update', 'set_user') g.custom_command('delete', 'delete_user') g.custom_command('reset-ssh', 'reset_linux_ssh') with self.command_group('vm host', compute_dedicated_host_sdk, client_factory=cf_dedicated_hosts, min_api='2019-03-01') as g: g.show_command('show', 'get') g.custom_command('get-instance-view', 'get_dedicated_host_instance_view') g.custom_command('create', 'create_dedicated_host') g.command('list', 'list_by_host_group') g.generic_update_command('update') g.command('delete', 'delete', confirmation=True) with self.command_group('vm host group', compute_dedicated_host_groups_sdk, client_factory=cf_dedicated_host_groups, min_api='2019-03-01') as g: g.show_command('show', 'get') g.custom_command('get-instance-view', 'get_dedicated_host_group_instance_view', min_api='2020-06-01') g.custom_command('create', 'create_dedicated_host_group') g.custom_command('list', 'list_dedicated_host_groups') g.generic_update_command('update') g.command('delete', 'delete', confirmation=True) with self.command_group('vmss', compute_vmss_sdk, operation_group='virtual_machine_scale_sets') as g: g.custom_command('identity assign', 'assign_vmss_identity', validator=process_assign_identity_namespace) g.custom_command('identity remove', 'remove_vmss_identity', validator=process_remove_identity_namespace, min_api='2017-12-01', is_preview=True) g.custom_show_command('identity show', 'show_vmss_identity') g.custom_command('create', 'create_vmss', transform=DeploymentOutputLongRunningOperation(self.cli_ctx, 'Starting vmss create'), supports_no_wait=True, table_transformer=deployment_validate_table_format, validator=process_vmss_create_namespace, exception_handler=handle_template_based_exception) g.custom_command('deallocate', 'deallocate_vmss', supports_no_wait=True) g.command('delete', 'delete', supports_no_wait=True) g.custom_command('delete-instances', 'delete_vmss_instances', supports_no_wait=True) g.custom_command('get-instance-view', 'get_vmss_instance_view', table_transformer='{ProvisioningState:statuses[0].displayStatus, PowerState:statuses[1].displayStatus}') g.custom_command('list', 'list_vmss', table_transformer=get_vmss_table_output_transformer(self)) g.command('list-instances', 'list', command_type=compute_vmss_vm_sdk) g.custom_command('list-instance-connection-info', 'list_vmss_instance_connection_info') g.custom_command('list-instance-public-ips', 'list_vmss_instance_public_ips') g.command('list-skus', 'list_skus') g.custom_command('reimage', 'reimage_vmss', supports_no_wait=True, min_api='2017-03-30') g.command('perform-maintenance', 'perform_maintenance', min_api='2017-12-01') g.custom_command('restart', 'restart_vmss', supports_no_wait=True) g.custom_command('scale', 'scale_vmss', supports_no_wait=True) g.custom_show_command('show', 'get_vmss', table_transformer=get_vmss_table_output_transformer(self, False)) g.command('simulate-eviction', 'simulate_eviction', command_type=compute_vmss_vm_sdk, min_api='2019-12-01') g.custom_command('start', 'start_vmss', supports_no_wait=True) g.custom_command('stop', 'stop_vmss', supports_no_wait=True, validator=process_vm_vmss_stop) g.generic_update_command('update', getter_name='get_vmss_modified', setter_name='update_vmss', supports_no_wait=True, command_type=compute_custom, validator=validate_vmss_update_namespace) g.custom_command('update-instances', 'update_vmss_instances', supports_no_wait=True) g.wait_command('wait', getter_name='get_vmss', getter_type=compute_custom) g.command('get-os-upgrade-history', 'get_os_upgrade_history', min_api='2018-10-01') g.custom_command('set-orchestration-service-state', 'set_orchestration_service_state', supports_no_wait=True) with self.command_group('vmss diagnostics', compute_vmss_sdk) as g: g.custom_command('set', 'set_vmss_diagnostics_extension') g.custom_command('get-default-config', 'show_default_diagnostics_configuration') with self.command_group('vmss disk', compute_vmss_sdk, min_api='2017-03-30') as g: g.custom_command('attach', 'attach_managed_data_disk_to_vmss') g.custom_command('detach', 'detach_disk_from_vmss') with self.command_group('vmss encryption', custom_command_type=compute_disk_encryption_custom, min_api='2017-03-30') as g: g.custom_command('enable', 'encrypt_vmss', validator=process_disk_encryption_namespace) g.custom_command('disable', 'decrypt_vmss') g.custom_show_command('show', 'show_vmss_encryption_status') with self.command_group('vmss extension', compute_vmss_sdk) as g: g.custom_command('delete', 'delete_vmss_extension', supports_no_wait=True) g.custom_show_command('show', 'get_vmss_extension') g.custom_command('set', 'set_vmss_extension', supports_no_wait=True) g.custom_command('list', 'list_vmss_extensions') g.custom_command('upgrade', 'upgrade_vmss_extension', min_api='2020-06-01', supports_no_wait=True) with self.command_group('vmss extension image', compute_vm_extension_image_sdk) as g: g.show_command('show', 'get') g.command('list-names', 'list_types') g.command('list-versions', 'list_versions') g.custom_command('list', 'list_vm_extension_images') with self.command_group('vmss nic', network_nic_sdk) as g: g.command('list', 'list_virtual_machine_scale_set_network_interfaces') g.command('list-vm-nics', 'list_virtual_machine_scale_set_vm_network_interfaces') g.show_command('show', 'get_virtual_machine_scale_set_network_interface') with self.command_group('vmss run-command', compute_vm_run_sdk, min_api='2018-04-01') as g: g.custom_command('invoke', 'vmss_run_command_invoke') g.command('list', 'list') g.show_command('show', 'get') with self.command_group('vmss rolling-upgrade', compute_vmss_rolling_upgrade_sdk, min_api='2017-03-30') as g: g.command('cancel', 'cancel') g.command('get-latest', 'get_latest') g.command('start', 'start_os_upgrade') with self.command_group('sig', compute_galleries_sdk, operation_group='galleries', min_api='2018-06-01') as g: g.custom_command('create', 'create_image_gallery') g.show_command('show', 'get') g.custom_command('list', 'list_image_galleries') g.command('delete', 'delete') g.generic_update_command('update', setter_arg_name='gallery') with self.command_group('sig image-definition', compute_gallery_images_sdk, operation_group='gallery_images', min_api='2018-06-01') as g: g.custom_command('create', 'create_gallery_image') g.command('list', 'list_by_gallery') g.show_command('show', 'get') g.command('delete', 'delete') g.generic_update_command('update', setter_arg_name='gallery_image') with self.command_group('sig image-version', compute_gallery_image_versions_sdk, operation_group='gallery_image_versions', min_api='2018-06-01') as g: g.command('delete', 'delete') g.show_command('show', 'get', table_transformer='{Name:name, ResourceGroup:resourceGroup, ProvisioningState:provisioningState, TargetRegions: publishingProfile.targetRegions && join(`, `, publishingProfile.targetRegions[*].name), ReplicationState:replicationStatus.aggregatedState}') g.command('list', 'list_by_gallery_image') g.custom_command('create', 'create_image_version', supports_no_wait=True) g.generic_update_command('update', getter_name='get_image_version_for_generic_update', setter_arg_name='gallery_image_version', setter_name='update_image_version', setter_type=compute_custom, command_type=compute_custom, supports_no_wait=True) g.wait_command('wait') with self.command_group('ppg', compute_proximity_placement_groups_sdk, min_api='2018-04-01', client_factory=cf_proximity_placement_groups) as g: g.show_command('show', 'get') g.custom_command('create', 'create_proximity_placement_group') g.custom_command('list', 'list_proximity_placement_groups') g.generic_update_command('update') g.command('delete', 'delete') with self.command_group('vm monitor log', client_factory=cf_log_analytics_data_plane) as g: g.custom_command('show', 'execute_query_for_vm', transform=transform_log_analytics_query_output) # pylint: disable=show-command with self.command_group('vm monitor metrics', custom_command_type=monitor_custom, command_type=metric_definitions_sdk, resource_type=ResourceType.MGMT_MONITOR, operation_group='metric_definitions', min_api='2018-01-01', is_preview=True) as g: from azure.cli.command_modules.monitor.transformers import metrics_table, metrics_definitions_table from azure.cli.core.profiles._shared import APIVersionException try: g.custom_command('tail', 'list_metrics', command_type=monitor_custom, table_transformer=metrics_table) g.command('list-definitions', 'list', table_transformer=metrics_definitions_table) except APIVersionException: pass
disable_boot_diagnostics, enable_boot_diagnostics, get_boot_log, list_extensions, set_extension, set_diagnostics_extension, show_default_diagnostics_configuration, vmss_start, vmss_restart, vmss_delete_instances, vmss_deallocate, vmss_get_instance_view, vmss_stop, vmss_reimage, vmss_scale, vmss_update_instances, vmss_show, vmss_list, set_vmss_diagnostics_extension, set_vmss_extension, get_vmss_extension, list_vmss_extensions, delete_vmss_extension) from ._factory import _compute_client_factory # pylint: disable=line-too-long # VM factory = lambda _: get_mgmt_service_client(VMClient).vm cli_command('vm create', VmOperations.create_or_update, factory, transform=DeploymentOutputLongRunningOperation('Starting vm create')) factory = lambda _: _compute_client_factory().virtual_machines cli_command('vm delete', VirtualMachinesOperations.delete, factory) cli_command('vm deallocate', VirtualMachinesOperations.deallocate, factory) cli_command('vm generalize', VirtualMachinesOperations.generalize, factory) cli_command('vm show', VirtualMachinesOperations.get, factory) cli_command('vm list-vm-resize-options', VirtualMachinesOperations.list_available_sizes, factory) cli_command('vm get-instance-view', get_instance_view) cli_command('vm stop', VirtualMachinesOperations.power_off, factory) cli_command('vm restart', VirtualMachinesOperations.restart, factory) cli_command('vm start', VirtualMachinesOperations.start, factory) cli_command('vm redeploy', VirtualMachinesOperations.redeploy, factory) cli_command('vm list-ip-addresses', list_ip_addresses) cli_command('vm list', list_vm)