def get_enable_fips_image(self) -> bool: """Obtain the value of enable_fips_image. :return: bool """ # read the original value passed by the command enable_fips_image = self.raw_param.get("enable_fips_image") # try to read the property value corresponding to the parameter from the `mc` object if self.mc and self.mc.agent_pool_profiles: agent_pool_profile = safe_list_get( self.mc.agent_pool_profiles, 0, None ) if ( agent_pool_profile and agent_pool_profile.enable_fips is not None ): enable_fips_image = agent_pool_profile.enable_fips # this parameter does not need dynamic completion # this parameter does not need validation return enable_fips_image
def get_gpu_instance_profile(self) -> Union[str, None]: """Obtain the value of gpu_instance_profile. :return: string or None """ # read the original value passed by the command gpu_instance_profile = self.raw_param.get("gpu_instance_profile") # try to read the property value corresponding to the parameter from the `mc` object if self.mc and self.mc.agent_pool_profiles: agent_pool_profile = safe_list_get( self.mc.agent_pool_profiles, 0, None ) if ( agent_pool_profile and agent_pool_profile.gpu_instance_profile is not None ): gpu_instance_profile = agent_pool_profile.gpu_instance_profile # this parameter does not need dynamic completion # this parameter does not need validation return gpu_instance_profile
def get_pod_subnet_id(self) -> Union[str, None]: """Obtain the value of pod_subnet_id. :return: bool """ # read the original value passed by the command pod_subnet_id = self.raw_param.get("pod_subnet_id") # try to read the property value corresponding to the parameter from the `mc` object if self.mc and self.mc.agent_pool_profiles: agent_pool_profile = safe_list_get( self.mc.agent_pool_profiles, 0, None ) if ( agent_pool_profile and agent_pool_profile.pod_subnet_id is not None ): pod_subnet_id = agent_pool_profile.pod_subnet_id # this parameter does not need dynamic completion # this parameter does not need validation return pod_subnet_id
def get_linux_os_config(self) -> Union[dict, LinuxOSConfig, None]: """Obtain the value of linux_os_config. :return: dict, LinuxOSConfig or None """ # read the original value passed by the command linux_os_config = None linux_os_config_file_path = self.raw_param.get("linux_os_config") # validate user input if linux_os_config_file_path: if not os.path.isfile(linux_os_config_file_path): raise InvalidArgumentValueError( "{} is not valid file, or not accessable.".format( linux_os_config_file_path ) ) linux_os_config = get_file_json(linux_os_config_file_path) if not isinstance(linux_os_config, dict): raise InvalidArgumentValueError( "Error reading Linux OS configuration from {}. " "Please see https://aka.ms/CustomNodeConfig for correct format.".format( linux_os_config_file_path ) ) # try to read the property value corresponding to the parameter from the `mc` object if self.mc and self.mc.agent_pool_profiles: agent_pool_profile = safe_list_get( self.mc.agent_pool_profiles, 0, None ) if ( agent_pool_profile and agent_pool_profile.linux_os_config is not None ): linux_os_config = agent_pool_profile.linux_os_config # this parameter does not need dynamic completion # this parameter does not need validation return linux_os_config
def set_up_agent_pool_profiles(self, mc: ManagedCluster) -> ManagedCluster: """Set up agent pool profiles for the ManagedCluster object. Call the method of the same name in the parent class to set up agent_pool_profiles, and then set some additional properties on this basis. :return: the ManagedCluster object """ mc = super().set_up_agent_pool_profiles(mc) agent_pool_profile = safe_list_get(mc.agent_pool_profiles, 0, None) # set up extra parameters supported in aks-preview agent_pool_profile.pod_subnet_id = self.context.get_pod_subnet_id() agent_pool_profile.enable_fips = self.context.get_enable_fips_image() agent_pool_profile.workload_runtime = ( self.context.get_workload_runtime() ) agent_pool_profile.gpu_instance_profile = ( self.context.get_gpu_instance_profile() ) agent_pool_profile.kubelet_config = self.context.get_kubelet_config() agent_pool_profile.linux_os_config = self.context.get_linux_os_config() return mc