4848 CONST_NONE_UPGRADE_CHANNEL ,
4949 CONST_AVAILABILITY_SET ,
5050 CONST_VIRTUAL_MACHINES ,
51+ CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH ,
52+ CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE
5153)
5254from azure .cli .command_modules .acs .azurecontainerstorage ._consts import (
5355 CONST_ACSTOR_EXT_INSTALLATION_NAME ,
@@ -2531,19 +2533,20 @@ def get_network_dataplane(self) -> Union[str, None]:
25312533 """
25322534 return self .raw_param .get ("network_dataplane" )
25332535
2534- def get_acns_enablement (self ) -> Tuple [
2536+ def get_acns_enablement_with_perf (self ) -> Tuple [
25352537 Union [bool , None ],
25362538 Union [bool , None ],
25372539 Union [bool , None ],
2540+ Union [bool , None ]
25382541 ]:
25392542 """Get the enablement of acns
25402543
2541- :return: Tuple of 3 elements which can be bool or None
2544+ :return: Tuple of 4 elements which can be bool or None
25422545 """
25432546 enable_acns = self .raw_param .get ("enable_acns" )
25442547 disable_acns = self .raw_param .get ("disable_acns" )
25452548 if enable_acns is None and disable_acns is None :
2546- return None , None , None
2549+ return None , None , None , None
25472550 if enable_acns and disable_acns :
25482551 raise MutuallyExclusiveArgumentError (
25492552 "Cannot specify --enable-acns and "
@@ -2553,17 +2556,22 @@ def get_acns_enablement(self) -> Tuple[
25532556 disable_acns = bool (disable_acns ) if disable_acns is not None else False
25542557 acns = enable_acns or not disable_acns
25552558 acns_observability = self .get_acns_observability ()
2559+ acns_datapath_acceleration_mode = self .get_acns_datapath_acceleration_mode ()
2560+ acns_perf_enabled = None
2561+ if acns_datapath_acceleration_mode is not None :
2562+ acns_perf_enabled = acns_datapath_acceleration_mode == CONST_ACNS_DATAPATH_ACCELERATION_MODE_BPFVETH
25562563 acns_security = self .get_acns_security ()
2557- if acns and (acns_observability is False and acns_security is False ):
2564+ if acns and (acns_observability is False and acns_security is False and acns_perf_enabled is not True ):
25582565 raise MutuallyExclusiveArgumentError (
2559- "Cannot disable both observability and security when enabling ACNS. "
2566+ "Cannot disable observability, security, and performance acceleration when enabling ACNS. "
25602567 "Please enable at least one of them or disable ACNS with --disable-acns."
25612568 )
2562- if not acns and (acns_observability is not None or acns_security is not None ):
2569+ if not acns and (acns_observability is not None or acns_security is not None or
2570+ acns_datapath_acceleration_mode is not None ):
25632571 raise MutuallyExclusiveArgumentError (
25642572 "--disable-acns does not use any additional acns arguments."
25652573 )
2566- return acns , acns_observability , acns_security
2574+ return acns , acns_observability , acns_security , acns_perf_enabled
25672575
25682576 def get_acns_observability (self ) -> Union [bool , None ]:
25692577 """Get the enablement of acns observability
@@ -2579,6 +2587,28 @@ def get_acns_security(self) -> Union[bool, None]:
25792587 disable_acns_security = self .raw_param .get ("disable_acns_security" )
25802588 return not bool (disable_acns_security ) if disable_acns_security is not None else None
25812589
2590+ def get_acns_datapath_acceleration_mode (self ) -> Union [str , None ]:
2591+ """Get the value of acns_datapath_acceleration_mode
2592+
2593+ :return: str or None
2594+ """
2595+ disable_acns = self .raw_param .get ("disable_acns" )
2596+ enable_acns = self .raw_param .get ("enable_acns" )
2597+ acns_datapath_acceleration_mode = self .raw_param .get ("acns_datapath_acceleration_mode" )
2598+ if acns_datapath_acceleration_mode is not None and \
2599+ acns_datapath_acceleration_mode != CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE :
2600+ if disable_acns :
2601+ raise MutuallyExclusiveArgumentError (
2602+ "--disable-acns cannot be used with --acns-performance-acceleration-mode."
2603+ )
2604+ # Require explicit ACNS enablement when specifying a datapath acceleration mode on create
2605+ if self .decorator_mode == DecoratorMode .CREATE and not enable_acns :
2606+ raise ArgumentUsageError (
2607+ "--acns-datapath-acceleration-mode can only be used when ACNS is enabled. "
2608+ "Please specify --enable-acns."
2609+ )
2610+ return acns_datapath_acceleration_mode
2611+
25822612 def get_acns_advanced_networkpolicies (self ) -> Union [str , None ]:
25832613 """Get the value of acns_advanced_networkpolicies
25842614 :return: str or None
@@ -2842,7 +2872,8 @@ def get_addon_consts(self) -> Dict[str, str]:
28422872 CONST_MONITORING_USING_AAD_MSI_AUTH ,
28432873 CONST_OPEN_SERVICE_MESH_ADDON_NAME , CONST_ROTATION_POLL_INTERVAL ,
28442874 CONST_SECRET_ROTATION_ENABLED , CONST_VIRTUAL_NODE_ADDON_NAME ,
2845- CONST_VIRTUAL_NODE_SUBNET_NAME )
2875+ CONST_VIRTUAL_NODE_SUBNET_NAME
2876+ )
28462877
28472878 addon_consts = {}
28482879 addon_consts ["ADDONS" ] = ADDONS
@@ -6380,8 +6411,8 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
63806411
63816412 network_dataplane = self .context .get_network_dataplane ()
63826413
6383- (acns_enabled , acns_observability , acns_security ) = self .context .get_acns_enablement ()
63846414 acns_advanced_networkpolicies = self .context .get_acns_advanced_networkpolicies ()
6415+ (acns_enabled , acns_observability , acns_security , acns_perf_enabled ) = self .context .get_acns_enablement_with_perf ()
63856416 acns_transit_encryption = self .context .get_acns_transit_encryption_type ()
63866417 if acns_enabled is not None :
63876418 acns = self .models .AdvancedNetworking (
@@ -6402,6 +6433,10 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
64026433 )
64036434 else :
64046435 acns .security .advanced_network_policies = acns_advanced_networkpolicies
6436+ if acns_perf_enabled is not None :
6437+ if acns .performance is None :
6438+ acns .performance = self .models .AdvancedNetworkingPerformance ()
6439+ acns .performance .acceleration_mode = self .context .get_acns_datapath_acceleration_mode ()
64056440 if acns_transit_encryption is not None :
64066441 if acns .security is None :
64076442 acns .security = self .models .AdvancedNetworkingSecurity ()
@@ -8312,8 +8347,8 @@ def update_network_profile_advanced_networking(self, mc: ManagedCluster) -> Mana
83128347 :return: the ManagedCluster object
83138348 """
83148349 self ._ensure_mc (mc )
8315- (acns_enabled , acns_observability , acns_security ) = self .context .get_acns_enablement ()
83168350 acns_advanced_networkpolicies = self .context .get_acns_advanced_networkpolicies ()
8351+ (acns_enabled , acns_observability , acns_security , acns_perf_enabled ) = self .context .get_acns_enablement_with_perf ()
83178352 acns_transit_encryption = self .context .get_acns_transit_encryption_type ()
83188353 if acns_enabled is not None :
83198354 acns = self .models .AdvancedNetworking (
@@ -8334,6 +8369,18 @@ def update_network_profile_advanced_networking(self, mc: ManagedCluster) -> Mana
83348369 )
83358370 else :
83368371 acns .security .advanced_network_policies = acns_advanced_networkpolicies
8372+ if acns_perf_enabled is not None :
8373+ acns .performance = self .models .AdvancedNetworkingPerformance (
8374+ acceleration_mode = self .context .get_acns_datapath_acceleration_mode (),
8375+ )
8376+ elif not acns_enabled :
8377+ acns .performance = self .models .AdvancedNetworkingPerformance (
8378+ acceleration_mode = CONST_ACNS_DATAPATH_ACCELERATION_MODE_NONE ,
8379+ )
8380+ elif mc .network_profile .advanced_networking is not None :
8381+ acns .performance = mc .network_profile .advanced_networking .performance
8382+
8383+ if acns_enabled is not None :
83378384 if acns_transit_encryption is not None :
83388385 if acns .security is None :
83398386 acns .security = self .models .AdvancedNetworkingSecurity ()
0 commit comments