code
stringlengths
26
870k
docstring
stringlengths
1
65.6k
func_name
stringlengths
1
194
language
stringclasses
1 value
repo
stringlengths
8
68
path
stringlengths
5
194
url
stringlengths
46
254
license
stringclasses
4 values
def _parse_actions(actions): """ Actions come in as a combined list. This method separates the webhook actions into a separate collection and combines any number of email actions into a single email collection and a single value for `email_service_owners`. If any email action contains a True value for `send_to_service_owners` then it is assumed the entire value should be True. """ from azure.mgmt.monitor.models import RuleEmailAction, RuleWebhookAction actions = actions or [] email_service_owners = None webhooks = [x for x in actions if isinstance(x, RuleWebhookAction)] custom_emails = set() for action in actions: if isinstance(action, RuleEmailAction): if action.send_to_service_owners: email_service_owners = True custom_emails = custom_emails | set(action.custom_emails) return list(custom_emails), webhooks, email_service_owners
Actions come in as a combined list. This method separates the webhook actions into a separate collection and combines any number of email actions into a single email collection and a single value for `email_service_owners`. If any email action contains a True value for `send_to_service_owners` then it is assumed the entire value should be True.
_parse_actions
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/monitor/operations/metric_alert.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/monitor/operations/metric_alert.py
MIT
def _parse_action_removals(actions): """ Separates the combined list of keys to remove into webhooks and emails. """ flattened = list({x for sublist in actions for x in sublist}) emails = [] webhooks = [] for item in flattened: if item.startswith('http://') or item.startswith('https://'): webhooks.append(item) else: emails.append(item) return emails, webhooks
Separates the combined list of keys to remove into webhooks and emails.
_parse_action_removals
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/monitor/operations/metric_alert.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/monitor/operations/metric_alert.py
MIT
def ensure_container_insights_for_monitoring( cmd, addon, cluster_subscription, cluster_resource_group_name, cluster_name, cluster_region, remove_monitoring=False, aad_route=False, create_dcr=False, create_dcra=False, enable_syslog=False, data_collection_settings=None, is_private_cluster=False, ampls_resource_id=None, enable_high_log_scale_mode=False, ): """ Either adds the ContainerInsights solution to a LA Workspace OR sets up a DCR (Data Collection Rule) and DCRA (Data Collection Rule Association). Both let the monitoring addon send data to a Log Analytics Workspace. Set aad_route == True to set up the DCR data route. Otherwise the solution route will be used. Create_dcr and create_dcra have no effect if aad_route == False. If syslog data is to be collected set aad_route == True and enable_syslog == True Set remove_monitoring to True and create_dcra to True to remove the DCRA from a cluster. The association makes it very hard to delete either the DCR or cluster. (It is not obvious how to even navigate to the association from the portal, and it prevents the cluster and DCR from being deleted individually). """ if not addon.enabled: return None if (not is_private_cluster or not aad_route) and ampls_resource_id is not None: raise ArgumentUsageError("--ampls-resource-id can only be used with private cluster in MSI mode.") is_use_ampls = False if ampls_resource_id is not None: is_use_ampls = True # workaround for this addon key which has been seen lowercased in the wild for key in list(addon.config): if ( key.lower() == CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID.lower() and key != CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID ): addon.config[ CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID ] = addon.config.pop(key) workspace_resource_id = addon.config[ CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID ] workspace_resource_id = sanitize_loganalytics_ws_resource_id( workspace_resource_id ) # extract subscription ID and workspace name from workspace_resource_id try: subscription_id = workspace_resource_id.split("/")[2] except IndexError: raise AzCLIError( "Could not locate resource group in workspace-resource-id." ) try: workspace_name = workspace_resource_id.split("/")[8] except IndexError: raise AzCLIError( "Could not locate workspace name in --workspace-resource-id." ) location = "" # region of workspace can be different from region of RG so find the location of the workspace_resource_id if not remove_monitoring: resources = get_resources_client(cmd.cli_ctx, subscription_id) try: resource = resources.get_by_id( workspace_resource_id, "2015-11-01-preview" ) location = resource.location # location can have spaces for example 'East US' hence remove the spaces location = location.replace(" ", "").lower() except HttpResponseError as ex: raise ex if aad_route: # pylint: disable=too-many-nested-blocks cluster_resource_id = ( f"/subscriptions/{cluster_subscription}/resourceGroups/{cluster_resource_group_name}/" f"providers/Microsoft.ContainerService/managedClusters/{cluster_name}" ) dataCollectionRuleName = f"MSCI-{location}-{cluster_name}" # Max length of the DCR name is 64 chars dataCollectionRuleName = _trim_suffix_if_needed(dataCollectionRuleName[0:64]) dcr_resource_id = ( f"/subscriptions/{cluster_subscription}/resourceGroups/{cluster_resource_group_name}/" f"providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}" ) # ingestion DCE MUST be in workspace region ingestionDataCollectionEndpointName = f"MSCI-ingest-{location}-{cluster_name}" # Max length of the DCE name is 44 chars ingestionDataCollectionEndpointName = _trim_suffix_if_needed(ingestionDataCollectionEndpointName[0:43]) ingestion_dce_resource_id = None # config DCE MUST be in cluster region configDataCollectionEndpointName = f"MSCI-config-{cluster_region}-{cluster_name}" # Max length of the DCE name is 44 chars configDataCollectionEndpointName = _trim_suffix_if_needed(configDataCollectionEndpointName[0:43]) config_dce_resource_id = None # create ingestion DCE if high log scale mode enabled if enable_high_log_scale_mode: ingestion_dce_resource_id = create_data_collection_endpoint(cmd, cluster_subscription, cluster_resource_group_name, location, ingestionDataCollectionEndpointName, is_use_ampls) # create config DCE if AMPLS resource specified if is_use_ampls: config_dce_resource_id = create_data_collection_endpoint(cmd, cluster_subscription, cluster_resource_group_name, cluster_region, configDataCollectionEndpointName, is_use_ampls) if create_dcr: # first get the association between region display names and region IDs (because for some reason # the "which RPs are available in which regions" check returns region display names) region_names_to_id = {} # retry the request up to two times for _ in range(3): try: location_list_url = cmd.cli_ctx.cloud.endpoints.resource_manager + \ f"/subscriptions/{cluster_subscription}/locations?api-version=2019-11-01" r = send_raw_request(cmd.cli_ctx, "GET", location_list_url) # this is required to fool the static analyzer. The else statement will only run if an exception # is thrown, but flake8 will complain that e is undefined if we don't also define it here. error = None break except AzCLIError as e: error = e else: # This will run if the above for loop was not broken out of. This means all three requests failed raise error json_response = json.loads(r.text) for region_data in json_response["value"]: region_names_to_id[region_data["displayName"]] = region_data[ "name" ] dcr_url = cmd.cli_ctx.cloud.endpoints.resource_manager + \ f"{dcr_resource_id}?api-version=2022-06-01" # get existing tags on the container insights extension DCR if the customer added any existing_tags = get_existing_container_insights_extension_dcr_tags( cmd, dcr_url) # get data collection settings extensionSettings = {} cistreams = ["Microsoft-ContainerInsights-Group-Default"] if enable_high_log_scale_mode: cistreams = ContainerInsightsStreams if data_collection_settings is not None: dataCollectionSettings = _get_data_collection_settings(data_collection_settings) validate_data_collection_settings(dataCollectionSettings) dataCollectionSettings.setdefault("enableContainerLogV2", True) extensionSettings["dataCollectionSettings"] = dataCollectionSettings cistreams = dataCollectionSettings["streams"] else: # If data_collection_settings is None, set default dataCollectionSettings dataCollectionSettings = { "enableContainerLogV2": True } extensionSettings["dataCollectionSettings"] = dataCollectionSettings if enable_high_log_scale_mode: for i, v in enumerate(cistreams): if v == "Microsoft-ContainerLogV2": cistreams[i] = "Microsoft-ContainerLogV2-HighScale" # create the DCR dcr_creation_body_without_syslog = json.dumps( { "location": location, "tags": existing_tags, "kind": "Linux", "properties": { "dataSources": { "extensions": [ { "name": "ContainerInsightsExtension", "streams": cistreams, "extensionName": "ContainerInsights", "extensionSettings": extensionSettings, } ] }, "dataFlows": [ { "streams": cistreams, "destinations": ["la-workspace"], } ], "destinations": { "logAnalytics": [ { "workspaceResourceId": workspace_resource_id, "name": "la-workspace", } ] }, "dataCollectionEndpointId": ingestion_dce_resource_id }, } ) dcr_creation_body_with_syslog = json.dumps( { "location": location, "tags": existing_tags, "kind": "Linux", "properties": { "dataSources": { "syslog": [ { "streams": [ "Microsoft-Syslog" ], "facilityNames": [ "auth", "authpriv", "cron", "daemon", "mark", "kern", "local0", "local1", "local2", "local3", "local4", "local5", "local6", "local7", "lpr", "mail", "news", "syslog", "user", "uucp" ], "logLevels": [ "Debug", "Info", "Notice", "Warning", "Error", "Critical", "Alert", "Emergency" ], "name": "sysLogsDataSource" } ], "extensions": [ { "name": "ContainerInsightsExtension", "streams": cistreams, "extensionName": "ContainerInsights", "extensionSettings": extensionSettings, } ] }, "dataFlows": [ { "streams": cistreams, "destinations": ["la-workspace"], }, { "streams": [ "Microsoft-Syslog" ], "destinations": ["la-workspace"], } ], "destinations": { "logAnalytics": [ { "workspaceResourceId": workspace_resource_id, "name": "la-workspace", } ] }, "dataCollectionEndpointId": ingestion_dce_resource_id }, } ) for _ in range(3): try: if enable_syslog: send_raw_request( cmd.cli_ctx, "PUT", dcr_url, body=dcr_creation_body_with_syslog ) else: send_raw_request( cmd.cli_ctx, "PUT", dcr_url, body=dcr_creation_body_without_syslog ) error = None break except AzCLIError as e: error = e else: raise error if create_dcra: # only create or delete the association between the DCR and cluster create_or_delete_dcr_association(cmd, cluster_region, remove_monitoring, cluster_resource_id, dcr_resource_id) if is_use_ampls: # associate config DCE to the cluster create_dce_association(cmd, cluster_region, cluster_resource_id, config_dce_resource_id) # link config DCE to AMPLS create_ampls_scope(cmd, ampls_resource_id, configDataCollectionEndpointName, config_dce_resource_id) # link workspace to AMPLS create_ampls_scope(cmd, ampls_resource_id, workspace_name, workspace_resource_id) # link ingest DCE to AMPLS if enable_high_log_scale_mode: create_ampls_scope(cmd, ampls_resource_id, ingestionDataCollectionEndpointName, ingestion_dce_resource_id)
Either adds the ContainerInsights solution to a LA Workspace OR sets up a DCR (Data Collection Rule) and DCRA (Data Collection Rule Association). Both let the monitoring addon send data to a Log Analytics Workspace. Set aad_route == True to set up the DCR data route. Otherwise the solution route will be used. Create_dcr and create_dcra have no effect if aad_route == False. If syslog data is to be collected set aad_route == True and enable_syslog == True Set remove_monitoring to True and create_dcra to True to remove the DCRA from a cluster. The association makes it very hard to delete either the DCR or cluster. (It is not obvious how to even navigate to the association from the portal, and it prevents the cluster and DCR from being deleted individually).
ensure_container_insights_for_monitoring
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/addonconfiguration.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/addonconfiguration.py
MIT
def _get_provisioning_state(response): """Attempt to get provisioning state from resource. :param azure.core.pipeline.transport.HttpResponse response: latest REST call response. :returns: Status if found, else 'None'. """ if _is_empty(response): return None body: Dict = _as_json(response) return body.get("properties", {}).get("provisioningState")
Attempt to get provisioning state from resource. :param azure.core.pipeline.transport.HttpResponse response: latest REST call response. :returns: Status if found, else 'None'.
_get_provisioning_state
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/_polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/_polling.py
MIT
def get_status(self, pipeline_response): """Process the latest status update retrieved from the same URL as the previous request. :param azure.core.pipeline.PipelineResponse response: latest REST call response. :raises: BadResponse if status not 200 or 204. """ response = pipeline_response.http_response if _is_empty(response): raise BadResponse( "The response from long running operation does not contain a body." ) status = self._get_provisioning_state(response) return status or "Unknown"
Process the latest status update retrieved from the same URL as the previous request. :param azure.core.pipeline.PipelineResponse response: latest REST call response. :raises: BadResponse if status not 200 or 204.
get_status
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/_polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/_polling.py
MIT
def load_balancer_models(self) -> SimpleNamespace: """Get load balancer related models. The models are stored in a SimpleNamespace object, could be accessed by the dot operator like `load_balancer_models.ManagedClusterLoadBalancerProfile`. :return: SimpleNamespace """ if self.__loadbalancer_models is None: load_balancer_models = {} load_balancer_models["ManagedClusterLoadBalancerProfile"] = self.ManagedClusterLoadBalancerProfile load_balancer_models[ "ManagedClusterLoadBalancerProfileManagedOutboundIPs" ] = self.ManagedClusterLoadBalancerProfileManagedOutboundIPs load_balancer_models[ "ManagedClusterLoadBalancerProfileOutboundIPs" ] = self.ManagedClusterLoadBalancerProfileOutboundIPs load_balancer_models[ "ManagedClusterLoadBalancerProfileOutboundIPPrefixes" ] = self.ManagedClusterLoadBalancerProfileOutboundIPPrefixes load_balancer_models["ResourceReference"] = self.ResourceReference self.__loadbalancer_models = SimpleNamespace(**load_balancer_models) return self.__loadbalancer_models
Get load balancer related models. The models are stored in a SimpleNamespace object, could be accessed by the dot operator like `load_balancer_models.ManagedClusterLoadBalancerProfile`. :return: SimpleNamespace
load_balancer_models
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def nat_gateway_models(self) -> SimpleNamespace: """Get nat gateway related models. The models are stored in a SimpleNamespace object, could be accessed by the dot operator like `nat_gateway_models.ManagedClusterNATGatewayProfile`. :return: SimpleNamespace """ if self.__nat_gateway_models is None: nat_gateway_models = {} nat_gateway_models["ManagedClusterNATGatewayProfile"] = ( self.ManagedClusterNATGatewayProfile if hasattr(self, "ManagedClusterNATGatewayProfile") else None ) # backward compatibility nat_gateway_models["ManagedClusterManagedOutboundIPProfile"] = ( self.ManagedClusterManagedOutboundIPProfile if hasattr(self, "ManagedClusterManagedOutboundIPProfile") else None ) # backward compatibility self.__nat_gateway_models = SimpleNamespace(**nat_gateway_models) return self.__nat_gateway_models
Get nat gateway related models. The models are stored in a SimpleNamespace object, could be accessed by the dot operator like `nat_gateway_models.ManagedClusterNATGatewayProfile`. :return: SimpleNamespace
nat_gateway_models
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def maintenance_configuration_models(self) -> SimpleNamespace: """Get maintenance configuration related models. The models are stored in a SimpleNamespace object, could be accessed by the dot operator like `maintenance_configuration_models.ManagedClusterMaintenanceConfigurationProfile`. :return: SimpleNamespace """ if self.__maintenance_configuration_models is None: maintenance_configuration_models = {} # getting maintenance configuration related models maintenance_configuration_models["MaintenanceConfiguration"] = self.MaintenanceConfiguration maintenance_configuration_models["MaintenanceConfigurationListResult"] = self.MaintenanceConfigurationListResult maintenance_configuration_models["MaintenanceWindow"] = self.MaintenanceWindow maintenance_configuration_models["Schedule"] = self.Schedule maintenance_configuration_models["DailySchedule"] = self.DailySchedule maintenance_configuration_models["WeeklySchedule"] = self.WeeklySchedule maintenance_configuration_models["AbsoluteMonthlySchedule"] = self.AbsoluteMonthlySchedule maintenance_configuration_models["RelativeMonthlySchedule"] = self.RelativeMonthlySchedule maintenance_configuration_models["TimeSpan"] = self.TimeSpan maintenance_configuration_models["TimeInWeek"] = self.TimeInWeek self.__maintenance_configuration_models = SimpleNamespace(**maintenance_configuration_models) return self.__maintenance_configuration_models
Get maintenance configuration related models. The models are stored in a SimpleNamespace object, could be accessed by the dot operator like `maintenance_configuration_models.ManagedClusterMaintenanceConfigurationProfile`. :return: SimpleNamespace
maintenance_configuration_models
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def existing_mc(self) -> ManagedCluster: """Get the existing ManagedCluster object in update mode. :return: ManagedCluster """ return self.__existing_mc
Get the existing ManagedCluster object in update mode. :return: ManagedCluster
existing_mc
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def attach_mc(self, mc: ManagedCluster) -> None: """Attach the ManagedCluster object to the context. The `mc` object is only allowed to be attached once, and attaching again will raise a CLIInternalError. :return: None """ if self.decorator_mode == DecoratorMode.UPDATE: self.attach_existing_mc(mc) if self.mc is None: self.mc = mc else: msg = "the same" if self.mc == mc else "different" raise CLIInternalError( "Attempting to attach the `mc` object again, the two objects are {}.".format( msg ) )
Attach the ManagedCluster object to the context. The `mc` object is only allowed to be attached once, and attaching again will raise a CLIInternalError. :return: None
attach_mc
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def attach_existing_mc(self, mc: ManagedCluster) -> None: """Attach the existing ManagedCluster object to the context in update mode. The `mc` object is only allowed to be attached once, and attaching again will raise a CLIInternalError. :return: None """ if self.__existing_mc is None: self.__existing_mc = mc else: msg = "the same" if self.__existing_mc == mc else "different" raise CLIInternalError( "Attempting to attach the existing `mc` object again, the two objects are {}.".format( msg ) )
Attach the existing ManagedCluster object to the context in update mode. The `mc` object is only allowed to be attached once, and attaching again will raise a CLIInternalError. :return: None
attach_existing_mc
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def attach_agentpool_context(self, agentpool_context: AKSAgentPoolContext) -> None: """Attach the AKSAgentPoolContext object to the context. The `agentpool_context` object is only allowed to be attached once, and attaching again will raise a CLIInternalError. :return: None """ if self.agentpool_context is None: self.agentpool_context = agentpool_context else: msg = "the same" if self.agentpool_context == agentpool_context else "different" raise CLIInternalError( "Attempting to attach the `agentpool_context` object again, the two objects are {}.".format( msg ) )
Attach the AKSAgentPoolContext object to the context. The `agentpool_context` object is only allowed to be attached once, and attaching again will raise a CLIInternalError. :return: None
attach_agentpool_context
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def __validate_cluster_autoscaler_profile( self, cluster_autoscaler_profile: Union[List, Dict, None] ) -> Union[Dict, None]: """Helper function to parse and verify cluster_autoscaler_profile. If the user input is a list, parse it with function "extract_comma_separated_string". If the type of user input or parsed value is not a dictionary, raise an InvalidArgumentValueError. Otherwise, take the keys from the attribute map of ManagedClusterPropertiesAutoScalerProfile to verify whether the keys in the key-value pairs provided by the user are valid. If not, raise an InvalidArgumentValueError. :return: dictionary or None """ if cluster_autoscaler_profile is not None: # convert list to dict if isinstance(cluster_autoscaler_profile, list): params_dict = {} for item in cluster_autoscaler_profile: params_dict.update( extract_comma_separated_string( item, extract_kv=True, allow_empty_value=True, default_value={}, ) ) cluster_autoscaler_profile = params_dict # check if the type is dict if not isinstance(cluster_autoscaler_profile, dict): raise InvalidArgumentValueError( "Unexpected input cluster-autoscaler-profile, value: '{}', type '{}'.".format( cluster_autoscaler_profile, type(cluster_autoscaler_profile), ) ) # verify keys # pylint: disable=protected-access valid_keys = list( k.replace("_", "-") for k in self.models.ManagedClusterPropertiesAutoScalerProfile._attribute_map.keys() ) for key in cluster_autoscaler_profile.keys(): if not key: raise InvalidArgumentValueError("Empty key specified for cluster-autoscaler-profile") if key not in valid_keys: raise InvalidArgumentValueError( "'{}' is an invalid key for cluster-autoscaler-profile. Valid keys are {}.".format( key, ", ".join(valid_keys) ) ) return cluster_autoscaler_profile
Helper function to parse and verify cluster_autoscaler_profile. If the user input is a list, parse it with function "extract_comma_separated_string". If the type of user input or parsed value is not a dictionary, raise an InvalidArgumentValueError. Otherwise, take the keys from the attribute map of ManagedClusterPropertiesAutoScalerProfile to verify whether the keys in the key-value pairs provided by the user are valid. If not, raise an InvalidArgumentValueError. :return: dictionary or None
__validate_cluster_autoscaler_profile
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def __validate_gmsa_options( self, enable_windows_gmsa, disable_windows_gmsa, gmsa_dns_server, gmsa_root_domain_name, yes, ) -> None: """Helper function to validate gmsa related options. When enable_windows_gmsa is specified, a InvalidArgumentValueError will be raised if disable_windows_gmsa is also specified; if both gmsa_dns_server and gmsa_root_domain_name are not assigned and user does not confirm the operation, a DecoratorEarlyExitException will be raised; if only one of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. When enable_windows_gmsa is not specified, if any of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. When disable_windows_gmsa is specified, if gmsa_dns_server or gmsa_root_domain_name is assigned, raise a InvalidArgumentValueError. :return: bool """ if enable_windows_gmsa: if disable_windows_gmsa: raise InvalidArgumentValueError( "You should not set --disable-windows-gmsa " "when setting --enable-windows-gmsa." ) if gmsa_dns_server is None and gmsa_root_domain_name is None: msg = ( "Please assure that you have set the DNS server in the vnet used by the cluster " "when not specifying --gmsa-dns-server and --gmsa-root-domain-name" ) if not yes and not prompt_y_n(msg, default="n"): raise DecoratorEarlyExitException() elif not all([gmsa_dns_server, gmsa_root_domain_name]): raise RequiredArgumentMissingError( "You must set or not set --gmsa-dns-server and --gmsa-root-domain-name at the same time." ) else: if not disable_windows_gmsa: if any([gmsa_dns_server, gmsa_root_domain_name]): raise RequiredArgumentMissingError( "You only can set --gmsa-dns-server and --gmsa-root-domain-name " "when setting --enable-windows-gmsa." ) if disable_windows_gmsa: if any([gmsa_dns_server, gmsa_root_domain_name]): raise InvalidArgumentValueError( "You should not set --gmsa-dns-server nor --gmsa-root-domain-name " "when setting --disable-windows-gmsa." )
Helper function to validate gmsa related options. When enable_windows_gmsa is specified, a InvalidArgumentValueError will be raised if disable_windows_gmsa is also specified; if both gmsa_dns_server and gmsa_root_domain_name are not assigned and user does not confirm the operation, a DecoratorEarlyExitException will be raised; if only one of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. When enable_windows_gmsa is not specified, if any of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. When disable_windows_gmsa is specified, if gmsa_dns_server or gmsa_root_domain_name is assigned, raise a InvalidArgumentValueError. :return: bool
__validate_gmsa_options
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_subscription_id(self): """Helper function to obtain the value of subscription_id. Note: This is not a parameter of aks_create, and it will not be decorated into the `mc` object. If no corresponding intermediate exists, method "get_subscription_id" of class "Profile" will be called, which depends on "az login" in advance, the returned subscription_id will be stored as an intermediate. :return: string """ subscription_id = self.get_intermediate("subscription_id", None) if not subscription_id: subscription_id = self.cmd.cli_ctx.data.get('subscription_id') if not subscription_id: subscription_id = Profile(cli_ctx=self.cmd.cli_ctx).get_subscription_id() self.cmd.cli_ctx.data['subscription_id'] = subscription_id self.set_intermediate("subscription_id", subscription_id, overwrite_exists=True) return subscription_id
Helper function to obtain the value of subscription_id. Note: This is not a parameter of aks_create, and it will not be decorated into the `mc` object. If no corresponding intermediate exists, method "get_subscription_id" of class "Profile" will be called, which depends on "az login" in advance, the returned subscription_id will be stored as an intermediate. :return: string
get_subscription_id
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_resource_group_name(self) -> str: """Obtain the value of resource_group_name. Note: resource_group_name will not be decorated into the `mc` object. The value of this parameter should be provided by user explicitly. :return: string """ # read the original value passed by the command resource_group_name = self.raw_param.get("resource_group_name") # this parameter does not need dynamic completion # this parameter does not need validation return resource_group_name
Obtain the value of resource_group_name. Note: resource_group_name will not be decorated into the `mc` object. The value of this parameter should be provided by user explicitly. :return: string
get_resource_group_name
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_name(self) -> str: """Obtain the value of name. Note: name will not be decorated into the `mc` object. The value of this parameter should be provided by user explicitly. :return: string """ # read the original value passed by the command name = self.raw_param.get("name") # this parameter does not need dynamic completion # this parameter does not need validation return name
Obtain the value of name. Note: name will not be decorated into the `mc` object. The value of this parameter should be provided by user explicitly. :return: string
get_name
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_location(self, read_only: bool = False) -> Union[str, None]: """Internal function to dynamically obtain the value of location according to the context. When location is not assigned, dynamic completion will be triggerd. Function "get_rg_location" will be called to get the location of the provided resource group, which internally used ResourceManagementClient to send the request. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: string or None """ # read the original value passed by the command location = self.raw_param.get("location") # try to read the property value corresponding to the parameter from the `mc` object read_from_mc = False if self.mc and self.mc.location is not None: location = self.mc.location read_from_mc = True # try to read from intermediate if location is None and self.get_intermediate("location"): location = self.get_intermediate("location") # skip dynamic completion & validation if option read_only is specified if read_only: return location # dynamic completion if not read_from_mc and location is None: location = self.external_functions.get_rg_location( self.cmd.cli_ctx, self.get_resource_group_name() ) self.set_intermediate("location", location, overwrite_exists=True) # this parameter does not need validation return location
Internal function to dynamically obtain the value of location according to the context. When location is not assigned, dynamic completion will be triggerd. Function "get_rg_location" will be called to get the location of the provided resource group, which internally used ResourceManagementClient to send the request. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: string or None
_get_location
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_location(self) -> Union[str, None]: """Dynamically obtain the value of location according to the context. When location is not assigned, dynamic completion will be triggerd. Function "get_rg_location" will be called to get the location of the provided resource group, which internally used ResourceManagementClient to send the request. :return: string or None """ return self._get_location()
Dynamically obtain the value of location according to the context. When location is not assigned, dynamic completion will be triggerd. Function "get_rg_location" will be called to get the location of the provided resource group, which internally used ResourceManagementClient to send the request. :return: string or None
get_location
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_tags(self) -> Union[Dict[str, str], None]: """Obtain the value of tags. :return: dictionary or None """ # read the original value passed by the command tags = self.raw_param.get("tags") # In create mode, try to read the property value corresponding to the parameter from the `mc` object. if self.decorator_mode == DecoratorMode.CREATE: if self.mc and self.mc.tags is not None: tags = self.mc.tags # this parameter does not need dynamic completion # this parameter does not need validation return tags
Obtain the value of tags. :return: dictionary or None
get_tags
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_kubernetes_version(self) -> str: """Obtain the value of kubernetes_version. :return: string """ return self.agentpool_context.get_kubernetes_version()
Obtain the value of kubernetes_version. :return: string
get_kubernetes_version
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_disk_driver(self) -> Optional[ManagedClusterStorageProfileDiskCSIDriver]: """Obtain the value of storage_profile.disk_csi_driver :return: Optional[ManagedClusterStorageProfileDiskCSIDriver] """ enable_disk_driver = self.raw_param.get("enable_disk_driver") disable_disk_driver = self.raw_param.get("disable_disk_driver") if not enable_disk_driver and not disable_disk_driver: return None profile = self.models.ManagedClusterStorageProfileDiskCSIDriver() if enable_disk_driver and disable_disk_driver: raise MutuallyExclusiveArgumentError( "Cannot specify --enable-disk-driver and " "--disable-disk-driver at the same time." ) if self.decorator_mode == DecoratorMode.CREATE: if disable_disk_driver: profile.enabled = False else: profile.enabled = True if self.decorator_mode == DecoratorMode.UPDATE: if enable_disk_driver: profile.enabled = True elif disable_disk_driver: msg = ( "Please make sure there are no existing PVs and PVCs " "that are used by AzureDisk CSI driver before disabling." ) if not self.get_yes() and not prompt_y_n(msg, default="n"): raise DecoratorEarlyExitException() profile.enabled = False return profile
Obtain the value of storage_profile.disk_csi_driver :return: Optional[ManagedClusterStorageProfileDiskCSIDriver]
get_disk_driver
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_file_driver(self) -> Optional[ManagedClusterStorageProfileFileCSIDriver]: """Obtain the value of storage_profile.file_csi_driver :return: Optional[ManagedClusterStorageProfileFileCSIDriver] """ enable_file_driver = self.raw_param.get("enable_file_driver") disable_file_driver = self.raw_param.get("disable_file_driver") if not enable_file_driver and not disable_file_driver: return None profile = self.models.ManagedClusterStorageProfileFileCSIDriver() if enable_file_driver and disable_file_driver: raise MutuallyExclusiveArgumentError( "Cannot specify --enable-file-driver and " "--disable-file-driver at the same time." ) if self.decorator_mode == DecoratorMode.CREATE: if disable_file_driver: profile.enabled = False if self.decorator_mode == DecoratorMode.UPDATE: if enable_file_driver: profile.enabled = True elif disable_file_driver: msg = ( "Please make sure there are no existing PVs and PVCs " "that are used by AzureFile CSI driver before disabling." ) if not self.get_yes() and not prompt_y_n(msg, default="n"): raise DecoratorEarlyExitException() profile.enabled = False return profile
Obtain the value of storage_profile.file_csi_driver :return: Optional[ManagedClusterStorageProfileFileCSIDriver]
get_file_driver
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_blob_driver(self) -> Optional[ManagedClusterStorageProfileBlobCSIDriver]: """Obtain the value of storage_profile.blob_csi_driver :return: Optional[ManagedClusterStorageProfileBlobCSIDriver] """ enable_blob_driver = self.raw_param.get("enable_blob_driver") disable_blob_driver = self.raw_param.get("disable_blob_driver") if enable_blob_driver is None and disable_blob_driver is None: return None profile = self.models.ManagedClusterStorageProfileBlobCSIDriver() if enable_blob_driver and disable_blob_driver: raise MutuallyExclusiveArgumentError( "Cannot specify --enable-blob-driver and " "--disable-blob-driver at the same time." ) if self.decorator_mode == DecoratorMode.CREATE: if enable_blob_driver: profile.enabled = True if self.decorator_mode == DecoratorMode.UPDATE: if enable_blob_driver: msg = "Please make sure there is no open-source Blob CSI driver installed before enabling." if not self.get_yes() and not prompt_y_n(msg, default="n"): raise DecoratorEarlyExitException() profile.enabled = True elif disable_blob_driver: msg = ( "Please make sure there are no existing PVs and PVCs " "that are used by Blob CSI driver before disabling." ) if not self.get_yes() and not prompt_y_n(msg, default="n"): raise DecoratorEarlyExitException() profile.enabled = False return profile
Obtain the value of storage_profile.blob_csi_driver :return: Optional[ManagedClusterStorageProfileBlobCSIDriver]
get_blob_driver
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_enable_app_routing(self) -> bool: """Obtain the value of enable_app_routing. :return: bool """ return self.raw_param.get("enable_app_routing")
Obtain the value of enable_app_routing. :return: bool
get_enable_app_routing
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_enable_kv(self) -> bool: """Obtain the value of enable_kv. :return: bool """ return self.raw_param.get("enable_kv")
Obtain the value of enable_kv. :return: bool
get_enable_kv
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_dns_zone_resource_ids(self) -> Union[list, None]: """Obtain the value of dns_zone_resource_ids. :return: list or None """ # read the original value passed by the command dns_zone_resource_ids = self.raw_param.get("dns_zone_resource_ids") # normalize dns_zone_resource_ids = [ x.strip() for x in ( dns_zone_resource_ids.split(",") if dns_zone_resource_ids else [] ) ] # try to read the property value corresponding to the parameter from the `mc` object if ( self.mc and self.mc.ingress_profile and self.mc.ingress_profile.web_app_routing and self.mc.ingress_profile.web_app_routing.dns_zone_resource_ids is not None ): dns_zone_resource_ids = self.mc.ingress_profile.web_app_routing.dns_zone_resource_ids # this parameter does not need dynamic completion # this parameter does not need validation return dns_zone_resource_ids
Obtain the value of dns_zone_resource_ids. :return: list or None
get_dns_zone_resource_ids
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_dns_zone_resource_ids_from_input(self) -> Union[List[str], None]: """Obtain the value of dns_zone_resource_ids from the input. :return: list of str or None """ dns_zone_resource_ids_input = self.raw_param.get("dns_zone_resource_ids") dns_zone_resource_ids = [] if dns_zone_resource_ids_input: for dns_zone in dns_zone_resource_ids_input.split(","): dns_zone = dns_zone.strip() if dns_zone and is_valid_resource_id(dns_zone): dns_zone_resource_ids.append(dns_zone) else: raise CLIError(dns_zone, " is not a valid Azure DNS Zone resource ID.") return dns_zone_resource_ids
Obtain the value of dns_zone_resource_ids from the input. :return: list of str or None
get_dns_zone_resource_ids_from_input
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_keyvault_id(self) -> str: """Obtain the value of keyvault_id. :return: str """ return self.raw_param.get("keyvault_id")
Obtain the value of keyvault_id. :return: str
get_keyvault_id
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_attach_zones(self) -> bool: """Obtain the value of attach_zones. :return: bool """ return self.raw_param.get("attach_zones")
Obtain the value of attach_zones. :return: bool
get_attach_zones
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_add_dns_zone(self) -> bool: """Obtain the value of add_dns_zone. :return: bool """ return self.raw_param.get("add_dns_zone")
Obtain the value of add_dns_zone. :return: bool
get_add_dns_zone
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_delete_dns_zone(self) -> bool: """Obtain the value of delete_dns_zone. :return: bool """ return self.raw_param.get("delete_dns_zone")
Obtain the value of delete_dns_zone. :return: bool
get_delete_dns_zone
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_update_dns_zone(self) -> bool: """Obtain the value of update_dns_zone. :return: bool """ return self.raw_param.get("update_dns_zone")
Obtain the value of update_dns_zone. :return: bool
get_update_dns_zone
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_enable_keda(self) -> bool: """Obtain the value of enable_keda. This function will verify the parameter by default. If both enable_keda and disable_keda are specified, raise a MutuallyExclusiveArgumentError. :return: bool """ return self._get_enable_keda(enable_validation=True)
Obtain the value of enable_keda. This function will verify the parameter by default. If both enable_keda and disable_keda are specified, raise a MutuallyExclusiveArgumentError. :return: bool
get_enable_keda
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_enable_keda(self, enable_validation: bool = False) -> bool: """Internal function to obtain the value of enable_keda. This function supports the option of enable_validation. When enabled, if both enable_keda and disable_keda are specified, raise a MutuallyExclusiveArgumentError. :return: bool """ # Read the original value passed by the command. enable_keda = self.raw_param.get("enable_keda") # In create mode, try to read the property value corresponding to the parameter from the `mc` object. if self.decorator_mode == DecoratorMode.CREATE: if ( self.mc and hasattr(self.mc, "workload_auto_scaler_profile") and # backward compatibility self.mc.workload_auto_scaler_profile and self.mc.workload_auto_scaler_profile.keda ): enable_keda = self.mc.workload_auto_scaler_profile.keda.enabled # This parameter does not need dynamic completion. if enable_validation: if enable_keda and self._get_disable_keda(enable_validation=False): raise MutuallyExclusiveArgumentError( "Cannot specify --enable-keda and --disable-keda at the same time." ) return enable_keda
Internal function to obtain the value of enable_keda. This function supports the option of enable_validation. When enabled, if both enable_keda and disable_keda are specified, raise a MutuallyExclusiveArgumentError. :return: bool
_get_enable_keda
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_disable_keda(self) -> bool: """Obtain the value of disable_keda. This function will verify the parameter by default. If both enable_keda and disable_keda are specified, raise a MutuallyExclusiveArgumentError. :return: bool """ return self._get_disable_keda(enable_validation=True)
Obtain the value of disable_keda. This function will verify the parameter by default. If both enable_keda and disable_keda are specified, raise a MutuallyExclusiveArgumentError. :return: bool
get_disable_keda
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_disable_keda(self, enable_validation: bool = False) -> bool: """Internal function to obtain the value of disable_keda. This function supports the option of enable_validation. When enabled, if both enable_keda and disable_keda are specified, raise a MutuallyExclusiveArgumentError. :return: bool """ # Read the original value passed by the command. disable_keda = self.raw_param.get("disable_keda") # This option is not supported in create mode, hence we do not read the property value from the `mc` object. # This parameter does not need dynamic completion. if enable_validation: if disable_keda and self._get_enable_keda(enable_validation=False): raise MutuallyExclusiveArgumentError( "Cannot specify --enable-keda and --disable-keda at the same time." ) return disable_keda
Internal function to obtain the value of disable_keda. This function supports the option of enable_validation. When enabled, if both enable_keda and disable_keda are specified, raise a MutuallyExclusiveArgumentError. :return: bool
_get_disable_keda
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_snapshot_controller(self) -> Optional[ManagedClusterStorageProfileSnapshotController]: """Obtain the value of storage_profile.snapshot_controller :return: Optional[ManagedClusterStorageProfileSnapshotController] """ enable_snapshot_controller = self.raw_param.get("enable_snapshot_controller") disable_snapshot_controller = self.raw_param.get("disable_snapshot_controller") if not enable_snapshot_controller and not disable_snapshot_controller: return None profile = self.models.ManagedClusterStorageProfileSnapshotController() if enable_snapshot_controller and disable_snapshot_controller: raise MutuallyExclusiveArgumentError( "Cannot specify --enable-snapshot_controller and " "--disable-snapshot_controller at the same time." ) if self.decorator_mode == DecoratorMode.CREATE: if disable_snapshot_controller: profile.enabled = False if self.decorator_mode == DecoratorMode.UPDATE: if enable_snapshot_controller: profile.enabled = True elif disable_snapshot_controller: msg = ( "Please make sure there are no existing " "VolumeSnapshots, VolumeSnapshotClasses and VolumeSnapshotContents " "that are used by the snapshot controller before disabling." ) if not self.get_yes() and not prompt_y_n(msg, default="n"): raise DecoratorEarlyExitException() profile.enabled = False return profile
Obtain the value of storage_profile.snapshot_controller :return: Optional[ManagedClusterStorageProfileSnapshotController]
get_snapshot_controller
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_storage_profile(self) -> Optional[ManagedClusterStorageProfile]: """Obtain the value of storage_profile. :return: Optional[ManagedClusterStorageProfile] """ profile = self.models.ManagedClusterStorageProfile() if self.mc.storage_profile is not None: profile = self.mc.storage_profile profile.disk_csi_driver = self.get_disk_driver() profile.file_csi_driver = self.get_file_driver() profile.blob_csi_driver = self.get_blob_driver() profile.snapshot_controller = self.get_snapshot_controller() return profile
Obtain the value of storage_profile. :return: Optional[ManagedClusterStorageProfile]
get_storage_profile
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_vnet_subnet_id(self) -> Union[str, None]: """Obtain the value of vnet_subnet_id. :return: string or None """ return self.agentpool_context.get_vnet_subnet_id()
Obtain the value of vnet_subnet_id. :return: string or None
get_vnet_subnet_id
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_nodepool_labels(self) -> Union[Dict[str, str], None]: """Obtain the value of nodepool_labels. :return: dictionary or None """ return self.agentpool_context.get_nodepool_labels()
Obtain the value of nodepool_labels. :return: dictionary or None
get_nodepool_labels
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_nodepool_taints(self) -> Union[List[str], None]: """Obtain the value of nodepool_labels. :return: dictionary or None """ return self.agentpool_context.get_node_taints()
Obtain the value of nodepool_labels. :return: dictionary or None
get_nodepool_taints
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_dns_name_prefix( self, enable_validation: bool = False, read_only: bool = False ) -> Union[str, None]: """Internal function to dynamically obtain the value of dns_name_prefix according to the context. When both dns_name_prefix and fqdn_subdomain are not assigned, dynamic completion will be triggerd. A default dns_name_prefix composed of name (cluster), resource_group_name, and subscription_id will be created. This function supports the option of enable_validation. When enabled, it will check if both dns_name_prefix and fqdn_subdomain are assigend, if so, raise the MutuallyExclusiveArgumentError. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: string or None """ # read the original value passed by the command dns_name_prefix = self.raw_param.get("dns_name_prefix") # try to read the property value corresponding to the parameter from the `mc` object read_from_mc = False if self.mc and self.mc.dns_prefix is not None: dns_name_prefix = self.mc.dns_prefix read_from_mc = True # skip dynamic completion & validation if option read_only is specified if read_only: return dns_name_prefix dynamic_completion = False # check whether the parameter meet the conditions of dynamic completion if not dns_name_prefix and not self._get_fqdn_subdomain(enable_validation=False): dynamic_completion = True # disable dynamic completion if the value is read from `mc` dynamic_completion = dynamic_completion and not read_from_mc # In case the user does not specify the parameter and it meets the conditions of automatic completion, # necessary information is dynamically completed. if dynamic_completion: name = self.get_name() resource_group_name = self.get_resource_group_name() subscription_id = self.get_subscription_id() # Use subscription id to provide uniqueness and prevent DNS name clashes name_part = re.sub('[^A-Za-z0-9-]', '', name)[0:10] if not name_part[0].isalpha(): name_part = (str('a') + name_part)[0:10] resource_group_part = re.sub( '[^A-Za-z0-9-]', '', resource_group_name)[0:16] dns_name_prefix = '{}-{}-{}'.format(name_part, resource_group_part, subscription_id[0:6]) # validation if enable_validation: if dns_name_prefix and self._get_fqdn_subdomain(enable_validation=False): raise MutuallyExclusiveArgumentError( "--dns-name-prefix and --fqdn-subdomain cannot be used at same time" ) return dns_name_prefix
Internal function to dynamically obtain the value of dns_name_prefix according to the context. When both dns_name_prefix and fqdn_subdomain are not assigned, dynamic completion will be triggerd. A default dns_name_prefix composed of name (cluster), resource_group_name, and subscription_id will be created. This function supports the option of enable_validation. When enabled, it will check if both dns_name_prefix and fqdn_subdomain are assigend, if so, raise the MutuallyExclusiveArgumentError. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: string or None
_get_dns_name_prefix
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_dns_name_prefix(self) -> Union[str, None]: """Dynamically obtain the value of dns_name_prefix according to the context. When both dns_name_prefix and fqdn_subdomain are not assigned, dynamic completion will be triggerd. A default dns_name_prefix composed of name (cluster), resource_group_name, and subscription_id will be created. This function will verify the parameter by default. It will check if both dns_name_prefix and fqdn_subdomain are assigend, if so, raise the MutuallyExclusiveArgumentError. :return: string or None """ return self._get_dns_name_prefix(enable_validation=True)
Dynamically obtain the value of dns_name_prefix according to the context. When both dns_name_prefix and fqdn_subdomain are not assigned, dynamic completion will be triggerd. A default dns_name_prefix composed of name (cluster), resource_group_name, and subscription_id will be created. This function will verify the parameter by default. It will check if both dns_name_prefix and fqdn_subdomain are assigend, if so, raise the MutuallyExclusiveArgumentError. :return: string or None
get_dns_name_prefix
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_node_osdisk_diskencryptionset_id(self) -> Union[str, None]: """Obtain the value of node_osdisk_diskencryptionset_id. :return: string or None """ # read the original value passed by the command node_osdisk_diskencryptionset_id = self.raw_param.get("node_osdisk_diskencryptionset_id") # try to read the property value corresponding to the parameter from the `mc` object if ( self.mc and self.mc.disk_encryption_set_id is not None ): node_osdisk_diskencryptionset_id = self.mc.disk_encryption_set_id # this parameter does not need dynamic completion # this parameter does not need validation return node_osdisk_diskencryptionset_id
Obtain the value of node_osdisk_diskencryptionset_id. :return: string or None
get_node_osdisk_diskencryptionset_id
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_ssh_key_value_and_no_ssh_key(self) -> Tuple[str, bool]: """Obtain the value of ssh_key_value and no_ssh_key. Note: no_ssh_key will not be decorated into the `mc` object. If the user does not explicitly specify --ssh-key-value, the validator function "validate_ssh_key" will check the default file location "~/.ssh/id_rsa.pub", if the file exists, read its content and return. Otherise, create a key pair at "~/.ssh/id_rsa.pub" and return the public key. If the user provides a string-like input for --ssh-key-value, the validator function "validate_ssh_key" will check whether it is a file path, if so, read its content and return; if it is a valid public key, return it. Otherwise, create a key pair there and return the public key. This function will verify the parameters by default. It will verify the validity of ssh_key_value. If parameter no_ssh_key is set to True, verification will be skipped. Otherwise, an InvalidArgumentValueError will be raised when the value of ssh_key_value is invalid. :return: a tuple containing two elements: ssh_key_value of string type and no_ssh_key of bool type """ # ssh_key_value # read the original value passed by the command raw_value = self.raw_param.get("ssh_key_value") # try to read the property value corresponding to the parameter from the `mc` object value_obtained_from_mc = None if ( self.mc and self.mc.linux_profile and self.mc.linux_profile.ssh and self.mc.linux_profile.ssh.public_keys ): public_key_obj = safe_list_get( self.mc.linux_profile.ssh.public_keys, 0, None ) if public_key_obj: value_obtained_from_mc = public_key_obj.key_data # set default value read_from_mc = False if value_obtained_from_mc is not None: ssh_key_value = value_obtained_from_mc read_from_mc = True else: ssh_key_value = raw_value # no_ssh_key # read the original value passed by the command no_ssh_key = self.raw_param.get("no_ssh_key") # consistent check if read_from_mc and no_ssh_key: raise CLIInternalError( "Inconsistent state detected, ssh_key_value is read from the `mc` object while no_ssh_key is enabled." ) # these parameters do not need dynamic completion # validation if not no_ssh_key: try: if not ssh_key_value or not is_valid_ssh_rsa_public_key( ssh_key_value ): raise ValueError() except (TypeError, ValueError): shortened_key = truncate_text(ssh_key_value) raise InvalidArgumentValueError( "Provided ssh key ({}) is invalid or non-existent".format( shortened_key ) ) return ssh_key_value, no_ssh_key
Obtain the value of ssh_key_value and no_ssh_key. Note: no_ssh_key will not be decorated into the `mc` object. If the user does not explicitly specify --ssh-key-value, the validator function "validate_ssh_key" will check the default file location "~/.ssh/id_rsa.pub", if the file exists, read its content and return. Otherise, create a key pair at "~/.ssh/id_rsa.pub" and return the public key. If the user provides a string-like input for --ssh-key-value, the validator function "validate_ssh_key" will check whether it is a file path, if so, read its content and return; if it is a valid public key, return it. Otherwise, create a key pair there and return the public key. This function will verify the parameters by default. It will verify the validity of ssh_key_value. If parameter no_ssh_key is set to True, verification will be skipped. Otherwise, an InvalidArgumentValueError will be raised when the value of ssh_key_value is invalid. :return: a tuple containing two elements: ssh_key_value of string type and no_ssh_key of bool type
get_ssh_key_value_and_no_ssh_key
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_admin_username(self) -> str: """Obtain the value of admin_username. Note: SDK performs the following validation {'required': True, 'pattern': r'^[A-Za-z][-A-Za-z0-9_]*$'}. :return: str """ # read the original value passed by the command admin_username = self.raw_param.get("admin_username") # try to read the property value corresponding to the parameter from the `mc` object if ( self.mc and self.mc.linux_profile and self.mc.linux_profile.admin_username is not None ): admin_username = self.mc.linux_profile.admin_username # this parameter does not need dynamic completion # this parameter does not need validation return admin_username
Obtain the value of admin_username. Note: SDK performs the following validation {'required': True, 'pattern': r'^[A-Za-z][-A-Za-z0-9_]*$'}. :return: str
get_admin_username
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_windows_admin_username_and_password( self, read_only: bool = False, enable_validation: bool = False ) -> Tuple[Union[str, None], Union[str, None]]: """Internal function to dynamically obtain the value of windows_admin_username and windows_admin_password according to the context. Note: This function is intended to be used in create mode. Note: All the external parameters involved in the validation are not verified in their own getters. When one of windows_admin_username and windows_admin_password is not assigned, dynamic completion will be triggerd. The user will be prompted to enter the missing windows_admin_username or windows_admin_password in tty (pseudo terminal). If the program is running in a non-interactive environment, a NoTTYError error will be raised. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. This function supports the option of enable_validation. When enabled, if neither windows_admin_username or windows_admin_password is specified and any of enable_windows_gmsa, gmsa_dns_server or gmsa_root_domain_name is specified, raise a RequiredArgumentMissingError. :return: a tuple containing two elements: windows_admin_username of string type or None and windows_admin_password of string type or None """ # windows_admin_username # read the original value passed by the command windows_admin_username = self.raw_param.get("windows_admin_username") # try to read the property value corresponding to the parameter from the `mc` object username_read_from_mc = False if ( self.mc and self.mc.windows_profile and self.mc.windows_profile.admin_username is not None ): windows_admin_username = self.mc.windows_profile.admin_username username_read_from_mc = True # windows_admin_password # read the original value passed by the command windows_admin_password = self.raw_param.get("windows_admin_password") # try to read the property value corresponding to the parameter from the `mc` object password_read_from_mc = False if ( self.mc and self.mc.windows_profile and self.mc.windows_profile.admin_password is not None ): windows_admin_password = self.mc.windows_profile.admin_password password_read_from_mc = True # consistent check if username_read_from_mc != password_read_from_mc: raise CLIInternalError( "Inconsistent state detected, one of windows admin name and password is read from the `mc` object." ) # skip dynamic completion & validation if option read_only is specified if read_only: return windows_admin_username, windows_admin_password username_dynamic_completion = False # check whether the parameter meet the conditions of dynamic completion # to avoid that windows_admin_password is set but windows_admin_username is not if windows_admin_username is None and windows_admin_password: username_dynamic_completion = True # disable dynamic completion if the value is read from `mc` username_dynamic_completion = ( username_dynamic_completion and not username_read_from_mc ) if username_dynamic_completion: try: windows_admin_username = prompt("windows_admin_username: ") # The validation for admin_username in ManagedClusterWindowsProfile will fail even if # users still set windows_admin_username to empty here except NoTTYException: raise NoTTYError( "Please specify username for Windows in non-interactive mode." ) password_dynamic_completion = False # check whether the parameter meet the conditions of dynamic completion # to avoid that windows_admin_username is set but windows_admin_password is not if windows_admin_password is None and windows_admin_username: password_dynamic_completion = True # disable dynamic completion if the value is read from `mc` password_dynamic_completion = ( password_dynamic_completion and not password_read_from_mc ) if password_dynamic_completion: try: windows_admin_password = prompt_pass( msg="windows-admin-password: ", confirm=True ) except NoTTYException: raise NoTTYError( "Please specify both username and password in non-interactive mode." ) # validation # Note: The external parameters involved in the validation are not verified in their own getters. if enable_validation: if self.decorator_mode == DecoratorMode.CREATE: if not any([windows_admin_username, windows_admin_password]): if self._get_enable_windows_gmsa( enable_validation=False ) or any(self._get_gmsa_dns_server_and_root_domain_name( enable_validation=False )): raise RequiredArgumentMissingError( "Please set windows admin username and password before setting gmsa related configs." ) return windows_admin_username, windows_admin_password
Internal function to dynamically obtain the value of windows_admin_username and windows_admin_password according to the context. Note: This function is intended to be used in create mode. Note: All the external parameters involved in the validation are not verified in their own getters. When one of windows_admin_username and windows_admin_password is not assigned, dynamic completion will be triggerd. The user will be prompted to enter the missing windows_admin_username or windows_admin_password in tty (pseudo terminal). If the program is running in a non-interactive environment, a NoTTYError error will be raised. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. This function supports the option of enable_validation. When enabled, if neither windows_admin_username or windows_admin_password is specified and any of enable_windows_gmsa, gmsa_dns_server or gmsa_root_domain_name is specified, raise a RequiredArgumentMissingError. :return: a tuple containing two elements: windows_admin_username of string type or None and windows_admin_password of string type or None
_get_windows_admin_username_and_password
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_windows_admin_username_and_password( self, ) -> Tuple[Union[str, None], Union[str, None]]: """Dynamically obtain the value of windows_admin_username and windows_admin_password according to the context. Note: This function is intended to be used in create mode. Note: All the external parameters involved in the validation are not verified in their own getters. When one of windows_admin_username and windows_admin_password is not assigned, dynamic completion will be triggerd. The user will be prompted to enter the missing windows_admin_username or windows_admin_password in tty (pseudo terminal). If the program is running in a non-interactive environment, a NoTTYError error will be raised. This function will verify the parameter by default. If neither windows_admin_username or windows_admin_password is specified and any of enable_windows_gmsa, gmsa_dns_server or gmsa_root_domain_name is specified, raise a RequiredArgumentMissingError. :return: a tuple containing two elements: windows_admin_username of string type or None and windows_admin_password of string type or None """ return self._get_windows_admin_username_and_password(enable_validation=True)
Dynamically obtain the value of windows_admin_username and windows_admin_password according to the context. Note: This function is intended to be used in create mode. Note: All the external parameters involved in the validation are not verified in their own getters. When one of windows_admin_username and windows_admin_password is not assigned, dynamic completion will be triggerd. The user will be prompted to enter the missing windows_admin_username or windows_admin_password in tty (pseudo terminal). If the program is running in a non-interactive environment, a NoTTYError error will be raised. This function will verify the parameter by default. If neither windows_admin_username or windows_admin_password is specified and any of enable_windows_gmsa, gmsa_dns_server or gmsa_root_domain_name is specified, raise a RequiredArgumentMissingError. :return: a tuple containing two elements: windows_admin_username of string type or None and windows_admin_password of string type or None
get_windows_admin_username_and_password
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_windows_admin_password(self) -> Union[str, None]: """Obtain the value of windows_admin_password. Note: This function is intended to be used in update mode. :return: string or None """ # read the original value passed by the command windows_admin_password = self.raw_param.get("windows_admin_password") # this parameter does not need dynamic completion # this parameter does not need validation return windows_admin_password
Obtain the value of windows_admin_password. Note: This function is intended to be used in update mode. :return: string or None
get_windows_admin_password
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_enable_ahub( self, enable_validation: bool = False ) -> bool: """Internal function to obtain the value of enable_ahub. Note: enable_ahub will not be directly decorated into the `mc` object. This function supports the option of enable_validation. When enabled, if both enable_ahub and disable_ahub are specified, raise a MutuallyExclusiveArgumentError. :return: bool """ # read the original value passed by the command enable_ahub = self.raw_param.get("enable_ahub") # In create mode, try to read the property value corresponding to the parameter from the `mc` object. if self.decorator_mode == DecoratorMode.CREATE: if self.mc and self.mc.windows_profile: enable_ahub = self.mc.windows_profile.license_type == "Windows_Server" # this parameter does not need dynamic completion # validation if enable_validation: if enable_ahub and self._get_disable_ahub(enable_validation=False): raise MutuallyExclusiveArgumentError( 'Cannot specify "--enable-ahub" and "--disable-ahub" at the same time' ) return enable_ahub
Internal function to obtain the value of enable_ahub. Note: enable_ahub will not be directly decorated into the `mc` object. This function supports the option of enable_validation. When enabled, if both enable_ahub and disable_ahub are specified, raise a MutuallyExclusiveArgumentError. :return: bool
_get_enable_ahub
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_enable_ahub(self) -> bool: """Obtain the value of enable_ahub. Note: enable_ahub will not be directly decorated into the `mc` object. This function will verify the parameter by default. If both enable_ahub and disable_ahub are specified, raise a MutuallyExclusiveArgumentError. :return: bool """ return self._get_enable_ahub(enable_validation=True)
Obtain the value of enable_ahub. Note: enable_ahub will not be directly decorated into the `mc` object. This function will verify the parameter by default. If both enable_ahub and disable_ahub are specified, raise a MutuallyExclusiveArgumentError. :return: bool
get_enable_ahub
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_disable_ahub(self, enable_validation: bool = False) -> bool: """Internal function to obtain the value of disable_ahub. Note: disable_ahub will not be directly decorated into the `mc` object. This function supports the option of enable_validation. When enabled, if both enable_ahub and disable_ahub are specified, raise a MutuallyExclusiveArgumentError. :return: bool """ # read the original value passed by the command disable_ahub = self.raw_param.get("disable_ahub") # We do not support this option in create mode, therefore we do not read the value from `mc`. # this parameter does not need dynamic completion # validation if enable_validation: if disable_ahub and self._get_enable_ahub(enable_validation=False): raise MutuallyExclusiveArgumentError( 'Cannot specify "--enable-ahub" and "--disable-ahub" at the same time' ) return disable_ahub
Internal function to obtain the value of disable_ahub. Note: disable_ahub will not be directly decorated into the `mc` object. This function supports the option of enable_validation. When enabled, if both enable_ahub and disable_ahub are specified, raise a MutuallyExclusiveArgumentError. :return: bool
_get_disable_ahub
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_disable_ahub(self) -> bool: """Obtain the value of disable_ahub. Note: disable_ahub will not be directly decorated into the `mc` object. This function will verify the parameter by default. If both enable_ahub and disable_ahub are specified, raise a MutuallyExclusiveArgumentError. :return: bool """ return self._get_disable_ahub(enable_validation=True)
Obtain the value of disable_ahub. Note: disable_ahub will not be directly decorated into the `mc` object. This function will verify the parameter by default. If both enable_ahub and disable_ahub are specified, raise a MutuallyExclusiveArgumentError. :return: bool
get_disable_ahub
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_enable_windows_gmsa(self, enable_validation: bool = False) -> bool: """Internal function to obtain the value of enable_windows_gmsa. This function supports the option of enable_validation. Please refer to function __validate_gmsa_options for details of validation. :return: bool """ # read the original value passed by the command enable_windows_gmsa = self.raw_param.get("enable_windows_gmsa") # In create mode, try to read the property value corresponding to the parameter from the `mc` object. if self.decorator_mode == DecoratorMode.CREATE: if ( self.mc and self.mc.windows_profile and hasattr(self.mc.windows_profile, "gmsa_profile") and # backward compatibility self.mc.windows_profile.gmsa_profile and self.mc.windows_profile.gmsa_profile.enabled is not None ): enable_windows_gmsa = self.mc.windows_profile.gmsa_profile.enabled # this parameter does not need dynamic completion # validation if enable_validation: ( gmsa_dns_server, gmsa_root_domain_name, ) = self._get_gmsa_dns_server_and_root_domain_name( enable_validation=False ) self.__validate_gmsa_options( enable_windows_gmsa, self._get_disable_windows_gmsa(enable_validation=False), gmsa_dns_server, gmsa_root_domain_name, self.get_yes() ) return enable_windows_gmsa
Internal function to obtain the value of enable_windows_gmsa. This function supports the option of enable_validation. Please refer to function __validate_gmsa_options for details of validation. :return: bool
_get_enable_windows_gmsa
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_enable_windows_gmsa(self) -> bool: """Obtain the value of enable_windows_gmsa. This function will verify the parameter by default. When enable_windows_gmsa is specified, a ; if both gmsa_dns_server and gmsa_root_domain_name are not assigned and user does not confirm the operation, a DecoratorEarlyExitException will be raised; if only one of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. When enable_windows_gmsa is not specified, if any of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. :return: bool """ return self._get_enable_windows_gmsa(enable_validation=True)
Obtain the value of enable_windows_gmsa. This function will verify the parameter by default. When enable_windows_gmsa is specified, a ; if both gmsa_dns_server and gmsa_root_domain_name are not assigned and user does not confirm the operation, a DecoratorEarlyExitException will be raised; if only one of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. When enable_windows_gmsa is not specified, if any of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. :return: bool
get_enable_windows_gmsa
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_gmsa_dns_server_and_root_domain_name(self, enable_validation: bool = False): """Internal function to obtain the values of gmsa_dns_server and gmsa_root_domain_name. This function supports the option of enable_validation. Please refer to function __validate_gmsa_options for details of validation. :return: a tuple containing two elements: gmsa_dns_server of string type or None and gmsa_root_domain_name of string type or None """ # gmsa_dns_server # read the original value passed by the command gmsa_dns_server = self.raw_param.get("gmsa_dns_server") # In create mode, try to read the property value corresponding to the parameter from the `mc` object. gmsa_dns_read_from_mc = False if self.decorator_mode == DecoratorMode.CREATE: if ( self.mc and self.mc.windows_profile and hasattr(self.mc.windows_profile, "gmsa_profile") and # backward compatibility self.mc.windows_profile.gmsa_profile and self.mc.windows_profile.gmsa_profile.dns_server is not None ): gmsa_dns_server = self.mc.windows_profile.gmsa_profile.dns_server gmsa_dns_read_from_mc = True # gmsa_root_domain_name # read the original value passed by the command gmsa_root_domain_name = self.raw_param.get("gmsa_root_domain_name") # In create mode, try to read the property value corresponding to the parameter from the `mc` object. gmsa_root_read_from_mc = False if self.decorator_mode == DecoratorMode.CREATE: if ( self.mc and self.mc.windows_profile and hasattr(self.mc.windows_profile, "gmsa_profile") and # backward compatibility self.mc.windows_profile.gmsa_profile and self.mc.windows_profile.gmsa_profile.root_domain_name is not None ): gmsa_root_domain_name = self.mc.windows_profile.gmsa_profile.root_domain_name gmsa_root_read_from_mc = True # consistent check if gmsa_dns_read_from_mc != gmsa_root_read_from_mc: raise CLIInternalError( "Inconsistent state detected, one of gmsa_dns_server and gmsa_root_domain_name " "is read from the `mc` object." ) # this parameter does not need dynamic completion # validation if enable_validation: self.__validate_gmsa_options( self._get_enable_windows_gmsa(enable_validation=False), self._get_disable_windows_gmsa(enable_validation=False), gmsa_dns_server, gmsa_root_domain_name, self.get_yes(), ) return gmsa_dns_server, gmsa_root_domain_name
Internal function to obtain the values of gmsa_dns_server and gmsa_root_domain_name. This function supports the option of enable_validation. Please refer to function __validate_gmsa_options for details of validation. :return: a tuple containing two elements: gmsa_dns_server of string type or None and gmsa_root_domain_name of string type or None
_get_gmsa_dns_server_and_root_domain_name
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_gmsa_dns_server_and_root_domain_name(self) -> Tuple[Union[str, None], Union[str, None]]: """Obtain the values of gmsa_dns_server and gmsa_root_domain_name. This function will verify the parameter by default. When enable_windows_gmsa is specified, if both gmsa_dns_server and gmsa_root_domain_name are not assigned and user does not confirm the operation, a DecoratorEarlyExitException will be raised; if only one of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. When enable_windows_gmsa is not specified, if any of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. :return: a tuple containing two elements: gmsa_dns_server of string type or None and gmsa_root_domain_name of string type or None """ return self._get_gmsa_dns_server_and_root_domain_name(enable_validation=True)
Obtain the values of gmsa_dns_server and gmsa_root_domain_name. This function will verify the parameter by default. When enable_windows_gmsa is specified, if both gmsa_dns_server and gmsa_root_domain_name are not assigned and user does not confirm the operation, a DecoratorEarlyExitException will be raised; if only one of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. When enable_windows_gmsa is not specified, if any of gmsa_dns_server or gmsa_root_domain_name is assigned, raise a RequiredArgumentMissingError. :return: a tuple containing two elements: gmsa_dns_server of string type or None and gmsa_root_domain_name of string type or None
get_gmsa_dns_server_and_root_domain_name
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_disable_windows_gmsa(self, enable_validation: bool = False) -> bool: """Internal function to obtain the value of disable_windows_gmsa. This function supports the option of enable_validation. Please refer to function __validate_gmsa_options for details of validation. :return: bool """ # disable_windows_gmsa is only supported in UPDATE if self.decorator_mode == DecoratorMode.CREATE: disable_windows_gmsa = False else: # read the original value passed by the command disable_windows_gmsa = self.raw_param.get("disable_windows_gmsa") # this parameter does not need dynamic completion # validation if enable_validation: ( gmsa_dns_server, gmsa_root_domain_name, ) = self._get_gmsa_dns_server_and_root_domain_name( enable_validation=False ) self.__validate_gmsa_options( self._get_enable_windows_gmsa(enable_validation=False), disable_windows_gmsa, gmsa_dns_server, gmsa_root_domain_name, self.get_yes(), ) return disable_windows_gmsa
Internal function to obtain the value of disable_windows_gmsa. This function supports the option of enable_validation. Please refer to function __validate_gmsa_options for details of validation. :return: bool
_get_disable_windows_gmsa
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_disable_windows_gmsa(self) -> bool: """Obtain the value of disable_windows_gmsa. This function will verify the parameter by default. When disable_windows_gmsa is specified, if gmsa_dns_server or gmsa_root_domain_name is assigned, a InvalidArgumentValueError will be raised; :return: bool """ return self._get_disable_windows_gmsa(enable_validation=True)
Obtain the value of disable_windows_gmsa. This function will verify the parameter by default. When disable_windows_gmsa is specified, if gmsa_dns_server or gmsa_root_domain_name is assigned, a InvalidArgumentValueError will be raised; :return: bool
get_disable_windows_gmsa
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_service_principal_and_client_secret( self, enable_validation: bool = False, read_only: bool = False ) -> Tuple[Union[str, None], Union[str, None]]: """Internal function to dynamically obtain the values of service_principal and client_secret according to the context. This function supports the option of enable_validation. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: a tuple containing two elements: service_principal of string type or None and client_secret of string type or None """ # service_principal # read the original value passed by the command service_principal = self.raw_param.get("service_principal") # try to read the property value corresponding to the parameter from the `mc` object sp_read_from_mc = False if ( self.mc and self.mc.service_principal_profile and self.mc.service_principal_profile.client_id is not None ): service_principal = self.mc.service_principal_profile.client_id sp_read_from_mc = True # client_secret # read the original value passed by the command client_secret = self.raw_param.get("client_secret") # try to read the property value corresponding to the parameter from the `mc` object secret_read_from_mc = False if ( self.mc and self.mc.service_principal_profile and self.mc.service_principal_profile.secret is not None ): client_secret = self.mc.service_principal_profile.secret secret_read_from_mc = True # consistent check if sp_read_from_mc != secret_read_from_mc: raise CLIInternalError( "Inconsistent state detected, one of sp and secret is read from the `mc` object." ) # skip dynamic completion & validation if option read_only is specified if read_only: return service_principal, client_secret # these parameters do not need dynamic completion # validation if enable_validation: # only one of service_principal and client_secret is provided, not both if (service_principal or client_secret) and not (service_principal and client_secret): raise RequiredArgumentMissingError( "Please provide both --service-principal and --client-secret to use sp as the cluster identity. " "An sp can be created using the 'az ad sp create-for-rbac' command." ) return service_principal, client_secret
Internal function to dynamically obtain the values of service_principal and client_secret according to the context. This function supports the option of enable_validation. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: a tuple containing two elements: service_principal of string type or None and client_secret of string type or None
_get_service_principal_and_client_secret
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_service_principal_and_client_secret( self ) -> Tuple[Union[str, None], Union[str, None]]: """Dynamically obtain the values of service_principal and client_secret according to the context. :return: a tuple containing two elements: service_principal of string type or None and client_secret of string type or None """ return self._get_service_principal_and_client_secret(enable_validation=True)
Dynamically obtain the values of service_principal and client_secret according to the context. :return: a tuple containing two elements: service_principal of string type or None and client_secret of string type or None
get_service_principal_and_client_secret
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_enable_managed_identity( self, enable_validation: bool = False, read_only: bool = False ) -> bool: """Internal function to dynamically obtain the values of service_principal and client_secret according to the context. Note: enable_managed_identity will not be directly decorated into the `mc` object. When both service_principal and client_secret are assigned and enable_managed_identity is True, dynamic completion will be triggered. The value of enable_managed_identity will be set to False. This function supports the option of enable_validation. When enabled, if enable_managed_identity is not specified and assign_identity is assigned, a RequiredArgumentMissingError will be raised. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: bool """ # read the original value passed by the command enable_managed_identity = self.raw_param.get("enable_managed_identity") # In create mode, try to read the property value corresponding to the parameter from the `mc` object if self.decorator_mode == DecoratorMode.CREATE: if self.mc and self.mc.identity: enable_managed_identity = check_is_msi_cluster(self.mc) # skip dynamic completion & validation if option read_only is specified if read_only: return enable_managed_identity # dynamic completion for create mode only if self.decorator_mode == DecoratorMode.CREATE: # if user does not specify service principal or client secret, # backfill the value of enable_managed_identity to True ( service_principal, client_secret, ) = self._get_service_principal_and_client_secret(read_only=True) if not (service_principal or client_secret) and not enable_managed_identity: enable_managed_identity = True # validation if enable_validation: if self.decorator_mode == DecoratorMode.CREATE: ( service_principal, client_secret, ) = self._get_service_principal_and_client_secret(read_only=True) if (service_principal or client_secret) and enable_managed_identity: raise MutuallyExclusiveArgumentError( "Cannot specify --enable-managed-identity and --service-principal/--client-secret at same time" ) if not enable_managed_identity and self._get_assign_identity(enable_validation=False): raise RequiredArgumentMissingError( "--assign-identity can only be specified when --enable-managed-identity is specified" ) return enable_managed_identity
Internal function to dynamically obtain the values of service_principal and client_secret according to the context. Note: enable_managed_identity will not be directly decorated into the `mc` object. When both service_principal and client_secret are assigned and enable_managed_identity is True, dynamic completion will be triggered. The value of enable_managed_identity will be set to False. This function supports the option of enable_validation. When enabled, if enable_managed_identity is not specified and assign_identity is assigned, a RequiredArgumentMissingError will be raised. This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: bool
_get_enable_managed_identity
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_enable_managed_identity(self) -> bool: """Dynamically obtain the values of service_principal and client_secret according to the context. Note: enable_managed_identity will not be directly decorated into the `mc` object. When both service_principal and client_secret are assigned and enable_managed_identity is True, dynamic completion will be triggered. The value of enable_managed_identity will be set to False. This function will verify the parameter by default. If enable_managed_identity is not specified and assign_identity is assigned, a RequiredArgumentMissingError will be raised. :return: bool """ return self._get_enable_managed_identity(enable_validation=True)
Dynamically obtain the values of service_principal and client_secret according to the context. Note: enable_managed_identity will not be directly decorated into the `mc` object. When both service_principal and client_secret are assigned and enable_managed_identity is True, dynamic completion will be triggered. The value of enable_managed_identity will be set to False. This function will verify the parameter by default. If enable_managed_identity is not specified and assign_identity is assigned, a RequiredArgumentMissingError will be raised. :return: bool
get_enable_managed_identity
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_skip_subnet_role_assignment(self) -> bool: """Obtain the value of skip_subnet_role_assignment. Note: skip_subnet_role_assignment will not be decorated into the `mc` object. :return: bool """ # read the original value passed by the command skip_subnet_role_assignment = self.raw_param.get("skip_subnet_role_assignment") # this parameter does not need dynamic completion # this parameter does not need validation return skip_subnet_role_assignment
Obtain the value of skip_subnet_role_assignment. Note: skip_subnet_role_assignment will not be decorated into the `mc` object. :return: bool
get_skip_subnet_role_assignment
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_assign_identity(self, enable_validation: bool = False) -> Union[str, None]: """Internal function to obtain the value of assign_identity. This function supports the option of enable_validation. When enabled, if enable_managed_identity is not specified and assign_identity is assigned, a RequiredArgumentMissingError will be raised. Besides, if assign_identity is not assigned but assign_kubelet_identity is, a RequiredArgumentMissingError will be raised. :return: string or None """ # read the original value passed by the command assign_identity = self.raw_param.get("assign_identity") # In create mode, try to read the property value corresponding to the parameter from the `mc` object if self.decorator_mode == DecoratorMode.CREATE: if ( self.mc and self.mc.identity and self.mc.identity.user_assigned_identities is not None ): value_obtained_from_mc = safe_list_get( list(self.mc.identity.user_assigned_identities.keys()), 0, None ) if value_obtained_from_mc is not None: assign_identity = value_obtained_from_mc # override to use shared identity in managed live test if use_shared_identity(): if self._get_enable_managed_identity(enable_validation=False): if ( self.decorator_mode == DecoratorMode.CREATE or (self.decorator_mode == DecoratorMode.UPDATE and not assign_identity) ): assign_identity = get_shared_control_plane_identity(designated_identity=assign_identity) # this parameter does not need dynamic completion # validation if enable_validation: if assign_identity: if not self._get_enable_managed_identity(enable_validation=False): raise RequiredArgumentMissingError( "--assign-identity can only be specified when --enable-managed-identity is specified" ) else: if self.decorator_mode == DecoratorMode.CREATE: if self._get_assign_kubelet_identity(enable_validation=False): raise RequiredArgumentMissingError( "--assign-kubelet-identity can only be specified when --assign-identity is specified" ) return assign_identity
Internal function to obtain the value of assign_identity. This function supports the option of enable_validation. When enabled, if enable_managed_identity is not specified and assign_identity is assigned, a RequiredArgumentMissingError will be raised. Besides, if assign_identity is not assigned but assign_kubelet_identity is, a RequiredArgumentMissingError will be raised. :return: string or None
_get_assign_identity
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_assign_identity(self) -> Union[str, None]: """Obtain the value of assign_identity. This function will verify the parameter by default. If enable_managed_identity is not specified and assign_identity is assigned, a RequiredArgumentMissingError will be raised. Besides, if assign_identity is not assigned but assign_kubelet_identity is, a RequiredArgumentMissingError will be raised. :return: string or None """ return self._get_assign_identity(enable_validation=True)
Obtain the value of assign_identity. This function will verify the parameter by default. If enable_managed_identity is not specified and assign_identity is assigned, a RequiredArgumentMissingError will be raised. Besides, if assign_identity is not assigned but assign_kubelet_identity is, a RequiredArgumentMissingError will be raised. :return: string or None
get_assign_identity
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_identity_by_msi_client(self, assigned_identity: str) -> Identity: """Helper function to obtain the identity object by msi client. Note: This is a wrapper of the external function "get_user_assigned_identity_by_resource_id", and the return value of this function will not be directly decorated into the `mc` object. This function will use ManagedServiceIdentityClient to send the request, and return an identity object. ResourceNotFoundError, ClientRequestError or InvalidArgumentValueError exceptions might be raised in the above process. :return: string """ return self.external_functions.get_user_assigned_identity_by_resource_id(self.cmd.cli_ctx, assigned_identity)
Helper function to obtain the identity object by msi client. Note: This is a wrapper of the external function "get_user_assigned_identity_by_resource_id", and the return value of this function will not be directly decorated into the `mc` object. This function will use ManagedServiceIdentityClient to send the request, and return an identity object. ResourceNotFoundError, ClientRequestError or InvalidArgumentValueError exceptions might be raised in the above process. :return: string
get_identity_by_msi_client
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_user_assigned_identity_client_id(self, user_assigned_identity=None) -> str: """Helper function to obtain the client_id of user assigned identity. Note: This is not a parameter of aks_create, and it will not be decorated into the `mc` object. Parse assign_identity and use ManagedServiceIdentityClient to send the request, get the client_id field in the returned identity object. ResourceNotFoundError, ClientRequestError or InvalidArgumentValueError exceptions may be raised in the above process. :return: string """ assigned_identity = user_assigned_identity if user_assigned_identity else self.get_assign_identity() if assigned_identity is None or assigned_identity == "": raise RequiredArgumentMissingError("No assigned identity provided.") return self.get_identity_by_msi_client(assigned_identity).client_id
Helper function to obtain the client_id of user assigned identity. Note: This is not a parameter of aks_create, and it will not be decorated into the `mc` object. Parse assign_identity and use ManagedServiceIdentityClient to send the request, get the client_id field in the returned identity object. ResourceNotFoundError, ClientRequestError or InvalidArgumentValueError exceptions may be raised in the above process. :return: string
get_user_assigned_identity_client_id
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_user_assigned_identity_object_id(self, user_assigned_identity=None) -> str: """Helper function to obtain the principal_id of user assigned identity. Note: This is not a parameter of aks_create, and it will not be decorated into the `mc` object. Parse assign_identity and use ManagedServiceIdentityClient to send the request, get the principal_id field in the returned identity object. ResourceNotFoundError, ClientRequestError or InvalidArgumentValueError exceptions may be raised in the above process. :return: string """ assigned_identity = user_assigned_identity if user_assigned_identity else self.get_assign_identity() if assigned_identity is None or assigned_identity == "": raise RequiredArgumentMissingError("No assigned identity provided.") return self.get_identity_by_msi_client(assigned_identity).principal_id
Helper function to obtain the principal_id of user assigned identity. Note: This is not a parameter of aks_create, and it will not be decorated into the `mc` object. Parse assign_identity and use ManagedServiceIdentityClient to send the request, get the principal_id field in the returned identity object. ResourceNotFoundError, ClientRequestError or InvalidArgumentValueError exceptions may be raised in the above process. :return: string
get_user_assigned_identity_object_id
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_attach_acr(self) -> Union[str, None]: """Obtain the value of attach_acr. Note: attach_acr will not be decorated into the `mc` object. This function will verify the parameter by default in create mode. When attach_acr is assigned, if both enable_managed_identity and no_wait are assigned, a MutuallyExclusiveArgumentError will be raised; if service_principal is not assigned, raise a RequiredArgumentMissingError. :return: string or None """ # read the original value passed by the command attach_acr = self.raw_param.get("attach_acr") # this parameter does not need dynamic completion # validation if self.decorator_mode == DecoratorMode.CREATE and attach_acr: if self._get_enable_managed_identity(enable_validation=False): # Attach acr operation will be handled after the cluster is created if self.get_no_wait(): raise MutuallyExclusiveArgumentError( "When --attach-acr and --enable-managed-identity are both specified, " "--no-wait is not allowed, please wait until the whole operation succeeds." ) else: # newly added check, check whether client_id exists before creating role assignment service_principal, _ = self._get_service_principal_and_client_secret(read_only=True) if not service_principal: raise RequiredArgumentMissingError( "No service principal provided to create the acrpull role assignment for acr." ) return attach_acr
Obtain the value of attach_acr. Note: attach_acr will not be decorated into the `mc` object. This function will verify the parameter by default in create mode. When attach_acr is assigned, if both enable_managed_identity and no_wait are assigned, a MutuallyExclusiveArgumentError will be raised; if service_principal is not assigned, raise a RequiredArgumentMissingError. :return: string or None
get_attach_acr
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_detach_acr(self) -> Union[str, None]: """Obtain the value of detach_acr. Note: detach_acr will not be decorated into the `mc` object. :return: string or None """ # read the original value passed by the command detach_acr = self.raw_param.get("detach_acr") # this parameter does not need dynamic completion # this parameter does not need validation return detach_acr
Obtain the value of detach_acr. Note: detach_acr will not be decorated into the `mc` object. :return: string or None
get_detach_acr
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_http_proxy_config(self) -> Union[Dict, ManagedClusterHTTPProxyConfig, None]: """Obtain the value of http_proxy_config. :return: dictionary, ManagedClusterHTTPProxyConfig or None """ # read the original value passed by the command http_proxy_config = None http_proxy_config_file_path = self.raw_param.get("http_proxy_config") # validate user input if http_proxy_config_file_path: if not os.path.isfile(http_proxy_config_file_path): raise InvalidArgumentValueError( "{} is not valid file, or not accessable.".format( http_proxy_config_file_path ) ) http_proxy_config = get_file_json(http_proxy_config_file_path) if not isinstance(http_proxy_config, dict): raise InvalidArgumentValueError( "Error reading Http Proxy Config from {}. " "Please see https://aka.ms/HttpProxyConfig for correct format.".format( http_proxy_config_file_path ) ) # In create mode, try to read the property value corresponding to the parameter from the `mc` object if self.decorator_mode == DecoratorMode.CREATE: if ( self.mc and hasattr(self.mc, "http_proxy_config") and self.mc.http_proxy_config is not None ): http_proxy_config = self.mc.http_proxy_config # this parameter does not need dynamic completion # this parameter does not need validation return http_proxy_config
Obtain the value of http_proxy_config. :return: dictionary, ManagedClusterHTTPProxyConfig or None
get_http_proxy_config
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_assignee_from_identity_or_sp_profile(self) -> Tuple[str, bool]: """Helper function to obtain the value of assignee from identity_profile or service_principal_profile. Note: This is not a parameter of aks_update, and it will not be decorated into the `mc` object. If assignee cannot be obtained, raise an UnknownError. :return: string, bool """ assignee = None is_service_principal = False if check_is_msi_cluster(self.mc): if self.mc.identity_profile is None or self.mc.identity_profile["kubeletidentity"] is None: raise UnknownError( "Unexpected error getting kubelet's identity for the cluster. " "Please do not set --attach-acr or --detach-acr. " "You can manually grant or revoke permission to the identity named " "<ClUSTER_NAME>-agentpool in MC_ resource group to access ACR." ) assignee = self.mc.identity_profile["kubeletidentity"].object_id is_service_principal = False elif self.mc and self.mc.service_principal_profile is not None: assignee = self.mc.service_principal_profile.client_id is_service_principal = True if not assignee: raise UnknownError('Cannot get the AKS cluster\'s service principal.') return assignee, is_service_principal
Helper function to obtain the value of assignee from identity_profile or service_principal_profile. Note: This is not a parameter of aks_update, and it will not be decorated into the `mc` object. If assignee cannot be obtained, raise an UnknownError. :return: string, bool
get_assignee_from_identity_or_sp_profile
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_load_balancer_sku(self, enable_validation: bool = False) -> Union[str, None]: """Internal function to obtain the value of load_balancer_sku, default value is CONST_LOAD_BALANCER_SKU_STANDARD. Note: When returning a string, it will always be lowercase. This function supports the option of enable_validation. When enabled, it will check if load_balancer_sku equals to CONST_LOAD_BALANCER_SKU_BASIC, if so, when api_server_authorized_ip_ranges is assigned or enable_private_cluster is specified, raise an InvalidArgumentValueError. :return: string or None """ # read the original value passed by the command load_balancer_sku = safe_lower(self.raw_param.get("load_balancer_sku", CONST_LOAD_BALANCER_SKU_STANDARD)) # try to read the property value corresponding to the parameter from the `mc` object if ( self.mc and self.mc.network_profile and self.mc.network_profile.load_balancer_sku is not None ): load_balancer_sku = safe_lower( self.mc.network_profile.load_balancer_sku ) # validation if enable_validation: if load_balancer_sku == CONST_LOAD_BALANCER_SKU_BASIC: if self._get_api_server_authorized_ip_ranges(enable_validation=False): raise InvalidArgumentValueError( "--api-server-authorized-ip-ranges can only be used with standard load balancer" ) if self._get_enable_private_cluster(enable_validation=False): raise InvalidArgumentValueError( "Please use standard load balancer for private cluster" ) return load_balancer_sku
Internal function to obtain the value of load_balancer_sku, default value is CONST_LOAD_BALANCER_SKU_STANDARD. Note: When returning a string, it will always be lowercase. This function supports the option of enable_validation. When enabled, it will check if load_balancer_sku equals to CONST_LOAD_BALANCER_SKU_BASIC, if so, when api_server_authorized_ip_ranges is assigned or enable_private_cluster is specified, raise an InvalidArgumentValueError. :return: string or None
_get_load_balancer_sku
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_load_balancer_sku(self) -> Union[str, None]: """Obtain the value of load_balancer_sku, default value is CONST_LOAD_BALANCER_SKU_STANDARD. Note: When returning a string, it will always be lowercase. This function will verify the parameter by default. It will check if load_balancer_sku equals to CONST_LOAD_BALANCER_SKU_BASIC, if so, when api_server_authorized_ip_ranges is assigned or enable_private_cluster is specified, raise an InvalidArgumentValueError. :return: string or None """ return safe_lower(self._get_load_balancer_sku(enable_validation=True))
Obtain the value of load_balancer_sku, default value is CONST_LOAD_BALANCER_SKU_STANDARD. Note: When returning a string, it will always be lowercase. This function will verify the parameter by default. It will check if load_balancer_sku equals to CONST_LOAD_BALANCER_SKU_BASIC, if so, when api_server_authorized_ip_ranges is assigned or enable_private_cluster is specified, raise an InvalidArgumentValueError. :return: string or None
get_load_balancer_sku
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_load_balancer_managed_outbound_ip_count(self) -> Union[int, None]: """Obtain the value of load_balancer_managed_outbound_ip_count. Note: SDK performs the following validation {'maximum': 100, 'minimum': 1}. :return: int or None """ # read the original value passed by the command return self.raw_param.get("load_balancer_managed_outbound_ip_count")
Obtain the value of load_balancer_managed_outbound_ip_count. Note: SDK performs the following validation {'maximum': 100, 'minimum': 1}. :return: int or None
get_load_balancer_managed_outbound_ip_count
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_load_balancer_managed_outbound_ipv6_count(self) -> Union[int, None]: """Obtain the expected count of IPv6 managed outbound IPs. Note: SDK provides default value 0 and performs the following validation {'maximum': 100, 'minimum': 0}. :return: int or None """ return self.raw_param.get('load_balancer_managed_outbound_ipv6_count')
Obtain the expected count of IPv6 managed outbound IPs. Note: SDK provides default value 0 and performs the following validation {'maximum': 100, 'minimum': 0}. :return: int or None
get_load_balancer_managed_outbound_ipv6_count
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_load_balancer_outbound_ips(self) -> Union[str, List[ResourceReference], None]: """Obtain the value of load_balancer_outbound_ips. Note: SDK performs the following validation {'maximum': 16, 'minimum': 1}. :return: string, list of ResourceReference, or None """ # read the original value passed by the command return self.raw_param.get("load_balancer_outbound_ips")
Obtain the value of load_balancer_outbound_ips. Note: SDK performs the following validation {'maximum': 16, 'minimum': 1}. :return: string, list of ResourceReference, or None
get_load_balancer_outbound_ips
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_load_balancer_outbound_ip_prefixes(self) -> Union[str, List[ResourceReference], None]: """Obtain the value of load_balancer_outbound_ip_prefixes. :return: string, list of ResourceReference, or None """ # read the original value passed by the command return self.raw_param.get("load_balancer_outbound_ip_prefixes")
Obtain the value of load_balancer_outbound_ip_prefixes. :return: string, list of ResourceReference, or None
get_load_balancer_outbound_ip_prefixes
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_load_balancer_outbound_ports(self) -> Union[int, None]: """Obtain the value of load_balancer_outbound_ports. Note: SDK performs the following validation {'maximum': 64000, 'minimum': 0}. :return: int or None """ # read the original value passed by the command return self.raw_param.get( "load_balancer_outbound_ports" )
Obtain the value of load_balancer_outbound_ports. Note: SDK performs the following validation {'maximum': 64000, 'minimum': 0}. :return: int or None
get_load_balancer_outbound_ports
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_load_balancer_idle_timeout(self) -> Union[int, None]: """Obtain the value of load_balancer_idle_timeout. Note: SDK performs the following validation {'maximum': 120, 'minimum': 4}. :return: int or None """ # read the original value passed by the command return self.raw_param.get( "load_balancer_idle_timeout" )
Obtain the value of load_balancer_idle_timeout. Note: SDK performs the following validation {'maximum': 120, 'minimum': 4}. :return: int or None
get_load_balancer_idle_timeout
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_load_balancer_backend_pool_type(self) -> Union[str, None]: """Obtain the value of load_balancer_backend_pool_type. :return: string """ # read the original value passed by the command load_balancer_backend_pool_type = self.raw_param.get( "load_balancer_backend_pool_type" ) # this parameter does not need dynamic completion # this parameter does not need validation return load_balancer_backend_pool_type
Obtain the value of load_balancer_backend_pool_type. :return: string
get_load_balancer_backend_pool_type
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_nrg_lockdown_restriction_level(self) -> Union[str, None]: """Obtain the value of nrg_lockdown_restriction_level. :return: string or None """ # read the original value passed by the command nrg_lockdown_restriction_level = self.raw_param.get("nrg_lockdown_restriction_level") # In create mode, try to read the property value corresponding to the parameter from the `mc` object. if self.decorator_mode == DecoratorMode.CREATE: if ( self.mc and hasattr(self.mc, "nrg_lockdown_restriction_level") and # for backward compatibility self.mc.node_resource_group_profile and self.mc.node_resource_group_profile.restriction_level is not None ): nrg_lockdown_restriction_level = self.mc.node_resource_group_profile.restriction_level # this parameter does not need dynamic completion # this parameter does not need validation return nrg_lockdown_restriction_level
Obtain the value of nrg_lockdown_restriction_level. :return: string or None
get_nrg_lockdown_restriction_level
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_nat_gateway_managed_outbound_ip_count(self) -> Union[int, None]: """Obtain the value of nat_gateway_managed_outbound_ip_count. Note: SDK provides default value 1 and performs the following validation {'maximum': 16, 'minimum': 1}. :return: int or None """ # read the original value passed by the command nat_gateway_managed_outbound_ip_count = self.raw_param.get("nat_gateway_managed_outbound_ip_count") # this parameter does not need dynamic completion # this parameter does not need validation return nat_gateway_managed_outbound_ip_count
Obtain the value of nat_gateway_managed_outbound_ip_count. Note: SDK provides default value 1 and performs the following validation {'maximum': 16, 'minimum': 1}. :return: int or None
get_nat_gateway_managed_outbound_ip_count
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_nat_gateway_idle_timeout(self) -> Union[int, None]: """Obtain the value of nat_gateway_idle_timeout. Note: SDK provides default value 4 and performs the following validation {'maximum': 120, 'minimum': 4}. :return: int or None """ # read the original value passed by the command nat_gateway_idle_timeout = self.raw_param.get("nat_gateway_idle_timeout") # this parameter does not need dynamic completion # this parameter does not need validation return nat_gateway_idle_timeout
Obtain the value of nat_gateway_idle_timeout. Note: SDK provides default value 4 and performs the following validation {'maximum': 120, 'minimum': 4}. :return: int or None
get_nat_gateway_idle_timeout
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_pod_cidrs(self) -> Union[List[str], None]: """Obtain the CIDR ranges used for pod subnets. :return: List[str] or None """ # read the original value passed by the command pod_cidrs = self.raw_param.get("pod_cidrs") # normalize pod_cidrs = extract_comma_separated_string(pod_cidrs, keep_none=True, default_value=[]) # try to read the property value corresponding to the parameter from the `mc` object if self.mc and self.mc.network_profile and self.mc.network_profile.pod_cidrs is not None: pod_cidrs = self.mc.network_profile.pod_cidrs # this parameter does not need dynamic completion # this parameter does not need validation return pod_cidrs
Obtain the CIDR ranges used for pod subnets. :return: List[str] or None
get_pod_cidrs
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_service_cidrs(self) -> Union[List[str], None]: """Obtain the CIDR ranges for the service subnet. :return: List[str] or None """ # read the original value passed by the command service_cidrs = self.raw_param.get("service_cidrs") # normalize service_cidrs = extract_comma_separated_string(service_cidrs, keep_none=True, default_value=[]) # try to read the property value corresponding to the parameter from the `mc` object if self.mc and self.mc.network_profile and self.mc.network_profile.service_cidrs is not None: service_cidrs = self.mc.network_profile.service_cidrs # this parameter does not need dynamic completion # this parameter does not need validation return service_cidrs
Obtain the CIDR ranges for the service subnet. :return: List[str] or None
get_service_cidrs
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_ip_families(self) -> Union[List[str], None]: """Obtain the value of ip_families. :return: List[str] or None """ # read the original value passed by the command ip_families = self.raw_param.get("ip_families") # normalize ip_families = extract_comma_separated_string(ip_families, keep_none=True, default_value=[]) # try to read the property value corresponding to the parameter from the `mc` object if ( not ip_families and self.mc and self.mc.network_profile and self.mc.network_profile.ip_families is not None ): ip_families = self.mc.network_profile.ip_families # this parameter does not need dynamic completion # this parameter does not need validation return ip_families
Obtain the value of ip_families. :return: List[str] or None
get_ip_families
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_outbound_type( self, enable_validation: bool = False, read_only: bool = False, ) -> Union[str, None]: """Internal function to dynamically obtain the value of outbound_type according to the context. Note: All the external parameters involved in the validation are not verified in their own getters. When outbound_type is not assigned, dynamic completion will be triggerd. By default, the value is set to CONST_OUTBOUND_TYPE_LOAD_BALANCER. This function supports the option of enable_validation. When enabled, if the value of outbound_type is CONST_OUTBOUND_TYPE_LOAD_BALANCER,CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY, CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY or CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING, the following checks will be performed. If load_balancer_sku is set to basic, an InvalidArgumentValueError will be raised. If vnet_subnet_id is not assigned, a RequiredArgumentMissingError will be raised. If any of load_balancer_managed_outbound_ip_count, This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: string or None """ # read the original value passed by the command outbound_type = self.raw_param.get("outbound_type") # try to read the property value corresponding to the parameter from the `mc` object read_from_mc = False if outbound_type is None: if ( self.mc and self.mc.network_profile and self.mc.network_profile.outbound_type is not None ): outbound_type = self.mc.network_profile.outbound_type read_from_mc = True # skip dynamic completion & validation if option read_only is specified if read_only: return outbound_type isBasicSKULb = safe_lower(self._get_load_balancer_sku(enable_validation=False)) == CONST_LOAD_BALANCER_SKU_BASIC # dynamic completion if not read_from_mc and not isBasicSKULb and outbound_type is None: outbound_type = CONST_OUTBOUND_TYPE_LOAD_BALANCER # validation # Note: The parameters involved in the validation are not verified in their own getters. if enable_validation: if not read_from_mc and outbound_type is not None and outbound_type not in [ CONST_OUTBOUND_TYPE_LOAD_BALANCER, CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY, CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY, CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING, "none" ]: raise InvalidArgumentValueError( "Invalid outbound type, supported values are loadBalancer, managedNATGateway, userAssignedNATGateway and " "userDefinedRouting. Please refer to " "https://learn.microsoft.com/en-us/azure/aks/egress-outboundtype#updating-outboundtype-after-cluster-creation " # pylint:disable=line-too-long "for more details." ) if isBasicSKULb: if outbound_type is not None: raise InvalidArgumentValueError( "{outbound_type} doesn't support basic load balancer sku".format(outbound_type=outbound_type) ) return outbound_type # basic sku lb doesn't support outbound type if outbound_type == CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING: if self.get_vnet_subnet_id() in ["", None]: raise RequiredArgumentMissingError( "--vnet-subnet-id must be specified for userDefinedRouting and it must " "be pre-configured with a route table with egress rules" ) if outbound_type == CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY: if self.get_vnet_subnet_id() in ["", None]: raise RequiredArgumentMissingError( "--vnet-subnet-id must be specified for userAssignedNATGateway and it must " "be pre-configured with a NAT gateway with outbound ips" ) if outbound_type == CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY: if self.get_vnet_subnet_id() not in ["", None]: raise InvalidArgumentValueError( "--vnet-subnet-id cannot be specified for managedNATGateway" ) if outbound_type != CONST_OUTBOUND_TYPE_LOAD_BALANCER: if ( self.get_load_balancer_managed_outbound_ip_count() or self.get_load_balancer_managed_outbound_ipv6_count() or self.get_load_balancer_outbound_ips() or self.get_load_balancer_outbound_ip_prefixes() ): raise MutuallyExclusiveArgumentError( outbound_type + " type doesn't support customizing " "the standard load balancer ips" ) if ( self.get_load_balancer_idle_timeout() or self.get_load_balancer_outbound_ports() ): raise MutuallyExclusiveArgumentError( outbound_type + " type doesn't support customizing " "the standard load balancer config" ) if outbound_type != CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY: if ( self.get_nat_gateway_managed_outbound_ip_count() or self.get_nat_gateway_idle_timeout() ): raise MutuallyExclusiveArgumentError( outbound_type + " type doesn't support customizing " "the standard nat gateway ips" ) return outbound_type
Internal function to dynamically obtain the value of outbound_type according to the context. Note: All the external parameters involved in the validation are not verified in their own getters. When outbound_type is not assigned, dynamic completion will be triggerd. By default, the value is set to CONST_OUTBOUND_TYPE_LOAD_BALANCER. This function supports the option of enable_validation. When enabled, if the value of outbound_type is CONST_OUTBOUND_TYPE_LOAD_BALANCER,CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY, CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY or CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING, the following checks will be performed. If load_balancer_sku is set to basic, an InvalidArgumentValueError will be raised. If vnet_subnet_id is not assigned, a RequiredArgumentMissingError will be raised. If any of load_balancer_managed_outbound_ip_count, This function supports the option of read_only. When enabled, it will skip dynamic completion and validation. :return: string or None
_get_outbound_type
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_outbound_type( self, ) -> Union[str, None]: """Dynamically obtain the value of outbound_type according to the context. Note: All the external parameters involved in the validation are not verified in their own getters. When outbound_type is not assigned, dynamic completion will be triggerd. By default, the value is set to CONST_OUTBOUND_TYPE_LOAD_BALANCER. :return: string or None """ return self._get_outbound_type( enable_validation=True )
Dynamically obtain the value of outbound_type according to the context. Note: All the external parameters involved in the validation are not verified in their own getters. When outbound_type is not assigned, dynamic completion will be triggerd. By default, the value is set to CONST_OUTBOUND_TYPE_LOAD_BALANCER. :return: string or None
get_outbound_type
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_network_plugin_mode(self) -> Union[str, None]: """Obtain the value of network_plugin_mode. :return: string or None """ return self._get_network_plugin_mode(enable_validation=True)
Obtain the value of network_plugin_mode. :return: string or None
get_network_plugin_mode
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_network_plugin(self, enable_validation: bool = False) -> Union[str, None]: """Internal function to obtain the value of network_plugin. Note: SDK provides default value "kubenet" for network_plugin. This function supports the option of enable_validation. When enabled, in case network_plugin is assigned, if pod_cidr is assigned and the value of network_plugin is azure, an InvalidArgumentValueError will be raised; otherwise, if any of pod_cidr, service_cidr, dns_service_ip, docker_bridge_address or network_policy is assigned, a RequiredArgumentMissingError will be raised. :return: string or None """ network_plugin = self.raw_param.get("network_plugin") # try to read the property value corresponding to the parameter from the `mc` object # only when we are not in CREATE mode. In Create, if nothing is given from the raw # input, then it should be None as no defaulting should happen in the CLI. if ( not network_plugin and self.decorator_mode != DecoratorMode.CREATE and self.mc and self.mc.network_profile and self.mc.network_profile.network_plugin is not None ): network_plugin = self.mc.network_profile.network_plugin # this parameter does not need dynamic completion # validation if enable_validation: ( pod_cidr, _, _, _, _, ) = self._get_pod_cidr_and_service_cidr_and_dns_service_ip_and_docker_bridge_address_and_network_policy( enable_validation=False ) network_plugin_mode = self._get_network_plugin_mode(enable_validation=False) if network_plugin: if network_plugin == "azure" and pod_cidr and network_plugin_mode != "overlay": raise InvalidArgumentValueError( "Please specify network plugin mode `overlay` when using --pod-cidr or " "use network plugin `kubenet`. For more information about Azure CNI " "Overlay please see https://aka.ms/aks/azure-cni-overlay" ) return network_plugin
Internal function to obtain the value of network_plugin. Note: SDK provides default value "kubenet" for network_plugin. This function supports the option of enable_validation. When enabled, in case network_plugin is assigned, if pod_cidr is assigned and the value of network_plugin is azure, an InvalidArgumentValueError will be raised; otherwise, if any of pod_cidr, service_cidr, dns_service_ip, docker_bridge_address or network_policy is assigned, a RequiredArgumentMissingError will be raised. :return: string or None
_get_network_plugin
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_network_plugin(self) -> Union[str, None]: """Obtain the value of network_plugin. Note: SDK provides default value "kubenet" for network_plugin. This function will verify the parameter by default. In case network_plugin is assigned, if pod_cidr is assigned and the value of network_plugin is azure, an InvalidArgumentValueError will be raised; otherwise, if any of pod_cidr, service_cidr, dns_service_ip, docker_bridge_address or network_policy is assigned, a RequiredArgumentMissingError will be raised. :return: string or None """ return self._get_network_plugin(enable_validation=True)
Obtain the value of network_plugin. Note: SDK provides default value "kubenet" for network_plugin. This function will verify the parameter by default. In case network_plugin is assigned, if pod_cidr is assigned and the value of network_plugin is azure, an InvalidArgumentValueError will be raised; otherwise, if any of pod_cidr, service_cidr, dns_service_ip, docker_bridge_address or network_policy is assigned, a RequiredArgumentMissingError will be raised. :return: string or None
get_network_plugin
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_network_policy(self) -> Union[str, None]: """Get the value of network_dataplane. :return: str or None """ return self.raw_param.get("network_policy")
Get the value of network_dataplane. :return: str or None
get_network_policy
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_network_dataplane(self) -> Union[str, None]: """Get the value of network_dataplane. :return: str or None """ return self.raw_param.get("network_dataplane")
Get the value of network_dataplane. :return: str or None
get_network_dataplane
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_acns_observability(self) -> Union[bool, None]: """Get the enablement of acns observability :return: bool or None""" disable_acns_observability = self.raw_param.get("disable_acns_observability") return not bool(disable_acns_observability) if disable_acns_observability is not None else None
Get the enablement of acns observability :return: bool or None
get_acns_observability
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_acns_security(self) -> Union[bool, None]: """Get the enablement of acns security :return: bool or None""" disable_acns_security = self.raw_param.get("disable_acns_security") return not bool(disable_acns_security) if disable_acns_security is not None else None
Get the enablement of acns security :return: bool or None
get_acns_security
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def get_addon_consts(self) -> Dict[str, str]: """Helper function to obtain the constants used by addons. Note: This is not a parameter of aks commands. :return: dict """ from azure.cli.command_modules.acs._consts import ( ADDONS, CONST_ACC_SGX_QUOTE_HELPER_ENABLED, CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME, CONST_AZURE_POLICY_ADDON_NAME, CONST_CONFCOM_ADDON_NAME, CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME, CONST_INGRESS_APPGW_ADDON_NAME, CONST_INGRESS_APPGW_APPLICATION_GATEWAY_ID, CONST_INGRESS_APPGW_APPLICATION_GATEWAY_NAME, CONST_INGRESS_APPGW_SUBNET_CIDR, CONST_INGRESS_APPGW_SUBNET_ID, CONST_INGRESS_APPGW_WATCH_NAMESPACE, CONST_KUBE_DASHBOARD_ADDON_NAME, CONST_MONITORING_ADDON_NAME, CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID, CONST_MONITORING_USING_AAD_MSI_AUTH, CONST_OPEN_SERVICE_MESH_ADDON_NAME, CONST_ROTATION_POLL_INTERVAL, CONST_SECRET_ROTATION_ENABLED, CONST_VIRTUAL_NODE_ADDON_NAME, CONST_VIRTUAL_NODE_SUBNET_NAME) addon_consts = {} addon_consts["ADDONS"] = ADDONS addon_consts[ "CONST_ACC_SGX_QUOTE_HELPER_ENABLED" ] = CONST_ACC_SGX_QUOTE_HELPER_ENABLED addon_consts[ "CONST_AZURE_POLICY_ADDON_NAME" ] = CONST_AZURE_POLICY_ADDON_NAME addon_consts["CONST_CONFCOM_ADDON_NAME"] = CONST_CONFCOM_ADDON_NAME addon_consts[ "CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME" ] = CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME addon_consts[ "CONST_INGRESS_APPGW_ADDON_NAME" ] = CONST_INGRESS_APPGW_ADDON_NAME addon_consts[ "CONST_INGRESS_APPGW_APPLICATION_GATEWAY_ID" ] = CONST_INGRESS_APPGW_APPLICATION_GATEWAY_ID addon_consts[ "CONST_INGRESS_APPGW_APPLICATION_GATEWAY_NAME" ] = CONST_INGRESS_APPGW_APPLICATION_GATEWAY_NAME addon_consts[ "CONST_INGRESS_APPGW_SUBNET_CIDR" ] = CONST_INGRESS_APPGW_SUBNET_CIDR addon_consts[ "CONST_INGRESS_APPGW_SUBNET_ID" ] = CONST_INGRESS_APPGW_SUBNET_ID addon_consts[ "CONST_INGRESS_APPGW_WATCH_NAMESPACE" ] = CONST_INGRESS_APPGW_WATCH_NAMESPACE addon_consts[ "CONST_KUBE_DASHBOARD_ADDON_NAME" ] = CONST_KUBE_DASHBOARD_ADDON_NAME addon_consts[ "CONST_MONITORING_ADDON_NAME" ] = CONST_MONITORING_ADDON_NAME addon_consts[ "CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID" ] = CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID addon_consts[ "CONST_OPEN_SERVICE_MESH_ADDON_NAME" ] = CONST_OPEN_SERVICE_MESH_ADDON_NAME addon_consts[ "CONST_VIRTUAL_NODE_ADDON_NAME" ] = CONST_VIRTUAL_NODE_ADDON_NAME addon_consts[ "CONST_VIRTUAL_NODE_SUBNET_NAME" ] = CONST_VIRTUAL_NODE_SUBNET_NAME addon_consts[ "CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME" ] = CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME addon_consts[ "CONST_SECRET_ROTATION_ENABLED" ] = CONST_SECRET_ROTATION_ENABLED addon_consts[ "CONST_ROTATION_POLL_INTERVAL" ] = CONST_ROTATION_POLL_INTERVAL addon_consts[ "CONST_MONITORING_USING_AAD_MSI_AUTH" ] = CONST_MONITORING_USING_AAD_MSI_AUTH return addon_consts
Helper function to obtain the constants used by addons. Note: This is not a parameter of aks commands. :return: dict
get_addon_consts
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT
def _get_enable_addons(self, enable_validation: bool = False) -> List[str]: """Internal function to obtain the value of enable_addons. Note: enable_addons will not be directly decorated into the `mc` object and we do not support to fetch it from `mc`. Note: Some of the external parameters involved in the validation are not verified in their own getters. This function supports the option of enable_validation. When enabled, it will check whether the provided addons have duplicate or invalid values, and raise an InvalidArgumentValueError if found. Besides, if monitoring is specified in enable_addons but workspace_resource_id is not assigned, or virtual-node is specified but aci_subnet_name or vnet_subnet_id is not, a RequiredArgumentMissingError will be raised. This function will normalize the parameter by default. It will split the string into a list with "," as the delimiter. :return: empty list or list of strings """ # determine the value of constants addon_consts = self.get_addon_consts() valid_addon_keys = addon_consts.get("ADDONS").keys() # read the original value passed by the command enable_addons = self.raw_param.get("enable_addons") # normalize enable_addons = enable_addons.split(',') if enable_addons else [] # validation if enable_validation: # check duplicate addons duplicate_addons_set = { x for x in enable_addons if enable_addons.count(x) >= 2 } if len(duplicate_addons_set) != 0: raise InvalidArgumentValueError( "Duplicate addon{} '{}' found in option --enable-addons.".format( "s" if len(duplicate_addons_set) > 1 else "", ",".join(duplicate_addons_set), ) ) # check unrecognized addons enable_addons_set = set(enable_addons) invalid_addons_set = enable_addons_set.difference(valid_addon_keys) if len(invalid_addons_set) != 0: raise InvalidArgumentValueError( "'{}' {} not recognized by the --enable-addons argument.".format( ",".join(invalid_addons_set), "are" if len(invalid_addons_set) > 1 else "is", ) ) # check monitoring/workspace_resource_id workspace_resource_id = self._get_workspace_resource_id(read_only=True) if "monitoring" not in enable_addons and workspace_resource_id: raise RequiredArgumentMissingError( '"--workspace-resource-id" requires "--enable-addons monitoring".') # check virtual node/aci_subnet_name/vnet_subnet_id # Note: The external parameters involved in the validation are not verified in their own getters. aci_subnet_name = self.get_aci_subnet_name() vnet_subnet_id = self.get_vnet_subnet_id() if "virtual-node" in enable_addons and not (aci_subnet_name and vnet_subnet_id): raise RequiredArgumentMissingError( '"--enable-addons virtual-node" requires "--aci-subnet-name" and "--vnet-subnet-id".') return enable_addons
Internal function to obtain the value of enable_addons. Note: enable_addons will not be directly decorated into the `mc` object and we do not support to fetch it from `mc`. Note: Some of the external parameters involved in the validation are not verified in their own getters. This function supports the option of enable_validation. When enabled, it will check whether the provided addons have duplicate or invalid values, and raise an InvalidArgumentValueError if found. Besides, if monitoring is specified in enable_addons but workspace_resource_id is not assigned, or virtual-node is specified but aci_subnet_name or vnet_subnet_id is not, a RequiredArgumentMissingError will be raised. This function will normalize the parameter by default. It will split the string into a list with "," as the delimiter. :return: empty list or list of strings
_get_enable_addons
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py
MIT