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 get_enable_addons(self) -> List[str]:
"""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 will verify the parameters by default. 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
"""
return self._get_enable_addons(enable_validation=True) | 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 will verify the parameters by default. 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 |
def _get_workspace_resource_id(
self, enable_validation: bool = False, read_only: bool = False
) -> Union[str, None]:
"""Internal function to dynamically obtain the value of workspace_resource_id according to the context.
When workspace_resource_id is not assigned, dynamic completion will be triggerd. Function
"ensure_default_log_analytics_workspace_for_monitoring" will be called to create a workspace with
subscription_id and resource_group_name, which internally used ResourceManagementClient to send the request.
This function supports the option of enable_validation. When enabled, it will check if workspace_resource_id is
assigned but 'monitoring' is not specified in enable_addons, if so, raise a RequiredArgumentMissingError.
This function supports the option of read_only. When enabled, it will skip dynamic completion and validation.
:return: string or None
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_MONITORING_ADDON_NAME = addon_consts.get("CONST_MONITORING_ADDON_NAME")
CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID = addon_consts.get(
"CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID"
)
# read the original value passed by the command
workspace_resource_id = self.raw_param.get("workspace_resource_id")
# try to read the property value corresponding to the parameter from the `mc` object
read_from_mc = False
if (
self.mc and
self.mc.addon_profiles and
CONST_MONITORING_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_MONITORING_ADDON_NAME
).config.get(CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID) is not None
):
workspace_resource_id = self.mc.addon_profiles.get(
CONST_MONITORING_ADDON_NAME
).config.get(CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID)
read_from_mc = True
# skip dynamic completion & validation if option read_only is specified
if read_only:
return workspace_resource_id
# dynamic completion
if not read_from_mc:
if workspace_resource_id is None:
# use default workspace if exists else create default workspace
workspace_resource_id = (
self.external_functions.ensure_default_log_analytics_workspace_for_monitoring(
self.cmd,
self.get_subscription_id(),
self.get_resource_group_name(),
)
)
# normalize
workspace_resource_id = "/" + workspace_resource_id.strip(" /")
# validation
if enable_validation:
enable_addons = self._get_enable_addons(enable_validation=False)
if workspace_resource_id and "monitoring" not in enable_addons:
raise RequiredArgumentMissingError(
'"--workspace-resource-id" requires "--enable-addons monitoring".')
# this parameter does not need validation
return workspace_resource_id | Internal function to dynamically obtain the value of workspace_resource_id according to the context.
When workspace_resource_id is not assigned, dynamic completion will be triggerd. Function
"ensure_default_log_analytics_workspace_for_monitoring" will be called to create a workspace with
subscription_id and resource_group_name, which internally used ResourceManagementClient to send the request.
This function supports the option of enable_validation. When enabled, it will check if workspace_resource_id is
assigned but 'monitoring' is not specified in enable_addons, if so, raise a RequiredArgumentMissingError.
This function supports the option of read_only. When enabled, it will skip dynamic completion and validation.
:return: string or None | _get_workspace_resource_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_workspace_resource_id(self) -> Union[str, None]:
"""Dynamically obtain the value of workspace_resource_id according to the context.
When workspace_resource_id is not assigned, dynamic completion will be triggerd. Function
"ensure_default_log_analytics_workspace_for_monitoring" will be called to create a workspace with
subscription_id and resource_group_name, which internally used ResourceManagementClient to send the request.
:return: string or None
"""
return self._get_workspace_resource_id(enable_validation=True) | Dynamically obtain the value of workspace_resource_id according to the context.
When workspace_resource_id is not assigned, dynamic completion will be triggerd. Function
"ensure_default_log_analytics_workspace_for_monitoring" will be called to create a workspace with
subscription_id and resource_group_name, which internally used ResourceManagementClient to send the request.
:return: string or None | get_workspace_resource_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_enable_msi_auth_for_monitoring(self) -> Union[bool, None]:
"""Obtain the value of enable_msi_auth_for_monitoring.
Note: The arg type of this parameter supports three states (True, False or None), but the corresponding default
value in entry function is not None.
:return: bool or None
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_MONITORING_ADDON_NAME = addon_consts.get("CONST_MONITORING_ADDON_NAME")
CONST_MONITORING_USING_AAD_MSI_AUTH = addon_consts.get("CONST_MONITORING_USING_AAD_MSI_AUTH")
# read the original value passed by the command
enable_msi_auth_for_monitoring = self.raw_param.get("enable_msi_auth_for_monitoring")
if (
self.mc and
self.mc.service_principal_profile and
self.mc.service_principal_profile.client_id is not None
):
return False
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.addon_profiles and
CONST_MONITORING_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_MONITORING_ADDON_NAME
).config.get(CONST_MONITORING_USING_AAD_MSI_AUTH) is not None
):
enable_msi_auth_for_monitoring = (
safe_lower(
self.mc.addon_profiles.get(CONST_MONITORING_ADDON_NAME).config.get(
CONST_MONITORING_USING_AAD_MSI_AUTH
)
) == "true"
)
# this parameter does not need dynamic completion
# this parameter does not need validation
return enable_msi_auth_for_monitoring | Obtain the value of enable_msi_auth_for_monitoring.
Note: The arg type of this parameter supports three states (True, False or None), but the corresponding default
value in entry function is not None.
:return: bool or None | get_enable_msi_auth_for_monitoring | 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_syslog(self) -> Union[bool, None]:
"""Obtain the value of enable_syslog.
Note: The arg type of this parameter supports three states (True, False or None), but the corresponding default
value in entry function is not None.
:return: bool or None
"""
# read the original value passed by the command
enable_syslog = self.raw_param.get("enable_syslog")
# this parameter does not need dynamic completion
# this parameter does not need validation
return enable_syslog | Obtain the value of enable_syslog.
Note: The arg type of this parameter supports three states (True, False or None), but the corresponding default
value in entry function is not None.
:return: bool or None | get_enable_syslog | 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_high_log_scale_mode(self) -> Union[bool, None]:
"""Obtain the value of enable_high_log_scale_mode.
Note: The arg type of this parameter supports three states (True, False or None), but the corresponding default
value in entry function is not None.
:return: bool or None
"""
# read the original value passed by the command
enable_high_log_scale_mode = self.raw_param.get("enable_high_log_scale_mode")
# this parameter does not need dynamic completion
# this parameter does not need validation
return enable_high_log_scale_mode | Obtain the value of enable_high_log_scale_mode.
Note: The arg type of this parameter supports three states (True, False or None), but the corresponding default
value in entry function is not None.
:return: bool or None | get_enable_high_log_scale_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_data_collection_settings(self) -> Union[str, None]:
"""Obtain the value of data_collection_settings.
:return: string or None
"""
# read the original value passed by the command
data_collection_settings_file_path = self.raw_param.get("data_collection_settings")
# validate user input
if data_collection_settings_file_path:
if not os.path.isfile(data_collection_settings_file_path):
raise InvalidArgumentValueError(
"{} is not valid file, or not accessable.".format(
data_collection_settings_file_path
)
)
return data_collection_settings_file_path | Obtain the value of data_collection_settings.
:return: string or None | get_data_collection_settings | 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_ampls_resource_id(self) -> Union[str, None]:
"""Obtain the value of ampls_resource_id.
:return: string or None
"""
# read the original value passed by the command
ampls_resource_id = self.raw_param.get("ampls_resource_id")
# this parameter does not need dynamic completion
# this parameter does not need validation
return ampls_resource_id | Obtain the value of ampls_resource_id.
:return: string or None | get_ampls_resource_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_virtual_node_addon_os_type(self) -> str:
"""Helper function to obtain the os_type of virtual node addon.
Note: This is not a parameter of aks_create.
:return: string
"""
return "Linux" | Helper function to obtain the os_type of virtual node addon.
Note: This is not a parameter of aks_create.
:return: string | get_virtual_node_addon_os_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_aci_subnet_name(self) -> Union[str, None]:
"""Obtain the value of aci_subnet_name.
:return: string or None
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_VIRTUAL_NODE_ADDON_NAME = addon_consts.get("CONST_VIRTUAL_NODE_ADDON_NAME")
CONST_VIRTUAL_NODE_SUBNET_NAME = addon_consts.get("CONST_VIRTUAL_NODE_SUBNET_NAME")
# read the original value passed by the command
aci_subnet_name = self.raw_param.get("aci_subnet_name")
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.addon_profiles and
CONST_VIRTUAL_NODE_ADDON_NAME +
self.get_virtual_node_addon_os_type()
in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_VIRTUAL_NODE_ADDON_NAME +
self.get_virtual_node_addon_os_type()
).config.get(CONST_VIRTUAL_NODE_SUBNET_NAME) is not None
):
aci_subnet_name = self.mc.addon_profiles.get(
CONST_VIRTUAL_NODE_ADDON_NAME +
self.get_virtual_node_addon_os_type()
).config.get(CONST_VIRTUAL_NODE_SUBNET_NAME)
# this parameter does not need dynamic completion
# this parameter does not need validation
return aci_subnet_name | Obtain the value of aci_subnet_name.
:return: string or None | get_aci_subnet_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_appgw_name(self) -> Union[str, None]:
"""Obtain the value of appgw_name.
:return: string or None
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_INGRESS_APPGW_ADDON_NAME = addon_consts.get("CONST_INGRESS_APPGW_ADDON_NAME")
CONST_INGRESS_APPGW_APPLICATION_GATEWAY_NAME = addon_consts.get(
"CONST_INGRESS_APPGW_APPLICATION_GATEWAY_NAME"
)
# read the original value passed by the command
appgw_name = self.raw_param.get("appgw_name")
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.addon_profiles and
CONST_INGRESS_APPGW_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_APPLICATION_GATEWAY_NAME) is not None
):
appgw_name = self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_APPLICATION_GATEWAY_NAME)
# this parameter does not need dynamic completion
# this parameter does not need validation
return appgw_name | Obtain the value of appgw_name.
:return: string or None | get_appgw_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_appgw_subnet_cidr(self) -> Union[str, None]:
"""Obtain the value of appgw_subnet_cidr.
:return: string or None
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_INGRESS_APPGW_ADDON_NAME = addon_consts.get("CONST_INGRESS_APPGW_ADDON_NAME")
CONST_INGRESS_APPGW_SUBNET_CIDR = addon_consts.get("CONST_INGRESS_APPGW_SUBNET_CIDR")
# read the original value passed by the command
appgw_subnet_cidr = self.raw_param.get("appgw_subnet_cidr")
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.addon_profiles and
CONST_INGRESS_APPGW_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_SUBNET_CIDR) is not None
):
appgw_subnet_cidr = self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_SUBNET_CIDR)
# this parameter does not need dynamic completion
# this parameter does not need validation
return appgw_subnet_cidr | Obtain the value of appgw_subnet_cidr.
:return: string or None | get_appgw_subnet_cidr | 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_appgw_id(self) -> Union[str, None]:
"""Obtain the value of appgw_id.
:return: string or None
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_INGRESS_APPGW_ADDON_NAME = addon_consts.get("CONST_INGRESS_APPGW_ADDON_NAME")
CONST_INGRESS_APPGW_APPLICATION_GATEWAY_ID = addon_consts.get("CONST_INGRESS_APPGW_APPLICATION_GATEWAY_ID")
# read the original value passed by the command
appgw_id = self.raw_param.get("appgw_id")
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.addon_profiles and
CONST_INGRESS_APPGW_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_APPLICATION_GATEWAY_ID) is not None
):
appgw_id = self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_APPLICATION_GATEWAY_ID)
# this parameter does not need dynamic completion
# this parameter does not need validation
return appgw_id | Obtain the value of appgw_id.
:return: string or None | get_appgw_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_appgw_subnet_id(self) -> Union[str, None]:
"""Obtain the value of appgw_subnet_id.
:return: string or None
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_INGRESS_APPGW_ADDON_NAME = addon_consts.get("CONST_INGRESS_APPGW_ADDON_NAME")
CONST_INGRESS_APPGW_SUBNET_ID = addon_consts.get("CONST_INGRESS_APPGW_SUBNET_ID")
# read the original value passed by the command
appgw_subnet_id = self.raw_param.get("appgw_subnet_id")
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.addon_profiles and
CONST_INGRESS_APPGW_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_SUBNET_ID) is not None
):
appgw_subnet_id = self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_SUBNET_ID)
# this parameter does not need dynamic completion
# this parameter does not need validation
return appgw_subnet_id | Obtain the value of appgw_subnet_id.
:return: string or None | get_appgw_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_appgw_watch_namespace(self) -> Union[str, None]:
"""Obtain the value of appgw_watch_namespace.
:return: string or None
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_INGRESS_APPGW_ADDON_NAME = addon_consts.get("CONST_INGRESS_APPGW_ADDON_NAME")
CONST_INGRESS_APPGW_WATCH_NAMESPACE = addon_consts.get("CONST_INGRESS_APPGW_WATCH_NAMESPACE")
# read the original value passed by the command
appgw_watch_namespace = self.raw_param.get("appgw_watch_namespace")
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.addon_profiles and
CONST_INGRESS_APPGW_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_WATCH_NAMESPACE) is not None
):
appgw_watch_namespace = self.mc.addon_profiles.get(
CONST_INGRESS_APPGW_ADDON_NAME
).config.get(CONST_INGRESS_APPGW_WATCH_NAMESPACE)
# this parameter does not need dynamic completion
# this parameter does not need validation
return appgw_watch_namespace | Obtain the value of appgw_watch_namespace.
:return: string or None | get_appgw_watch_namespace | 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_sgxquotehelper(self) -> bool:
"""Obtain the value of enable_sgxquotehelper.
:return: bool
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_CONFCOM_ADDON_NAME = addon_consts.get("CONST_CONFCOM_ADDON_NAME")
CONST_ACC_SGX_QUOTE_HELPER_ENABLED = addon_consts.get("CONST_ACC_SGX_QUOTE_HELPER_ENABLED")
# read the original value passed by the command
enable_sgxquotehelper = self.raw_param.get("enable_sgxquotehelper")
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.addon_profiles and
CONST_CONFCOM_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_CONFCOM_ADDON_NAME
).config.get(CONST_ACC_SGX_QUOTE_HELPER_ENABLED) is not None
):
enable_sgxquotehelper = self.mc.addon_profiles.get(
CONST_CONFCOM_ADDON_NAME
).config.get(CONST_ACC_SGX_QUOTE_HELPER_ENABLED) == "true"
# this parameter does not need dynamic completion
# this parameter does not need validation
return enable_sgxquotehelper | Obtain the value of enable_sgxquotehelper.
:return: bool | get_enable_sgxquotehelper | 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_secret_rotation(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_secret_rotation.
This function supports the option of enable_validation. When enabled, in update mode, if enable_secret_rotation
is specified but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError
will be raised.
:return: bool
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME = addon_consts.get(
"CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME"
)
CONST_SECRET_ROTATION_ENABLED = addon_consts.get(
"CONST_SECRET_ROTATION_ENABLED"
)
# read the original value passed by the command
enable_secret_rotation = self.raw_param.get("enable_secret_rotation")
# 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.addon_profiles and
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME
).config.get(CONST_SECRET_ROTATION_ENABLED) is not None
):
enable_secret_rotation = self.mc.addon_profiles.get(
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME
).config.get(CONST_SECRET_ROTATION_ENABLED) == "true"
# this parameter does not need dynamic completion
# validation
if enable_validation:
if self.decorator_mode == DecoratorMode.UPDATE:
if enable_secret_rotation:
azure_keyvault_secrets_provider_enabled = (
self.mc and
self.mc.addon_profiles and
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME).enabled
)
if not azure_keyvault_secrets_provider_enabled:
raise InvalidArgumentValueError(
"--enable-secret-rotation can only be specified "
"when azure-keyvault-secrets-provider is enabled. "
"Please use command 'az aks enable-addons' to enable it."
)
return enable_secret_rotation | Internal function to obtain the value of enable_secret_rotation.
This function supports the option of enable_validation. When enabled, in update mode, if enable_secret_rotation
is specified but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError
will be raised.
:return: bool | _get_enable_secret_rotation | 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_secret_rotation(self) -> bool:
"""Obtain the value of enable_secret_rotation.
This function will verify the parameter by default. In update mode, if enable_secret_rotation is specified
but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError will be raised.
:return: bool
"""
return self._get_enable_secret_rotation(enable_validation=True) | Obtain the value of enable_secret_rotation.
This function will verify the parameter by default. In update mode, if enable_secret_rotation is specified
but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError will be raised.
:return: bool | get_enable_secret_rotation | 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_secret_rotation(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of disable_secret_rotation.
This function supports the option of enable_validation. When enabled, in update mode, if disable_secret_rotation
is specified but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError
will be raised.
:return: bool
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME = addon_consts.get(
"CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME"
)
# read the original value passed by the command
disable_secret_rotation = self.raw_param.get("disable_secret_rotation")
# 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 self.decorator_mode == DecoratorMode.UPDATE:
if disable_secret_rotation:
azure_keyvault_secrets_provider_enabled = (
self.mc and
self.mc.addon_profiles and
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME).enabled
)
if not azure_keyvault_secrets_provider_enabled:
raise InvalidArgumentValueError(
"--disable-secret-rotation can only be specified "
"when azure-keyvault-secrets-provider is enabled. "
"Please use command 'az aks enable-addons' to enable it."
)
return disable_secret_rotation | Internal function to obtain the value of disable_secret_rotation.
This function supports the option of enable_validation. When enabled, in update mode, if disable_secret_rotation
is specified but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError
will be raised.
:return: bool | _get_disable_secret_rotation | 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_secret_rotation(self) -> bool:
"""Obtain the value of disable_secret_rotation.
This function will verify the parameter by default. In update mode, if disable_secret_rotation is specified
but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError will be raised.
:return: bool
"""
return self._get_disable_secret_rotation(enable_validation=True) | Obtain the value of disable_secret_rotation.
This function will verify the parameter by default. In update mode, if disable_secret_rotation is specified
but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError will be raised.
:return: bool | get_disable_secret_rotation | 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_rotation_poll_interval(self, enable_validation: bool = False) -> Union[str, None]:
"""Internal function to obtain the value of rotation_poll_interval.
This function supports the option of enable_validation. When enabled, in update mode, if rotation_poll_interval
is specified but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError
will be raised.
:return: string or None
"""
# determine the value of constants
addon_consts = self.get_addon_consts()
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME = addon_consts.get(
"CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME"
)
CONST_ROTATION_POLL_INTERVAL = addon_consts.get(
"CONST_ROTATION_POLL_INTERVAL"
)
# read the original value passed by the command
rotation_poll_interval = self.raw_param.get("rotation_poll_interval")
# 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.addon_profiles and
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME
).config.get(CONST_ROTATION_POLL_INTERVAL) is not None
):
rotation_poll_interval = self.mc.addon_profiles.get(
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME
).config.get(CONST_ROTATION_POLL_INTERVAL)
# this parameter does not need dynamic completion
# validation
if enable_validation:
if self.decorator_mode == DecoratorMode.UPDATE:
if rotation_poll_interval:
azure_keyvault_secrets_provider_enabled = (
self.mc and
self.mc.addon_profiles and
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME in self.mc.addon_profiles and
self.mc.addon_profiles.get(CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME).enabled
)
if not azure_keyvault_secrets_provider_enabled:
raise InvalidArgumentValueError(
"--rotation-poll-interval can only be specified "
"when azure-keyvault-secrets-provider is enabled "
"Please use command 'az aks enable-addons' to enable it."
)
return rotation_poll_interval | Internal function to obtain the value of rotation_poll_interval.
This function supports the option of enable_validation. When enabled, in update mode, if rotation_poll_interval
is specified but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError
will be raised.
:return: string or None | _get_rotation_poll_interval | 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_rotation_poll_interval(self) -> Union[str, None]:
"""Obtain the value of rotation_poll_interval.
This function will verify the parameter by default. In update mode, if rotation_poll_interval is specified
but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError will be raised.
:return: string or None
"""
return self._get_rotation_poll_interval(enable_validation=True) | Obtain the value of rotation_poll_interval.
This function will verify the parameter by default. In update mode, if rotation_poll_interval is specified
but azure keyvault secret provider addon is not enabled, an InvalidArgumentValueError will be raised.
:return: string or None | get_rotation_poll_interval | 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_aad(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_aad.
This function supports the option of enable_validation. If the value of enable_aad is False and the value of
enable_azure_rbac is True, a RequiredArgumentMissingError will be raised. In update mode, if enable_aad is
specified and managed aad has been enabled, an InvalidArgumentValueError will be raised.
:return: bool
"""
# read the original value passed by the command
enable_aad = self.raw_param.get("enable_aad")
# 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.aad_profile and
self.mc.aad_profile.managed is not None
):
enable_aad = self.mc.aad_profile.managed
# this parameter does not need dynamic completion
# validation
if enable_validation:
if self.decorator_mode == DecoratorMode.CREATE:
if not enable_aad and self._get_enable_azure_rbac(enable_validation=False):
raise RequiredArgumentMissingError(
"--enable-azure-rbac can only be used together with --enable-aad"
)
elif self.decorator_mode == DecoratorMode.UPDATE:
if enable_aad:
if check_is_managed_aad_cluster(self.mc):
raise InvalidArgumentValueError(
'Cannot specify "--enable-aad" if managed AAD is already enabled'
)
return enable_aad | Internal function to obtain the value of enable_aad.
This function supports the option of enable_validation. If the value of enable_aad is False and the value of
enable_azure_rbac is True, a RequiredArgumentMissingError will be raised. In update mode, if enable_aad is
specified and managed aad has been enabled, an InvalidArgumentValueError will be raised.
:return: bool | _get_enable_aad | 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_aad(self) -> bool:
"""Obtain the value of enable_aad.
This function will verify the parameter by default. If the value of enable_aad is False and the value of
enable_azure_rbac is True, a RequiredArgumentMissingError will be raised. In update mode, if enable_aad is
specified and managed aad has been enabled, an InvalidArgumentValueError will be raised.
:return: bool
"""
return self._get_enable_aad(enable_validation=True) | Obtain the value of enable_aad.
This function will verify the parameter by default. If the value of enable_aad is False and the value of
enable_azure_rbac is True, a RequiredArgumentMissingError will be raised. In update mode, if enable_aad is
specified and managed aad has been enabled, an InvalidArgumentValueError will be raised.
:return: bool | get_enable_aad | 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_aad_tenant_id(
self, enable_validation: bool = False, read_only: bool = False
) -> Union[str, None]:
"""Internal function to obtain the value of aad_tenant_id according to the context.
This function supports the option of enable_validation. When enabled in update mode, if aad_tenant_id
is specified, while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
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
aad_tenant_id = self.raw_param.get("aad_tenant_id")
# 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.aad_profile and
self.mc.aad_profile.tenant_id is not None
):
aad_tenant_id = self.mc.aad_profile.tenant_id
# skip validation if option read_only is specified
if read_only:
return aad_tenant_id
# validation
if enable_validation:
if aad_tenant_id:
if self.decorator_mode == DecoratorMode.UPDATE:
if not check_is_managed_aad_cluster(self.mc):
raise InvalidArgumentValueError(
'Cannot specify "--aad-tenant-id" if managed AAD is not enabled'
)
return aad_tenant_id | Internal function to obtain the value of aad_tenant_id according to the context.
This function supports the option of enable_validation. When enabled in update mode, if aad_tenant_id
is specified, while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
This function supports the option of read_only. When enabled, it will skip dynamic completion and validation.
:return: string or None | _get_aad_tenant_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_aad_tenant_id(self) -> Union[str, None]:
"""Obtain the value of aad_tenant_id according to the context.
This function will verify the parameter by default. In update mode, if aad_tenant_id is specified,
while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
:return: string or None
"""
return self._get_aad_tenant_id(enable_validation=True) | Obtain the value of aad_tenant_id according to the context.
This function will verify the parameter by default. In update mode, if aad_tenant_id is specified,
while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
:return: string or None | get_aad_tenant_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_aad_admin_group_object_ids(self, enable_validation: bool = False) -> Union[List[str], None]:
"""Internal function to obtain the value of aad_admin_group_object_ids.
This function supports the option of enable_validation. When enabled in update mode, if
aad_admin_group_object_ids is specified, while aad_profile is not set or managed aad is not enabled,
raise an InvalidArgumentValueError.
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, or None
"""
# read the original value passed by the command
aad_admin_group_object_ids = self.raw_param.get("aad_admin_group_object_ids")
# In create mode, try to read the property value corresponding to the parameter from the `mc` object.
read_from_mc = False
if self.decorator_mode == DecoratorMode.CREATE:
if (
self.mc and
self.mc.aad_profile and
self.mc.aad_profile.admin_group_object_i_ds is not None
):
aad_admin_group_object_ids = self.mc.aad_profile.admin_group_object_i_ds
read_from_mc = True
# keep None as None, but empty string ("") to empty list ([])
if not read_from_mc and aad_admin_group_object_ids is not None:
aad_admin_group_object_ids = aad_admin_group_object_ids.split(',') if aad_admin_group_object_ids else []
# validation
if enable_validation:
if aad_admin_group_object_ids:
if self.decorator_mode == DecoratorMode.UPDATE:
if not check_is_managed_aad_cluster(self.mc):
raise InvalidArgumentValueError(
'Cannot specify "--aad-admin-group-object-ids" if managed AAD is not enabled'
)
return aad_admin_group_object_ids | Internal function to obtain the value of aad_admin_group_object_ids.
This function supports the option of enable_validation. When enabled in update mode, if
aad_admin_group_object_ids is specified, while aad_profile is not set or managed aad is not enabled,
raise an InvalidArgumentValueError.
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, or None | _get_aad_admin_group_object_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_aad_admin_group_object_ids(self) -> Union[List[str], None]:
"""Obtain the value of aad_admin_group_object_ids.
This function will verify the parameter by default. In update mode, if aad_admin_group_object_ids is specified,
while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
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, or None
"""
return self._get_aad_admin_group_object_ids(enable_validation=True) | Obtain the value of aad_admin_group_object_ids.
This function will verify the parameter by default. In update mode, if aad_admin_group_object_ids is specified,
while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
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, or None | get_aad_admin_group_object_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_disable_rbac(self, enable_validation: bool = False) -> Union[bool, None]:
"""Internal function to obtain the value of disable_rbac.
This function supports the option of enable_validation. When enabled, if the values of disable_rbac and
enable_azure_rbac are both True, a MutuallyExclusiveArgumentError will be raised. Besides, if the values of
enable_rbac and disable_rbac are both True, a MutuallyExclusiveArgumentError will be raised.
:return: bool or None
"""
# read the original value passed by the command
disable_rbac = self.raw_param.get("disable_rbac")
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.enable_rbac is not None
):
disable_rbac = not self.mc.enable_rbac
# this parameter does not need dynamic completion
# validation
if enable_validation:
if disable_rbac and self._get_enable_azure_rbac(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"--enable-azure-rbac cannot be used together with --disable-rbac"
)
if disable_rbac and self._get_enable_rbac(enable_validation=False):
raise MutuallyExclusiveArgumentError("specify either '--disable-rbac' or '--enable-rbac', not both.")
return disable_rbac | Internal function to obtain the value of disable_rbac.
This function supports the option of enable_validation. When enabled, if the values of disable_rbac and
enable_azure_rbac are both True, a MutuallyExclusiveArgumentError will be raised. Besides, if the values of
enable_rbac and disable_rbac are both True, a MutuallyExclusiveArgumentError will be raised.
:return: bool or None | _get_disable_rbac | 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_rbac(self) -> Union[bool, None]:
"""Obtain the value of disable_rbac.
This function will verify the parameter by default. If the values of disable_rbac and enable_azure_rbac are
both True, a MutuallyExclusiveArgumentError will be raised. Besides, if the values of enable_rbac and
disable_rbac are both True, a MutuallyExclusiveArgumentError will be raised.
:return: bool or None
"""
return self._get_disable_rbac(enable_validation=True) | Obtain the value of disable_rbac.
This function will verify the parameter by default. If the values of disable_rbac and enable_azure_rbac are
both True, a MutuallyExclusiveArgumentError will be raised. Besides, if the values of enable_rbac and
disable_rbac are both True, a MutuallyExclusiveArgumentError will be raised.
:return: bool or None | get_disable_rbac | 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_rbac(self, enable_validation: bool = False) -> Union[bool, None]:
"""Internal function to obtain the value of enable_rbac.
This function supports the option of enable_validation. When enabled, if the values of enable_rbac and
disable_rbac are both True, a MutuallyExclusiveArgumentError will be raised.
:return: bool or None
"""
# read the original value passed by the command
enable_rbac = self.raw_param.get("enable_rbac")
# try to read the property value corresponding to the parameter from the `mc` object
if (
self.mc and
self.mc.enable_rbac is not None
):
enable_rbac = self.mc.enable_rbac
# this parameter does not need dynamic completion
# validation
if enable_validation:
if enable_rbac and self._get_disable_rbac(enable_validation=False):
raise MutuallyExclusiveArgumentError("specify either '--disable-rbac' or '--enable-rbac', not both.")
return enable_rbac | Internal function to obtain the value of enable_rbac.
This function supports the option of enable_validation. When enabled, if the values of enable_rbac and
disable_rbac are both True, a MutuallyExclusiveArgumentError will be raised.
:return: bool or None | _get_enable_rbac | 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_rbac(self) -> Union[bool, None]:
"""Obtain the value of enable_rbac.
This function will verify the parameter by default. If the values of enable_rbac and disable_rbac are both True,
a MutuallyExclusiveArgumentError will be raised.
:return: bool or None
"""
return self._get_enable_rbac(enable_validation=True) | Obtain the value of enable_rbac.
This function will verify the parameter by default. If the values of enable_rbac and disable_rbac are both True,
a MutuallyExclusiveArgumentError will be raised.
:return: bool or None | get_enable_rbac | 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_azure_rbac(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_azure_rbac.
This function supports the option of enable_validation. When enabled and enable_azure_rbac is specified,
in create mode, if the value of enable_aad is not True, a RequiredArgumentMissingError will be raised.
If disable_rbac is specified, a MutuallyExclusiveArgumentError will be raised. In update mode, if
enable_azure_rbac is specified, while aad_profile is not set or managed aad is not enabled,
raise an InvalidArgumentValueError. If both disable_azure_rbac and enable_azure_rbac are specified,
raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# read the original value passed by the command
enable_azure_rbac = self.raw_param.get("enable_azure_rbac")
# 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.aad_profile and
self.mc.aad_profile.enable_azure_rbac is not None
):
enable_azure_rbac = self.mc.aad_profile.enable_azure_rbac
# this parameter does not need dynamic completion
# validation
if enable_validation:
if enable_azure_rbac:
if self.decorator_mode == DecoratorMode.CREATE:
if not self._get_enable_aad(enable_validation=False):
raise RequiredArgumentMissingError(
"--enable-azure-rbac can only be used together with --enable-aad"
)
if self._get_disable_rbac(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"--enable-azure-rbac cannot be used together with --disable-rbac"
)
elif self.decorator_mode == DecoratorMode.UPDATE:
if not check_is_managed_aad_cluster(self.mc):
raise InvalidArgumentValueError(
'Cannot specify "--enable-azure-rbac" if managed AAD is not enabled'
)
if self._get_disable_azure_rbac(enable_validation=False):
raise MutuallyExclusiveArgumentError(
'Cannot specify "--enable-azure-rbac" and "--disable-azure-rbac" at the same time'
)
return enable_azure_rbac | Internal function to obtain the value of enable_azure_rbac.
This function supports the option of enable_validation. When enabled and enable_azure_rbac is specified,
in create mode, if the value of enable_aad is not True, a RequiredArgumentMissingError will be raised.
If disable_rbac is specified, a MutuallyExclusiveArgumentError will be raised. In update mode, if
enable_azure_rbac is specified, while aad_profile is not set or managed aad is not enabled,
raise an InvalidArgumentValueError. If both disable_azure_rbac and enable_azure_rbac are specified,
raise a MutuallyExclusiveArgumentError.
:return: bool | _get_enable_azure_rbac | 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_azure_rbac(self) -> bool:
"""Obtain the value of enable_azure_rbac.
This function will verify the parameter by default. If enable_azure_rbac is specified, in create mode,
if the value of enable_aad is not True, a RequiredArgumentMissingError will be raised. If disable_rbac
is specified, a MutuallyExclusiveArgumentError will be raised. In update mode, if enable_azure_rbac
is specified, while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
If both disable_azure_rbac and enable_azure_rbac are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_enable_azure_rbac(enable_validation=True) | Obtain the value of enable_azure_rbac.
This function will verify the parameter by default. If enable_azure_rbac is specified, in create mode,
if the value of enable_aad is not True, a RequiredArgumentMissingError will be raised. If disable_rbac
is specified, a MutuallyExclusiveArgumentError will be raised. In update mode, if enable_azure_rbac
is specified, while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
If both disable_azure_rbac and enable_azure_rbac are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | get_enable_azure_rbac | 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_azure_rbac(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of disable_azure_rbac.
This function supports the option of enable_validation. When enabled, in update mode, if disable_azure_rbac
is specified, while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
If both disable_azure_rbac and enable_azure_rbac are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# read the original value passed by the command
disable_azure_rbac = self.raw_param.get("disable_azure_rbac")
# 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_azure_rbac:
if self.decorator_mode == DecoratorMode.UPDATE:
if not check_is_managed_aad_cluster(self.mc):
raise InvalidArgumentValueError(
'Cannot specify "--disable-azure-rbac" if managed AAD is not enabled'
)
if self._get_enable_azure_rbac(enable_validation=False):
raise MutuallyExclusiveArgumentError(
'Cannot specify "--enable-azure-rbac" and "--disable-azure-rbac" at the same time'
)
return disable_azure_rbac | Internal function to obtain the value of disable_azure_rbac.
This function supports the option of enable_validation. When enabled, in update mode, if disable_azure_rbac
is specified, while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
If both disable_azure_rbac and enable_azure_rbac are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | _get_disable_azure_rbac | 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_azure_rbac(self) -> bool:
"""Obtain the value of disable_azure_rbac.
This function will verify the parameter by default. In update mode, if disable_azure_rbac is specified,
while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
If both disable_azure_rbac and enable_azure_rbac are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_disable_azure_rbac(enable_validation=True) | Obtain the value of disable_azure_rbac.
This function will verify the parameter by default. In update mode, if disable_azure_rbac is specified,
while aad_profile is not set or managed aad is not enabled, raise an InvalidArgumentValueError.
If both disable_azure_rbac and enable_azure_rbac are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | get_disable_azure_rbac | 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_oidc_issuer_profile(self) -> ManagedClusterOIDCIssuerProfile:
"""Obtain the value of oidc_issuer_profile based on the user input.
:return: ManagedClusterOIDCIssuerProfile
"""
enable_flag_value = bool(self.raw_param.get("enable_oidc_issuer"))
if not enable_flag_value:
# enable flag not set, return a None profile, server side will backfill the default/existing value
return None
profile = self.models.ManagedClusterOIDCIssuerProfile()
if self.decorator_mode == DecoratorMode.UPDATE:
if self.mc.oidc_issuer_profile is not None:
profile = self.mc.oidc_issuer_profile
profile.enabled = True
return profile | Obtain the value of oidc_issuer_profile based on the user input.
:return: ManagedClusterOIDCIssuerProfile | get_oidc_issuer_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_api_server_authorized_ip_ranges(self, enable_validation: bool = False) -> List[str]:
"""Internal function to obtain the value of api_server_authorized_ip_ranges.
This function supports the option of enable_validation. When enabled and api_server_authorized_ip_ranges is
assigned, if load_balancer_sku equals to CONST_LOAD_BALANCER_SKU_BASIC, raise an InvalidArgumentValueError;
if enable_private_cluster is specified, raise a MutuallyExclusiveArgumentError.
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
"""
# read the original value passed by the command
api_server_authorized_ip_ranges = self.raw_param.get(
"api_server_authorized_ip_ranges"
)
# In create mode, try to read the property value corresponding to the parameter from the `mc` object.
if self.decorator_mode == DecoratorMode.CREATE:
read_from_mc = False
if (
self.mc and
self.mc.api_server_access_profile and
self.mc.api_server_access_profile.authorized_ip_ranges is not None
):
api_server_authorized_ip_ranges = (
self.mc.api_server_access_profile.authorized_ip_ranges
)
read_from_mc = True
# normalize
if not read_from_mc:
api_server_authorized_ip_ranges = [
x.strip()
for x in (
api_server_authorized_ip_ranges.split(",")
if api_server_authorized_ip_ranges
else []
)
]
elif self.decorator_mode == DecoratorMode.UPDATE:
# normalize, keep None as None
if api_server_authorized_ip_ranges is not None:
api_server_authorized_ip_ranges = [
x.strip()
for x in (
api_server_authorized_ip_ranges.split(",")
if api_server_authorized_ip_ranges
else []
)
]
# validation
if enable_validation:
if self.decorator_mode == DecoratorMode.CREATE:
if api_server_authorized_ip_ranges:
if (
safe_lower(self._get_load_balancer_sku(enable_validation=False)) ==
CONST_LOAD_BALANCER_SKU_BASIC
):
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 MutuallyExclusiveArgumentError(
"--api-server-authorized-ip-ranges is not supported for private cluster"
)
elif self.decorator_mode == DecoratorMode.UPDATE:
if api_server_authorized_ip_ranges:
if check_is_private_cluster(self.mc):
raise MutuallyExclusiveArgumentError(
"--api-server-authorized-ip-ranges is not supported for private cluster"
)
return api_server_authorized_ip_ranges | Internal function to obtain the value of api_server_authorized_ip_ranges.
This function supports the option of enable_validation. When enabled and api_server_authorized_ip_ranges is
assigned, if load_balancer_sku equals to CONST_LOAD_BALANCER_SKU_BASIC, raise an InvalidArgumentValueError;
if enable_private_cluster is specified, raise a MutuallyExclusiveArgumentError.
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_api_server_authorized_ip_ranges | 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_api_server_authorized_ip_ranges(self) -> List[str]:
"""Obtain the value of api_server_authorized_ip_ranges.
This function will verify the parameter by default. When api_server_authorized_ip_ranges is assigned, if
load_balancer_sku equals to CONST_LOAD_BALANCER_SKU_BASIC, raise an InvalidArgumentValueError; if
enable_private_cluster is specified, raise a MutuallyExclusiveArgumentError.
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
"""
return self._get_api_server_authorized_ip_ranges(enable_validation=True) | Obtain the value of api_server_authorized_ip_ranges.
This function will verify the parameter by default. When api_server_authorized_ip_ranges is assigned, if
load_balancer_sku equals to CONST_LOAD_BALANCER_SKU_BASIC, raise an InvalidArgumentValueError; if
enable_private_cluster is specified, raise a MutuallyExclusiveArgumentError.
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_api_server_authorized_ip_ranges | 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_fqdn_subdomain(self, enable_validation: bool = False) -> Union[str, None]:
"""Internal function to obtain the value of fqdn_subdomain.
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. It will also check when both
private_dns_zone and fqdn_subdomain are assigned, if the value of private_dns_zone is
CONST_PRIVATE_DNS_ZONE_SYSTEM, raise an InvalidArgumentValueError; Otherwise if the value of private_dns_zone
is not a valid resource ID, raise an InvalidArgumentValueError.
:return: string or None
"""
# read the original value passed by the command
fqdn_subdomain = self.raw_param.get("fqdn_subdomain")
# try to read the property value corresponding to the parameter from the `mc` object
# Backward Compatibility: We also support api version v2020.11.01 in profile 2020-09-01-hybrid and there is
# no such attribute.
if (
self.mc and
hasattr(self.mc, "fqdn_subdomain") and
self.mc.fqdn_subdomain is not None
):
fqdn_subdomain = self.mc.fqdn_subdomain
# this parameter does not need dynamic completion
# validation
if enable_validation:
if fqdn_subdomain:
if self._get_dns_name_prefix(read_only=True):
raise MutuallyExclusiveArgumentError(
"--dns-name-prefix and --fqdn-subdomain cannot be used at same time"
)
private_dns_zone = self._get_private_dns_zone(enable_validation=False)
if private_dns_zone:
if private_dns_zone.lower() != CONST_PRIVATE_DNS_ZONE_SYSTEM:
if not is_valid_resource_id(private_dns_zone):
raise InvalidArgumentValueError(
private_dns_zone + " is not a valid Azure resource ID."
)
else:
raise InvalidArgumentValueError(
"--fqdn-subdomain should only be used for private cluster with custom private dns zone"
)
return fqdn_subdomain | Internal function to obtain the value of fqdn_subdomain.
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. It will also check when both
private_dns_zone and fqdn_subdomain are assigned, if the value of private_dns_zone is
CONST_PRIVATE_DNS_ZONE_SYSTEM, raise an InvalidArgumentValueError; Otherwise if the value of private_dns_zone
is not a valid resource ID, raise an InvalidArgumentValueError.
:return: string or None | _get_fqdn_subdomain | 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_fqdn_subdomain(self) -> Union[str, None]:
"""Obtain the value of fqdn_subdomain.
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. It will also check when both private_dns_zone
and fqdn_subdomain are assigned, if the value of private_dns_zone is CONST_PRIVATE_DNS_ZONE_SYSTEM, raise an
InvalidArgumentValueError; Otherwise if the value of private_dns_zone is not a valid resource ID, raise an
InvalidArgumentValueError.
:return: string or None
"""
return self._get_fqdn_subdomain(enable_validation=True) | Obtain the value of fqdn_subdomain.
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. It will also check when both private_dns_zone
and fqdn_subdomain are assigned, if the value of private_dns_zone is CONST_PRIVATE_DNS_ZONE_SYSTEM, raise an
InvalidArgumentValueError; Otherwise if the value of private_dns_zone is not a valid resource ID, raise an
InvalidArgumentValueError.
:return: string or None | get_fqdn_subdomain | 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_private_cluster(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_private_cluster.
This function supports the option of enable_validation. When enabled and enable_private_cluster is specified,
if load_balancer_sku equals to basic, raise an InvalidArgumentValueError; if api_server_authorized_ip_ranges
is assigned, raise an MutuallyExclusiveArgumentError; Otherwise when enable_private_cluster is not specified
and disable_public_fqdn, enable_public_fqdn or private_dns_zone is assigned, raise an InvalidArgumentValueError.
:return: bool
"""
# read the original value passed by the command
enable_private_cluster = self.raw_param.get("enable_private_cluster")
# 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.api_server_access_profile and
self.mc.api_server_access_profile.enable_private_cluster is not None
):
enable_private_cluster = self.mc.api_server_access_profile.enable_private_cluster
# this parameter does not need dynamic completion
# validation
if enable_validation:
if self.decorator_mode == DecoratorMode.CREATE:
if enable_private_cluster:
if (
safe_lower(self._get_load_balancer_sku(enable_validation=False)) ==
CONST_LOAD_BALANCER_SKU_BASIC
):
raise InvalidArgumentValueError(
"Please use standard load balancer for private cluster"
)
if self._get_api_server_authorized_ip_ranges(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"--api-server-authorized-ip-ranges is not supported for private cluster"
)
else:
if self._get_disable_public_fqdn(enable_validation=False):
raise InvalidArgumentValueError(
"--disable-public-fqdn should only be used with --enable-private-cluster"
)
if self._get_private_dns_zone(enable_validation=False):
raise InvalidArgumentValueError(
"Invalid private dns zone for public cluster. It should always be empty for public cluster"
)
elif self.decorator_mode == DecoratorMode.UPDATE:
is_private_cluster = check_is_private_cluster(self.mc)
if is_private_cluster:
if self._get_api_server_authorized_ip_ranges(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"--api-server-authorized-ip-ranges is not supported for private cluster"
)
else:
if self._get_disable_public_fqdn(enable_validation=False):
raise InvalidArgumentValueError(
"--disable-public-fqdn can only be used for private cluster"
)
if self._get_enable_public_fqdn(enable_validation=False):
raise InvalidArgumentValueError(
"--enable-public-fqdn can only be used for private cluster"
)
return enable_private_cluster | Internal function to obtain the value of enable_private_cluster.
This function supports the option of enable_validation. When enabled and enable_private_cluster is specified,
if load_balancer_sku equals to basic, raise an InvalidArgumentValueError; if api_server_authorized_ip_ranges
is assigned, raise an MutuallyExclusiveArgumentError; Otherwise when enable_private_cluster is not specified
and disable_public_fqdn, enable_public_fqdn or private_dns_zone is assigned, raise an InvalidArgumentValueError.
:return: bool | _get_enable_private_cluster | 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_private_cluster(self) -> bool:
"""Obtain the value of enable_private_cluster.
This function will verify the parameter by default. When enable_private_cluster is specified, if
load_balancer_sku equals to basic, raise an InvalidArgumentValueError; if api_server_authorized_ip_ranges
is assigned, raise an MutuallyExclusiveArgumentError; Otherwise when enable_private_cluster is not specified
and disable_public_fqdn, enable_public_fqdn or private_dns_zone is assigned, raise an InvalidArgumentValueError.
:return: bool
"""
return self._get_enable_private_cluster(enable_validation=True) | Obtain the value of enable_private_cluster.
This function will verify the parameter by default. When enable_private_cluster is specified, if
load_balancer_sku equals to basic, raise an InvalidArgumentValueError; if api_server_authorized_ip_ranges
is assigned, raise an MutuallyExclusiveArgumentError; Otherwise when enable_private_cluster is not specified
and disable_public_fqdn, enable_public_fqdn or private_dns_zone is assigned, raise an InvalidArgumentValueError.
:return: bool | get_enable_private_cluster | 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_public_fqdn(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of disable_public_fqdn.
This function supports the option of enable_validation. When enabled, if enable_private_cluster is not specified
and disable_public_fqdn is assigned, raise an InvalidArgumentValueError. If both disable_public_fqdn and
enable_public_fqdn are assigned, raise a MutuallyExclusiveArgumentError. In update mode, if
disable_public_fqdn is assigned and private_dns_zone equals to CONST_PRIVATE_DNS_ZONE_NONE, raise an
InvalidArgumentValueError.
:return: bool
"""
# read the original value passed by the command
disable_public_fqdn = self.raw_param.get("disable_public_fqdn")
# 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.api_server_access_profile and
self.mc.api_server_access_profile.enable_private_cluster_public_fqdn is not None
):
disable_public_fqdn = not self.mc.api_server_access_profile.enable_private_cluster_public_fqdn
# this parameter does not need dynamic completion
# validation
if enable_validation:
if self.decorator_mode == DecoratorMode.CREATE:
if disable_public_fqdn and not self._get_enable_private_cluster(enable_validation=False):
raise InvalidArgumentValueError(
"--disable-public-fqdn should only be used with --enable-private-cluster"
)
if self.decorator_mode == DecoratorMode.UPDATE:
if disable_public_fqdn:
if self._get_enable_public_fqdn(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"Cannot specify '--enable-public-fqdn' and '--disable-public-fqdn' at the same time"
)
if safe_lower(self._get_private_dns_zone(enable_validation=False)) == CONST_PRIVATE_DNS_ZONE_NONE:
raise InvalidArgumentValueError(
"--disable-public-fqdn cannot be applied for none mode private dns zone cluster"
)
if not check_is_private_cluster(self.mc):
raise InvalidArgumentValueError(
"--disable-public-fqdn can only be used for private cluster"
)
return disable_public_fqdn | Internal function to obtain the value of disable_public_fqdn.
This function supports the option of enable_validation. When enabled, if enable_private_cluster is not specified
and disable_public_fqdn is assigned, raise an InvalidArgumentValueError. If both disable_public_fqdn and
enable_public_fqdn are assigned, raise a MutuallyExclusiveArgumentError. In update mode, if
disable_public_fqdn is assigned and private_dns_zone equals to CONST_PRIVATE_DNS_ZONE_NONE, raise an
InvalidArgumentValueError.
:return: bool | _get_disable_public_fqdn | 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_public_fqdn(self) -> bool:
"""Obtain the value of disable_public_fqdn.
This function will verify the parameter by default. If enable_private_cluster is not specified and
disable_public_fqdn is assigned, raise an InvalidArgumentValueError. If both disable_public_fqdn and
enable_public_fqdn are assigned, raise a MutuallyExclusiveArgumentError. In update mode, if
disable_public_fqdn is assigned and private_dns_zone equals to CONST_PRIVATE_DNS_ZONE_NONE, raise an
InvalidArgumentValueError.
:return: bool
"""
return self._get_disable_public_fqdn(enable_validation=True) | Obtain the value of disable_public_fqdn.
This function will verify the parameter by default. If enable_private_cluster is not specified and
disable_public_fqdn is assigned, raise an InvalidArgumentValueError. If both disable_public_fqdn and
enable_public_fqdn are assigned, raise a MutuallyExclusiveArgumentError. In update mode, if
disable_public_fqdn is assigned and private_dns_zone equals to CONST_PRIVATE_DNS_ZONE_NONE, raise an
InvalidArgumentValueError.
:return: bool | get_disable_public_fqdn | 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_public_fqdn(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_public_fqdn.
This function supports the option of enable_validation. When enabled, if private cluster is not enabled and
enable_public_fqdn is assigned, raise an InvalidArgumentValueError. If both disable_public_fqdn and
enable_public_fqdn are assigned, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# read the original value passed by the command
enable_public_fqdn = self.raw_param.get("enable_public_fqdn")
# 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 self.decorator_mode == DecoratorMode.UPDATE:
if enable_public_fqdn:
if self._get_disable_public_fqdn(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"Cannot specify '--enable-public-fqdn' and '--disable-public-fqdn' at the same time"
)
if not check_is_private_cluster(self.mc):
raise InvalidArgumentValueError(
"--enable-public-fqdn can only be used for private cluster"
)
return enable_public_fqdn | Internal function to obtain the value of enable_public_fqdn.
This function supports the option of enable_validation. When enabled, if private cluster is not enabled and
enable_public_fqdn is assigned, raise an InvalidArgumentValueError. If both disable_public_fqdn and
enable_public_fqdn are assigned, raise a MutuallyExclusiveArgumentError.
:return: bool | _get_enable_public_fqdn | 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_public_fqdn(self) -> bool:
"""Obtain the value of enable_public_fqdn.
This function will verify the parameter by default. If private cluster is not enabled and enable_public_fqdn
is assigned, raise an InvalidArgumentValueError. If both disable_public_fqdn and enable_private_cluster are
assigned, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_enable_public_fqdn(enable_validation=True) | Obtain the value of enable_public_fqdn.
This function will verify the parameter by default. If private cluster is not enabled and enable_public_fqdn
is assigned, raise an InvalidArgumentValueError. If both disable_public_fqdn and enable_private_cluster are
assigned, raise a MutuallyExclusiveArgumentError.
:return: bool | get_enable_public_fqdn | 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_private_dns_zone(self, enable_validation: bool = False) -> Union[str, None]:
"""Internal function to obtain the value of private_dns_zone.
This function supports the option of enable_validation. When enabled and private_dns_zone is assigned, if
enable_private_cluster is not specified raise an InvalidArgumentValueError. It will also check when both
private_dns_zone and fqdn_subdomain are assigned, if the value of private_dns_zone is
CONST_PRIVATE_DNS_ZONE_SYSTEM or CONST_PRIVATE_DNS_ZONE_NONE, raise an InvalidArgumentValueError; Otherwise if
the value of private_dns_zone is not a valid resource ID, raise an InvalidArgumentValueError. In update mode,
if disable_public_fqdn is assigned and private_dns_zone equals to CONST_PRIVATE_DNS_ZONE_NONE, raise an
InvalidArgumentValueError.
:return: string or None
"""
# read the original value passed by the command
private_dns_zone = self.raw_param.get("private_dns_zone")
# 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.api_server_access_profile and
self.mc.api_server_access_profile.private_dns_zone is not None
):
private_dns_zone = self.mc.api_server_access_profile.private_dns_zone
# this parameter does not need dynamic completion
# validation
if enable_validation:
if self.decorator_mode == DecoratorMode.CREATE:
if private_dns_zone:
if not self._get_enable_private_cluster(enable_validation=False):
raise InvalidArgumentValueError(
"Invalid private dns zone for public cluster. It should always be empty for public cluster"
)
if (
private_dns_zone.lower() != CONST_PRIVATE_DNS_ZONE_SYSTEM and
private_dns_zone.lower() != CONST_PRIVATE_DNS_ZONE_NONE
):
if not is_valid_resource_id(private_dns_zone):
raise InvalidArgumentValueError(
private_dns_zone + " is not a valid Azure resource ID."
)
else:
if self._get_fqdn_subdomain(enable_validation=False):
raise InvalidArgumentValueError(
"--fqdn-subdomain should only be used for private cluster with custom private dns zone"
)
elif self.decorator_mode == DecoratorMode.UPDATE:
if (
self.mc and
self.mc.api_server_access_profile and
self.mc.api_server_access_profile.private_dns_zone == CONST_PRIVATE_DNS_ZONE_NONE
):
if self._get_disable_public_fqdn(enable_validation=False):
raise InvalidArgumentValueError(
"--disable-public-fqdn cannot be applied for none mode private dns zone cluster"
)
return private_dns_zone | Internal function to obtain the value of private_dns_zone.
This function supports the option of enable_validation. When enabled and private_dns_zone is assigned, if
enable_private_cluster is not specified raise an InvalidArgumentValueError. It will also check when both
private_dns_zone and fqdn_subdomain are assigned, if the value of private_dns_zone is
CONST_PRIVATE_DNS_ZONE_SYSTEM or CONST_PRIVATE_DNS_ZONE_NONE, raise an InvalidArgumentValueError; Otherwise if
the value of private_dns_zone is not a valid resource ID, raise an InvalidArgumentValueError. In update mode,
if disable_public_fqdn is assigned and private_dns_zone equals to CONST_PRIVATE_DNS_ZONE_NONE, raise an
InvalidArgumentValueError.
:return: string or None | _get_private_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_private_dns_zone(self) -> Union[str, None]:
"""Obtain the value of private_dns_zone.
This function will verify the parameter by default. When private_dns_zone is assigned, if enable_private_cluster
is not specified raise an InvalidArgumentValueError. It will also check when both private_dns_zone and
fqdn_subdomain are assigned, if the value of private_dns_zone is CONST_PRIVATE_DNS_ZONE_SYSTEM or
CONST_PRIVATE_DNS_ZONE_NONE, raise an InvalidArgumentValueError; Otherwise if the value of private_dns_zone is
not a valid resource ID, raise an InvalidArgumentValueError. In update mode, if disable_public_fqdn is assigned
and private_dns_zone equals to CONST_PRIVATE_DNS_ZONE_NONE, raise an InvalidArgumentValueError.
:return: string or None
"""
return self._get_private_dns_zone(enable_validation=True) | Obtain the value of private_dns_zone.
This function will verify the parameter by default. When private_dns_zone is assigned, if enable_private_cluster
is not specified raise an InvalidArgumentValueError. It will also check when both private_dns_zone and
fqdn_subdomain are assigned, if the value of private_dns_zone is CONST_PRIVATE_DNS_ZONE_SYSTEM or
CONST_PRIVATE_DNS_ZONE_NONE, raise an InvalidArgumentValueError; Otherwise if the value of private_dns_zone is
not a valid resource ID, raise an InvalidArgumentValueError. In update mode, if disable_public_fqdn is assigned
and private_dns_zone equals to CONST_PRIVATE_DNS_ZONE_NONE, raise an InvalidArgumentValueError.
:return: string or None | get_private_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_user_assignd_identity_from_mc(self) -> Union[str, None]:
"""Helper function to obtain the (first) user assignd identity from ManagedCluster.
:return: string or None
"""
user_assigned_identity = None
if self.mc and self.mc.identity and self.mc.identity.user_assigned_identities:
user_assigned_identity = safe_list_get(list(self.mc.identity.user_assigned_identities.keys()), 0, None)
return user_assigned_identity | Helper function to obtain the (first) user assignd identity from ManagedCluster.
:return: string or None | get_user_assignd_identity_from_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 _get_assign_kubelet_identity(self, enable_validation: bool = False) -> Union[str, None]:
"""Internal function to obtain the value of assign_kubelet_identity.
This function supports the option of enable_validation. When enabled, 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_kubelet_identity = self.raw_param.get("assign_kubelet_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_profile and
self.mc.identity_profile.get("kubeletidentity", None) and
getattr(self.mc.identity_profile.get("kubeletidentity"), "resource_id") is not None
):
assign_kubelet_identity = getattr(self.mc.identity_profile.get("kubeletidentity"), "resource_id")
# this parameter does not need dynamic completion
# validation
if enable_validation:
if assign_kubelet_identity:
if self.decorator_mode == DecoratorMode.CREATE and not self._get_assign_identity(
enable_validation=False
):
raise RequiredArgumentMissingError(
"--assign-kubelet-identity can only be specified when --assign-identity is specified"
)
if self.decorator_mode == DecoratorMode.UPDATE:
msg = (
"You're going to update kubelet identity to {}, "
"which will upgrade every node pool in the cluster "
"and might take a while, do you wish to continue?".format(assign_kubelet_identity)
)
if not self.get_yes() and not prompt_y_n(msg, default="n"):
raise DecoratorEarlyExitException
if not self.get_assign_identity() and not self.get_user_assignd_identity_from_mc():
raise RequiredArgumentMissingError(
"--assign-identity is not provided and the cluster identity type "
"is not user assigned, cannot update kubelet identity"
)
return assign_kubelet_identity | Internal function to obtain the value of assign_kubelet_identity.
This function supports the option of enable_validation. When enabled, if assign_identity is not assigned but
assign_kubelet_identity is, a RequiredArgumentMissingError will be raised.
:return: string or None | _get_assign_kubelet_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_kubelet_identity(self) -> Union[str, None]:
"""Obtain the value of assign_kubelet_identity.
This function will verify the parameter by default. If assign_identity is not assigned but
assign_kubelet_identity is, a RequiredArgumentMissingError will be raised.
:return: string or None
"""
return self._get_assign_kubelet_identity(enable_validation=True) | Obtain the value of assign_kubelet_identity.
This function will verify the parameter by default. If assign_identity is not assigned but
assign_kubelet_identity is, a RequiredArgumentMissingError will be raised.
:return: string or None | get_assign_kubelet_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_auto_upgrade_channel(self) -> Union[str, None]:
"""Obtain the value of auto_upgrade_channel.
:return: string or None
"""
# read the original value passed by the command
auto_upgrade_channel = self.raw_param.get("auto_upgrade_channel")
# 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.auto_upgrade_profile and
self.mc.auto_upgrade_profile.upgrade_channel is not None
):
auto_upgrade_channel = self.mc.auto_upgrade_profile.upgrade_channel
# this parameter does not need dynamic completion
# this parameter does not need validation
return auto_upgrade_channel | Obtain the value of auto_upgrade_channel.
:return: string or None | get_auto_upgrade_channel | 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_os_upgrade_channel(self) -> Union[str, None]:
"""Obtain the value of node_os_upgrade_channel.
:return: string or None
"""
# read the original value passed by the command
node_os_upgrade_channel = self.raw_param.get("node_os_upgrade_channel")
# 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.auto_upgrade_profile and
self.mc.auto_upgrade_profile.node_os_upgrade_channel is not None
):
node_os_upgrade_channel = self.mc.auto_upgrade_profile.node_os_upgrade_channel
# this parameter does not need dynamic completion
# this parameter does not need validation
return node_os_upgrade_channel | Obtain the value of node_os_upgrade_channel.
:return: string or None | get_node_os_upgrade_channel | 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_cluster_autoscaler_profile(self, read_only: bool = False) -> Union[Dict[str, str], None]:
"""Internal function to dynamically obtain the value of cluster_autoscaler_profile according to the context.
This function will call function "__validate_cluster_autoscaler_profile" to parse and verify the parameter
by default.
In update mode, when cluster_autoscaler_profile is assigned and auto_scaler_profile in the `mc` object has also
been set, dynamic completion will be triggerd. We will first make a copy of the original configuration
(extract the dictionary from the ManagedClusterPropertiesAutoScalerProfile object), and then update the copied
dictionary with the dictionary of new options.
:return: dictionary or None
"""
# read the original value passed by the command
cluster_autoscaler_profile = self.raw_param.get("cluster_autoscaler_profile")
# parse and validate user input
cluster_autoscaler_profile = self.__validate_cluster_autoscaler_profile(cluster_autoscaler_profile)
# 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.auto_scaler_profile is not None:
cluster_autoscaler_profile = self.mc.auto_scaler_profile
# skip dynamic completion & validation if option read_only is specified
if read_only:
return cluster_autoscaler_profile
# dynamic completion for update mode only
if not read_only and self.decorator_mode == DecoratorMode.UPDATE:
if cluster_autoscaler_profile and self.mc and self.mc.auto_scaler_profile:
# shallow copy should be enough for string-to-string dictionary
copy_of_raw_dict = self.mc.auto_scaler_profile.__dict__.copy()
new_options_dict = {
key.replace("-", "_"): value
for key, value in cluster_autoscaler_profile.items()
}
copy_of_raw_dict.update(new_options_dict)
cluster_autoscaler_profile = copy_of_raw_dict
# this parameter does not need validation
return cluster_autoscaler_profile | Internal function to dynamically obtain the value of cluster_autoscaler_profile according to the context.
This function will call function "__validate_cluster_autoscaler_profile" to parse and verify the parameter
by default.
In update mode, when cluster_autoscaler_profile is assigned and auto_scaler_profile in the `mc` object has also
been set, dynamic completion will be triggerd. We will first make a copy of the original configuration
(extract the dictionary from the ManagedClusterPropertiesAutoScalerProfile object), and then update the copied
dictionary with the dictionary of new options.
:return: dictionary or None | _get_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 get_cluster_autoscaler_profile(self) -> Union[Dict[str, str], None]:
"""Dynamically obtain the value of cluster_autoscaler_profile according to the context.
This function will call function "__validate_cluster_autoscaler_profile" to parse and verify the parameter
by default.
In update mode, when cluster_autoscaler_profile is assigned and auto_scaler_profile in the `mc` object has also
been set, dynamic completion will be triggerd. We will first make a copy of the original configuration
(extract the dictionary from the ManagedClusterPropertiesAutoScalerProfile object), and then update the copied
dictionary with the dictionary of new options.
:return: dictionary or None
"""
return self._get_cluster_autoscaler_profile() | Dynamically obtain the value of cluster_autoscaler_profile according to the context.
This function will call function "__validate_cluster_autoscaler_profile" to parse and verify the parameter
by default.
In update mode, when cluster_autoscaler_profile is assigned and auto_scaler_profile in the `mc` object has also
been set, dynamic completion will be triggerd. We will first make a copy of the original configuration
(extract the dictionary from the ManagedClusterPropertiesAutoScalerProfile object), and then update the copied
dictionary with the dictionary of new options.
:return: dictionary or None | get_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 get_initial_service_mesh_profile(self) -> ServiceMeshProfile:
""" Obtain the initial service mesh profile from parameters.
This function is used only when setting up a new AKS cluster.
:return: initial service mesh profile
"""
# returns a service mesh profile only if '--enable-azure-service-mesh' is applied
enable_asm = self.raw_param.get("enable_azure_service_mesh", False)
revision = self.raw_param.get("revision", None)
revisions = None
if revision is not None:
revisions = [revision]
if enable_asm:
return self.models.ServiceMeshProfile(
mode=CONST_AZURE_SERVICE_MESH_MODE_ISTIO,
istio=self.models.IstioServiceMesh(
revisions=revisions
), # pylint: disable=no-member
)
return None | Obtain the initial service mesh profile from parameters.
This function is used only when setting up a new AKS cluster.
:return: initial service mesh profile | get_initial_service_mesh_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 update_azure_service_mesh_profile(self) -> ServiceMeshProfile:
""" Update azure service mesh profile.
This function clone the existing service mesh profile, then apply user supplied changes
like enable or disable mesh, enable or disable internal or external ingress gateway
then return the updated service mesh profile.
It does not overwrite the service mesh profile attribute of the managed cluster.
:return: updated service mesh profile
"""
updated = False
new_profile = (
self.models.ServiceMeshProfile(mode=CONST_AZURE_SERVICE_MESH_MODE_DISABLED) # pylint: disable=no-member
if self.mc.service_mesh_profile is None
else copy.deepcopy(self.mc.service_mesh_profile)
)
new_profile, updated_enable_disable_asm = self._handle_enable_disable_asm(new_profile)
updated |= updated_enable_disable_asm
new_profile, updated_ingress_gateways_asm = self._handle_ingress_gateways_asm(new_profile)
updated |= updated_ingress_gateways_asm
new_profile, updated_pluginca_asm = self._handle_pluginca_asm(new_profile)
updated |= updated_pluginca_asm
new_profile, updated_upgrade_asm = self._handle_upgrade_asm(new_profile)
updated |= updated_upgrade_asm
if updated:
return new_profile
return self.mc.service_mesh_profile | Update azure service mesh profile.
This function clone the existing service mesh profile, then apply user supplied changes
like enable or disable mesh, enable or disable internal or external ingress gateway
then return the updated service mesh profile.
It does not overwrite the service mesh profile attribute of the managed cluster.
:return: updated service mesh profile | update_azure_service_mesh_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_tier(self) -> str:
"""Obtain the value of tier.
:return: str
"""
tier = self.raw_param.get("tier")
if not tier:
return ""
return tier.lower() | Obtain the value of tier.
:return: str | get_tier | 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_defender_config(self) -> Union[ManagedClusterSecurityProfileDefender, None]:
"""Obtain the value of defender.
:return: ManagedClusterSecurityProfileDefender or None
"""
disable_defender = self.raw_param.get("disable_defender")
if disable_defender:
return self.models.ManagedClusterSecurityProfileDefender(
security_monitoring=self.models.ManagedClusterSecurityProfileDefenderSecurityMonitoring(
enabled=False
)
)
enable_defender = self.raw_param.get("enable_defender")
if not enable_defender:
return None
workspace = ""
config_file_path = self.raw_param.get("defender_config")
if config_file_path:
if not os.path.isfile(config_file_path):
raise InvalidArgumentValueError(
"{} is not valid file, or not accessable.".format(
config_file_path
)
)
defender_config = get_file_json(config_file_path)
if "logAnalyticsWorkspaceResourceId" in defender_config:
workspace = defender_config["logAnalyticsWorkspaceResourceId"]
if workspace == "":
workspace = self.external_functions.ensure_default_log_analytics_workspace_for_monitoring(
self.cmd,
self.get_subscription_id(),
self.get_resource_group_name())
azure_defender = self.models.ManagedClusterSecurityProfileDefender(
log_analytics_workspace_resource_id=workspace,
security_monitoring=self.models.ManagedClusterSecurityProfileDefenderSecurityMonitoring(
enabled=enable_defender
),
)
return azure_defender | Obtain the value of defender.
:return: ManagedClusterSecurityProfileDefender or None | get_defender_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_workload_identity_profile(self) -> Optional[ManagedClusterSecurityProfileWorkloadIdentity]:
"""Obtrain the value of security_profile.workload_identity.
:return: Optional[ManagedClusterSecurityProfileWorkloadIdentity]
"""
enable_workload_identity = self.raw_param.get("enable_workload_identity")
disable_workload_identity = self.raw_param.get("disable_workload_identity")
if not enable_workload_identity and not disable_workload_identity:
return None
if enable_workload_identity and disable_workload_identity:
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-workload-identity and "
"--disable-workload-identity at the same time."
)
if not hasattr(self.models, "ManagedClusterSecurityProfileWorkloadIdentity"):
return None
profile = self.models.ManagedClusterSecurityProfileWorkloadIdentity()
if self.decorator_mode == DecoratorMode.CREATE:
profile.enabled = bool(enable_workload_identity)
elif self.decorator_mode == DecoratorMode.UPDATE:
if (
hasattr(self.mc, "security_profile") and
self.mc.security_profile is not None and
self.mc.security_profile.workload_identity is not None
):
# reuse previous profile is has been set
profile = self.mc.security_profile.workload_identity
if enable_workload_identity:
profile.enabled = True
elif disable_workload_identity:
profile.enabled = False
if profile.enabled:
# in enable case, we need to check if OIDC issuer has been enabled
oidc_issuer_profile = self.get_oidc_issuer_profile()
if self.decorator_mode == DecoratorMode.UPDATE and oidc_issuer_profile is None:
# if the cluster has enabled OIDC issuer before, in update call:
#
# az aks update --enable-workload-identity
#
# we need to use previous OIDC issuer profile
oidc_issuer_profile = self.mc.oidc_issuer_profile
oidc_issuer_enabled = oidc_issuer_profile is not None and oidc_issuer_profile.enabled
if not oidc_issuer_enabled:
raise RequiredArgumentMissingError(
"Enabling workload identity requires enabling OIDC issuer (--enable-oidc-issuer)."
)
return profile | Obtrain the value of security_profile.workload_identity.
:return: Optional[ManagedClusterSecurityProfileWorkloadIdentity] | get_workload_identity_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_enable_azure_keyvault_kms(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_azure_keyvault_kms.
This function supports the option of enable_validation. When enabled, if azure_keyvault_kms_key_id is empty,
raise a RequiredArgumentMissingError.
:return: bool
"""
# read the original value passed by the command
enable_azure_keyvault_kms = self.raw_param.get("enable_azure_keyvault_kms")
# 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, "security_profile") and # backward compatibility
self.mc.security_profile and
self.mc.security_profile.azure_key_vault_kms
):
enable_azure_keyvault_kms = self.mc.security_profile.azure_key_vault_kms.enabled
# this parameter does not need dynamic completion
# validation
if enable_validation:
if bool(enable_azure_keyvault_kms) != bool(self._get_azure_keyvault_kms_key_id(enable_validation=False)):
raise RequiredArgumentMissingError(
'You must set "--enable-azure-keyvault-kms" and "--azure-keyvault-kms-key-id" at the same time.'
)
return enable_azure_keyvault_kms | Internal function to obtain the value of enable_azure_keyvault_kms.
This function supports the option of enable_validation. When enabled, if azure_keyvault_kms_key_id is empty,
raise a RequiredArgumentMissingError.
:return: bool | _get_enable_azure_keyvault_kms | 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_azure_keyvault_kms(self) -> bool:
"""Obtain the value of enable_azure_keyvault_kms.
This function will verify the parameter by default. When enabled, if azure_keyvault_kms_key_id is empty,
raise a RequiredArgumentMissingError.
:return: bool
"""
return self._get_enable_azure_keyvault_kms(enable_validation=True) | Obtain the value of enable_azure_keyvault_kms.
This function will verify the parameter by default. When enabled, if azure_keyvault_kms_key_id is empty,
raise a RequiredArgumentMissingError.
:return: bool | get_enable_azure_keyvault_kms | 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_azure_keyvault_kms(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of disable_azure_keyvault_kms.
This function supports the option of enable_validation. When enabled,
if both enable_azure_keyvault_kms and disable_azure_keyvault_kms are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# Read the original value passed by the command.
disable_azure_keyvault_kms = self.raw_param.get("disable_azure_keyvault_kms")
# 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_azure_keyvault_kms and self._get_enable_azure_keyvault_kms(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-azure-keyvault-kms and --disable-azure-keyvault-kms at the same time."
)
return disable_azure_keyvault_kms | Internal function to obtain the value of disable_azure_keyvault_kms.
This function supports the option of enable_validation. When enabled,
if both enable_azure_keyvault_kms and disable_azure_keyvault_kms are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool | _get_disable_azure_keyvault_kms | 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_azure_keyvault_kms(self) -> bool:
"""Obtain the value of disable_azure_keyvault_kms.
This function will verify the parameter by default. If both enable_azure_keyvault_kms and
disable_azure_keyvault_kms are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_disable_azure_keyvault_kms(enable_validation=True) | Obtain the value of disable_azure_keyvault_kms.
This function will verify the parameter by default. If both enable_azure_keyvault_kms and
disable_azure_keyvault_kms are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | get_disable_azure_keyvault_kms | 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_azure_keyvault_kms_key_id(self, enable_validation: bool = False) -> Union[str, None]:
"""Internal function to obtain the value of azure_keyvault_kms_key_id according to the context.
This function supports the option of enable_validation. When enabled, it will check if
azure_keyvault_kms_key_id is assigned but enable_azure_keyvault_kms is not specified,
if so, raise a RequiredArgumentMissingError.
:return: string or None
"""
# read the original value passed by the command
azure_keyvault_kms_key_id = self.raw_param.get("azure_keyvault_kms_key_id")
# 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, "security_profile") and # backward compatibility
self.mc.security_profile and
self.mc.security_profile.azure_key_vault_kms and
self.mc.security_profile.azure_key_vault_kms.key_id is not None
):
azure_keyvault_kms_key_id = self.mc.security_profile.azure_key_vault_kms.key_id
if enable_validation:
enable_azure_keyvault_kms = self._get_enable_azure_keyvault_kms(
enable_validation=False)
if (
azure_keyvault_kms_key_id and
(
enable_azure_keyvault_kms is None or
enable_azure_keyvault_kms is False
)
):
raise RequiredArgumentMissingError(
'"--azure-keyvault-kms-key-id" requires "--enable-azure-keyvault-kms".')
return azure_keyvault_kms_key_id | Internal function to obtain the value of azure_keyvault_kms_key_id according to the context.
This function supports the option of enable_validation. When enabled, it will check if
azure_keyvault_kms_key_id is assigned but enable_azure_keyvault_kms is not specified,
if so, raise a RequiredArgumentMissingError.
:return: string or None | _get_azure_keyvault_kms_key_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_azure_keyvault_kms_key_id(self) -> Union[str, None]:
"""Obtain the value of azure_keyvault_kms_key_id.
This function will verify the parameter by default. When enabled, if enable_azure_keyvault_kms is False,
raise a RequiredArgumentMissingError.
:return: bool
"""
return self._get_azure_keyvault_kms_key_id(enable_validation=True) | Obtain the value of azure_keyvault_kms_key_id.
This function will verify the parameter by default. When enabled, if enable_azure_keyvault_kms is False,
raise a RequiredArgumentMissingError.
:return: bool | get_azure_keyvault_kms_key_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_azure_keyvault_kms_key_vault_network_access(self, enable_validation: bool = False) -> Union[str, None]:
"""Internal function to obtain the value of azure_keyvault_kms_key_vault_network_access according to the
context.
This function supports the option of enable_validation. When enabled, it will check if
azure_keyvault_kms_key_vault_network_access is assigned but enable_azure_keyvault_kms is not specified, if so,
raise a RequiredArgumentMissingError.
:return: string or None
"""
# read the original value passed by the command
azure_keyvault_kms_key_vault_network_access = self.raw_param.get(
"azure_keyvault_kms_key_vault_network_access"
)
# validation
if enable_validation:
enable_azure_keyvault_kms = self._get_enable_azure_keyvault_kms(
enable_validation=False)
if azure_keyvault_kms_key_vault_network_access is None:
raise RequiredArgumentMissingError(
'"--azure-keyvault-kms-key-vault-network-access" is required.')
if (
azure_keyvault_kms_key_vault_network_access and
(
enable_azure_keyvault_kms is None or
enable_azure_keyvault_kms is False
)
):
raise RequiredArgumentMissingError(
'"--azure-keyvault-kms-key-vault-network-access" requires "--enable-azure-keyvault-kms".')
if azure_keyvault_kms_key_vault_network_access == CONST_AZURE_KEYVAULT_NETWORK_ACCESS_PRIVATE:
key_vault_resource_id = self._get_azure_keyvault_kms_key_vault_resource_id(
enable_validation=False)
if (
key_vault_resource_id is None or
key_vault_resource_id == ""
):
raise RequiredArgumentMissingError(
'"--azure-keyvault-kms-key-vault-resource-id" is required '
'when "--azure-keyvault-kms-key-vault-network-access" is Private.'
)
return azure_keyvault_kms_key_vault_network_access | Internal function to obtain the value of azure_keyvault_kms_key_vault_network_access according to the
context.
This function supports the option of enable_validation. When enabled, it will check if
azure_keyvault_kms_key_vault_network_access is assigned but enable_azure_keyvault_kms is not specified, if so,
raise a RequiredArgumentMissingError.
:return: string or None | _get_azure_keyvault_kms_key_vault_network_access | 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_azure_keyvault_kms_key_vault_network_access(self) -> Union[str, None]:
"""Obtain the value of azure_keyvault_kms_key_vault_network_access.
This function will verify the parameter by default. When enabled, if enable_azure_keyvault_kms is False,
raise a RequiredArgumentMissingError.
:return: bool
"""
return self._get_azure_keyvault_kms_key_vault_network_access(enable_validation=True) | Obtain the value of azure_keyvault_kms_key_vault_network_access.
This function will verify the parameter by default. When enabled, if enable_azure_keyvault_kms is False,
raise a RequiredArgumentMissingError.
:return: bool | get_azure_keyvault_kms_key_vault_network_access | 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_azure_keyvault_kms_key_vault_resource_id(self, enable_validation: bool = False) -> Union[str, None]:
"""Internal function to obtain the value of azure_keyvault_kms_key_vault_resource_id according to the context.
This function supports the option of enable_validation. When enabled, it will do validation, and raise a
RequiredArgumentMissingError.
:return: string or None
"""
# read the original value passed by the command
azure_keyvault_kms_key_vault_resource_id = self.raw_param.get(
"azure_keyvault_kms_key_vault_resource_id"
)
if self.decorator_mode == DecoratorMode.CREATE:
if (
self.mc and
hasattr(self.mc, "security_profile") and # backward compatibility
self.mc.security_profile and
self.mc.security_profile.azure_key_vault_kms and
self.mc.security_profile.azure_key_vault_kms.key_vault_resource_id is not None
):
azure_keyvault_kms_key_vault_resource_id = (
self.mc.security_profile.azure_key_vault_kms.key_vault_resource_id
)
# validation
if enable_validation:
enable_azure_keyvault_kms = self._get_enable_azure_keyvault_kms(
enable_validation=False)
if (
azure_keyvault_kms_key_vault_resource_id and
(
enable_azure_keyvault_kms is None or
enable_azure_keyvault_kms is False
)
):
raise RequiredArgumentMissingError(
'"--azure-keyvault-kms-key-vault-resource-id" requires "--enable-azure-keyvault-kms".'
)
key_vault_network_access = self._get_azure_keyvault_kms_key_vault_network_access(
enable_validation=False)
if (
key_vault_network_access == CONST_AZURE_KEYVAULT_NETWORK_ACCESS_PRIVATE and
(
azure_keyvault_kms_key_vault_resource_id is None or
azure_keyvault_kms_key_vault_resource_id == ""
)
):
raise ArgumentUsageError(
'"--azure-keyvault-kms-key-vault-resource-id" can not be empty if '
'"--azure-keyvault-kms-key-vault-network-access" is "Private".'
)
if (
key_vault_network_access == CONST_AZURE_KEYVAULT_NETWORK_ACCESS_PUBLIC and
(
azure_keyvault_kms_key_vault_resource_id is not None and
azure_keyvault_kms_key_vault_resource_id != ""
)
):
raise ArgumentUsageError(
'"--azure-keyvault-kms-key-vault-resource-id" must be empty if '
'"--azure-keyvault-kms-key-vault-network-access" is "Public".'
)
return azure_keyvault_kms_key_vault_resource_id | Internal function to obtain the value of azure_keyvault_kms_key_vault_resource_id according to the context.
This function supports the option of enable_validation. When enabled, it will do validation, and raise a
RequiredArgumentMissingError.
:return: string or None | _get_azure_keyvault_kms_key_vault_resource_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_azure_keyvault_kms_key_vault_resource_id(self) -> Union[str, None]:
"""Obtain the value of azure_keyvault_kms_key_vault_resource_id.
This function will verify the parameter by default. When enabled, if enable_azure_keyvault_kms is False,
raise a RequiredArgumentMissingError.
:return: bool
"""
return self._get_azure_keyvault_kms_key_vault_resource_id(enable_validation=True) | Obtain the value of azure_keyvault_kms_key_vault_resource_id.
This function will verify the parameter by default. When enabled, if enable_azure_keyvault_kms is False,
raise a RequiredArgumentMissingError.
:return: bool | get_azure_keyvault_kms_key_vault_resource_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_enable_image_cleaner(self) -> bool:
"""Obtain the value of enable_image_cleaner.
:return: bool
"""
# read the original value passed by the command
enable_image_cleaner = self.raw_param.get("enable_image_cleaner")
return enable_image_cleaner | Obtain the value of enable_image_cleaner.
:return: bool | get_enable_image_cleaner | 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_image_cleaner(self) -> bool:
"""Obtain the value of disable_image_cleaner.
This function supports the option of enable_validation. When enabled, if both enable_image_cleaner and
disable_image_cleaner are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# read the original value passed by the command
disable_image_cleaner = self.raw_param.get("disable_image_cleaner")
return disable_image_cleaner | Obtain the value of disable_image_cleaner.
This function supports the option of enable_validation. When enabled, if both enable_image_cleaner and
disable_image_cleaner are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | get_disable_image_cleaner | 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_image_cleaner_interval_hours(self, enable_validation: bool = False) -> Union[int, None]:
"""Internal function to obtain the value of image_cleaner_interval_hours according to the context.
This function supports the option of enable_validation. When enabled
1. In Create mode
a. if image_cleaner_interval_hours is specified but enable_image_cleaner is missed,
raise a RequiredArgumentMissingError.
2. In update mode
b. if image_cleaner_interval_hours is specified and image cleaner was not enabled,
raise a RequiredArgumentMissingError.
c. if image_cleaner_interval_hours is specified and disable_image_cleaner is specified,
raise a MutuallyExclusiveArgumentError.
:return: int or None
"""
# read the original value passed by the command
image_cleaner_interval_hours = self.raw_param.get("image_cleaner_interval_hours")
if image_cleaner_interval_hours is not None and enable_validation:
enable_image_cleaner = self.get_enable_image_cleaner()
disable_image_cleaner = self.get_disable_image_cleaner()
if self.decorator_mode == DecoratorMode.CREATE:
if not enable_image_cleaner:
raise RequiredArgumentMissingError(
'"--image-cleaner-interval-hours" requires "--enable-image-cleaner" in create mode.')
elif self.decorator_mode == DecoratorMode.UPDATE:
if not enable_image_cleaner and (
not self.mc or
not self.mc.security_profile or
not self.mc.security_profile.image_cleaner or
not self.mc.security_profile.image_cleaner.enabled
):
raise RequiredArgumentMissingError(
'Update "--image-cleaner-interval-hours" requires specifying "--enable-image-cleaner" \
or ImageCleaner enabled on managed cluster.')
if disable_image_cleaner:
raise MutuallyExclusiveArgumentError(
'Cannot specify --image-cleaner-interval-hours and --disable-image-cleaner at the same time.')
return image_cleaner_interval_hours | Internal function to obtain the value of image_cleaner_interval_hours according to the context.
This function supports the option of enable_validation. When enabled
1. In Create mode
a. if image_cleaner_interval_hours is specified but enable_image_cleaner is missed,
raise a RequiredArgumentMissingError.
2. In update mode
b. if image_cleaner_interval_hours is specified and image cleaner was not enabled,
raise a RequiredArgumentMissingError.
c. if image_cleaner_interval_hours is specified and disable_image_cleaner is specified,
raise a MutuallyExclusiveArgumentError.
:return: int or None | _get_image_cleaner_interval_hours | 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_image_cleaner_interval_hours(self) -> Union[int, None]:
"""Obtain the value of image_cleaner_interval_hours.
This function supports the option of enable_validation. When enabled
1. In Create mode
a. if image_cleaner_interval_hours is specified but enable_image_cleaner is missed,
raise a RequiredArgumentMissingError.
2. In update mode
b. if image_cleaner_interval_hours is specified and image cleaner was not enabled,
raise a RequiredArgumentMissingError.
c. if image_cleaner_interval_hours is specified and disable_image_cleaner is specified,
raise a MutuallyExclusiveArgumentError.
:return: int or None
"""
interval_hours = self._get_image_cleaner_interval_hours(enable_validation=True)
return interval_hours | Obtain the value of image_cleaner_interval_hours.
This function supports the option of enable_validation. When enabled
1. In Create mode
a. if image_cleaner_interval_hours is specified but enable_image_cleaner is missed,
raise a RequiredArgumentMissingError.
2. In update mode
b. if image_cleaner_interval_hours is specified and image cleaner was not enabled,
raise a RequiredArgumentMissingError.
c. if image_cleaner_interval_hours is specified and disable_image_cleaner is specified,
raise a MutuallyExclusiveArgumentError.
:return: int or None | get_image_cleaner_interval_hours | 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_local_accounts(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of disable_local_accounts.
This function supports the option of enable_validation. When enabled, if both disable_local_accounts and
enable_local_accounts are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# read the original value passed by the command
disable_local_accounts = self.raw_param.get("disable_local_accounts")
# 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, "disable_local_accounts") and # backward compatibility
self.mc.disable_local_accounts is not None
):
disable_local_accounts = self.mc.disable_local_accounts
# this parameter does not need dynamic completion
# validation
if enable_validation:
if self.decorator_mode == DecoratorMode.UPDATE:
if disable_local_accounts and self._get_enable_local_accounts(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"Cannot specify --disable-local-accounts and "
"--enable-local-accounts at the same time."
)
return disable_local_accounts | Internal function to obtain the value of disable_local_accounts.
This function supports the option of enable_validation. When enabled, if both disable_local_accounts and
enable_local_accounts are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | _get_disable_local_accounts | 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_local_accounts(self) -> bool:
"""Obtain the value of disable_local_accounts.
This function will verify the parameter by default. If both disable_local_accounts and enable_local_accounts
are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_disable_local_accounts(enable_validation=True) | Obtain the value of disable_local_accounts.
This function will verify the parameter by default. If both disable_local_accounts and enable_local_accounts
are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | get_disable_local_accounts | 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_local_accounts(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_local_accounts.
This function supports the option of enable_validation. When enabled, if both disable_local_accounts and
enable_local_accounts are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# read the original value passed by the command
enable_local_accounts = self.raw_param.get("enable_local_accounts")
# 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 enable_local_accounts and self._get_disable_local_accounts(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"Cannot specify --disable-local-accounts and "
"--enable-local-accounts at the same time."
)
return enable_local_accounts | Internal function to obtain the value of enable_local_accounts.
This function supports the option of enable_validation. When enabled, if both disable_local_accounts and
enable_local_accounts are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | _get_enable_local_accounts | 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_local_accounts(self) -> bool:
"""Obtain the value of enable_local_accounts.
This function will verify the parameter by default. If both disable_local_accounts and enable_local_accounts
are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_enable_local_accounts(enable_validation=True) | Obtain the value of enable_local_accounts.
This function will verify the parameter by default. If both disable_local_accounts and enable_local_accounts
are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | get_enable_local_accounts | 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_edge_zone(self) -> Union[str, None]:
"""Obtain the value of edge_zone.
:return: string or None
"""
# read the original value passed by the command
edge_zone = self.raw_param.get("edge_zone")
# try to read the property value corresponding to the parameter from the `mc` object
# Backward Compatibility: We also support api version v2020.11.01 in profile 2020-09-01-hybrid and there is
# no such attribute.
if (
self.mc and
hasattr(self.mc, "extended_location") and
self.mc.extended_location and
self.mc.extended_location.name is not None
):
edge_zone = self.mc.extended_location.name
# this parameter does not need dynamic completion
# this parameter does not need validation
return edge_zone | Obtain the value of edge_zone.
:return: string or None | get_edge_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_node_resource_group(self) -> Union[str, None]:
"""Obtain the value of node_resource_group.
:return: string or None
"""
# read the original value passed by the command
node_resource_group = self.raw_param.get("node_resource_group")
# try to read the property value corresponding to the parameter from the `mc` object
if self.mc and self.mc.node_resource_group is not None:
node_resource_group = self.mc.node_resource_group
# this parameter does not need dynamic completion
# this parameter does not need validation
return node_resource_group | Obtain the value of node_resource_group.
:return: string or None | get_node_resource_group | 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_k8s_support_plan(self) -> Union[str, None]:
"""Obtain the value of kubernetes_support_plan.
:return: string or None
"""
# take input
support_plan = self.raw_param.get("k8s_support_plan")
if support_plan is None:
# user didn't update this property, load from existing ManagedCluster
if self.mc and hasattr(self.mc, "support_plan") and self.mc.support_plan is not None:
support_plan = self.mc.support_plan
return support_plan | Obtain the value of kubernetes_support_plan.
:return: string or None | get_k8s_support_plan | 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_yes(self) -> bool:
"""Obtain the value of yes.
Note: yes will not be decorated into the `mc` object.
:return: bool
"""
# read the original value passed by the command
yes = self.raw_param.get("yes")
# this parameter does not need dynamic completion
# this parameter does not need validation
return yes | Obtain the value of yes.
Note: yes will not be decorated into the `mc` object.
:return: bool | get_yes | 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_no_wait(self) -> bool:
"""Obtain the value of no_wait.
Note: no_wait will not be decorated into the `mc` object.
:return: bool
"""
# read the original value passed by the command
no_wait = self.raw_param.get("no_wait")
# this parameter does not need dynamic completion
# this parameter does not need validation
return no_wait | Obtain the value of no_wait.
Note: no_wait will not be decorated into the `mc` object.
:return: bool | get_no_wait | 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_aks_custom_headers(self) -> Dict[str, str]:
"""Obtain the value of aks_custom_headers.
Note: aks_custom_headers will not be decorated into the `mc` object.
This function will normalize the parameter by default. It will call "extract_comma_separated_string" to extract
comma-separated key value pairs from the string.
:return: dictionary
"""
# read the original value passed by the command
aks_custom_headers = self.raw_param.get("aks_custom_headers")
# normalize user-provided header, extract key-value pairs with comma as separator
# used to enable (preview) features through custom header field or AKSHTTPCustomFeatures (internal only)
aks_custom_headers = extract_comma_separated_string(
aks_custom_headers,
enable_strip=True,
extract_kv=True,
default_value={},
allow_appending_values_to_same_key=True,
)
# this parameter does not need validation
return aks_custom_headers | Obtain the value of aks_custom_headers.
Note: aks_custom_headers will not be decorated into the `mc` object.
This function will normalize the parameter by default. It will call "extract_comma_separated_string" to extract
comma-separated key value pairs from the string.
:return: dictionary | get_aks_custom_headers | 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_azure_monitor_metrics(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_azure_monitor_metrics.
This function supports the option of enable_validation.
When enabled, if both enable_azure_monitor_metrics and disable_azure_monitor_metrics are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# print("_get_enable_azure_monitor_metrics being called...")
# Read the original value passed by the command.
enable_azure_monitor_metrics = self.raw_param.get("enable_azure_monitor_metrics")
# 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, "azure_monitor_profile") and
self.mc.azure_monitor_profile and
self.mc.azure_monitor_profile.metrics
):
enable_azure_monitor_metrics = self.mc.azure_monitor_profile.metrics.enabled
# This parameter does not need dynamic completion.
if enable_validation:
if enable_azure_monitor_metrics and self._get_disable_azure_monitor_metrics(False):
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-azure-monitor-metrics and --disable-azure-monitor-metrics at the same time"
)
if enable_azure_monitor_metrics and not check_is_msi_cluster(self.mc):
raise RequiredArgumentMissingError(
"--enable-azure-monitor-metrics can only be specified for clusters with managed identity enabled"
)
return enable_azure_monitor_metrics | Internal function to obtain the value of enable_azure_monitor_metrics.
This function supports the option of enable_validation.
When enabled, if both enable_azure_monitor_metrics and disable_azure_monitor_metrics are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool | _get_enable_azure_monitor_metrics | 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_azure_monitor_metrics(self) -> bool:
"""Obtain the value of enable_azure_monitor_metrics.
This function will verify the parameter by default.
If both enable_azure_monitor_metrics and disable_azure_monitor_metrics are specified,
raise a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_enable_azure_monitor_metrics(enable_validation=True) | Obtain the value of enable_azure_monitor_metrics.
This function will verify the parameter by default.
If both enable_azure_monitor_metrics and disable_azure_monitor_metrics are specified,
raise a MutuallyExclusiveArgumentError.
:return: bool | get_enable_azure_monitor_metrics | 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_azure_monitor_metrics(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of disable_azure_monito4790r_metrics.
This function supports the option of enable_validation.
When enabled, if both enable_azure_monitor_metrics and disable_azure_monitor_metrics are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# Read the original value passed by the command.
disable_azure_monitor_metrics = self.raw_param.get("disable_azure_monitor_metrics")
if enable_validation:
if disable_azure_monitor_metrics and self._get_enable_azure_monitor_metrics(False):
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-azure-monitor-metrics and --disable-azure-monitor-metrics at the same time"
)
return disable_azure_monitor_metrics | Internal function to obtain the value of disable_azure_monito4790r_metrics.
This function supports the option of enable_validation.
When enabled, if both enable_azure_monitor_metrics and disable_azure_monitor_metrics are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool | _get_disable_azure_monitor_metrics | 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_azure_monitor_metrics(self) -> bool:
"""Obtain the value of disable_azure_monitor_metrics.
This function will verify the parameter by default.
If both enable_azure_monitor_metrics and disable_azure_monitor_metrics are specified,
raise a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_disable_azure_monitor_metrics(enable_validation=True) | Obtain the value of disable_azure_monitor_metrics.
This function will verify the parameter by default.
If both enable_azure_monitor_metrics and disable_azure_monitor_metrics are specified,
raise a MutuallyExclusiveArgumentError.
:return: bool | get_disable_azure_monitor_metrics | 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_vpa(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_vpa.
This function supports the option of enable_vpa. When enabled, if both enable_vpa and enable_vpa are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# Read the original value passed by the command.
enable_vpa = self.raw_param.get("enable_vpa")
# This parameter does not need dynamic completion.
if enable_validation:
if enable_vpa and self._get_disable_vpa(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-vpa and --disable-vpa at the same time."
)
return enable_vpa | Internal function to obtain the value of enable_vpa.
This function supports the option of enable_vpa. When enabled, if both enable_vpa and enable_vpa are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool | _get_enable_vpa | 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_vpa(self) -> bool:
"""Obtain the value of enable_vpa.
This function will verify the parameter by default. If both enable_vpa and disable_vpa are specified, raise
a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_enable_vpa(enable_validation=True) | Obtain the value of enable_vpa.
This function will verify the parameter by default. If both enable_vpa and disable_vpa are specified, raise
a MutuallyExclusiveArgumentError.
:return: bool | get_enable_vpa | 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_vpa(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of disable_vpa.
This function supports the option of enable_vpa. When enabled, if both enable_vpa and disable_vpa are specified,
raise a MutuallyExclusiveArgumentError.
:return: bool
"""
# Read the original value passed by the command.
disable_vpa = self.raw_param.get("disable_vpa")
# 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_vpa and self._get_enable_vpa(enable_validation=False):
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-vpa and --disable-vpa at the same time."
)
return disable_vpa | Internal function to obtain the value of disable_vpa.
This function supports the option of enable_vpa. When enabled, if both enable_vpa and disable_vpa are specified,
raise a MutuallyExclusiveArgumentError.
:return: bool | _get_disable_vpa | 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_vpa(self) -> bool:
"""Obtain the value of disable_vpa.
This function will verify the parameter by default. If both enable_vpa and disable_vpa are specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
return self._get_disable_vpa(enable_validation=True) | Obtain the value of disable_vpa.
This function will verify the parameter by default. If both enable_vpa and disable_vpa are specified, raise a MutuallyExclusiveArgumentError.
:return: bool | get_disable_vpa | 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_force_upgrade(self) -> Union[bool, None]:
"""Obtain the value of force_upgrade.
:return: bool or None
"""
# this parameter does not need dynamic completion
# validation is done with param validator
enable_force_upgrade = self.raw_param.get("enable_force_upgrade")
disable_force_upgrade = self.raw_param.get("disable_force_upgrade")
if enable_force_upgrade is False and disable_force_upgrade is False:
return None
if enable_force_upgrade is not None:
return enable_force_upgrade
if disable_force_upgrade is not None:
return not disable_force_upgrade
return None | Obtain the value of force_upgrade.
:return: bool or None | get_force_upgrade | 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_upgrade_override_until(self) -> Union[str, None]:
"""Obtain the value of upgrade_override_until.
:return: string or None
"""
# this parameter does not need dynamic completion
# this parameter does not need validation
return self.raw_param.get("upgrade_override_until") | Obtain the value of upgrade_override_until.
:return: string or None | get_upgrade_override_until | 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_cost_analysis(self, enable_validation: bool = False) -> bool:
"""Internal function to obtain the value of enable_cost_analysis.
When enabled, if both enable_cost_analysis and disable_cost_analysis are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool
"""
enable_cost_analysis = self.raw_param.get("enable_cost_analysis")
# This parameter does not need dynamic completion.
if enable_validation:
if enable_cost_analysis and self.get_disable_cost_analysis():
raise MutuallyExclusiveArgumentError(
"Cannot specify --enable-cost-analysis and --disable-cost-analysis at the same time."
)
return enable_cost_analysis | Internal function to obtain the value of enable_cost_analysis.
When enabled, if both enable_cost_analysis and disable_cost_analysis are
specified, raise a MutuallyExclusiveArgumentError.
:return: bool | _get_enable_cost_analysis | 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_cost_analysis(self) -> bool:
"""Obtain the value of enable_cost_analysis.
:return: bool
"""
return self._get_enable_cost_analysis(enable_validation=True) | Obtain the value of enable_cost_analysis.
:return: bool | get_enable_cost_analysis | 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_cost_analysis(self) -> bool:
"""Obtain the value of disable_cost_analysis.
:return: bool
"""
# Note: No need to check for mutually exclusive parameter with enable-cost-analysis here
# because it's already checked in _get_enable_cost_analysis
return self.raw_param.get("disable_cost_analysis") | Obtain the value of disable_cost_analysis.
:return: bool | get_disable_cost_analysis | 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_if_match(self) -> Union[str, None]:
"""Obtain the value of if_match.
:return: string or None
"""
# this parameter does not need dynamic completion
# this parameter does not need validation
return self.raw_param.get("if_match") | Obtain the value of if_match.
:return: string or None | get_if_match | 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_if_none_match(self) -> Union[str, None]:
"""Obtain the value of if_none_match.
:return: string or None
"""
# this parameter does not need dynamic completion
# this parameter does not need validation
return self.raw_param.get("if_none_match") | Obtain the value of if_none_match.
:return: string or None | get_if_none_match | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.