Skip to content

Commit

Permalink
[CDN] Fix #27744: az afd origin-group: Add parameter `--enable-heal…
Browse files Browse the repository at this point in the history
…th-probe` (#28432)

* add enable_health_probe for origin group

* add new parameters

* change para

* change blank value

---------

Co-authored-by: Jingnan Xu <jingnanxu@microsoft.com>
  • Loading branch information
Ptnan7 and Jingnan Xu committed Feb 26, 2024
1 parent 186dca0 commit 33f5b24
Show file tree
Hide file tree
Showing 4 changed files with 413 additions and 232 deletions.
6 changes: 6 additions & 0 deletions src/azure-cli/azure/cli/command_modules/cdn/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ def load_command_table(self, _):
from .custom.custom_afdx import AFDOriginUpdate
self.command_table['afd origin update'] = AFDOriginUpdate(loader=self)

from .custom.custom_afdx import AFDOriginGroupCreate
self.command_table['afd origin-group create'] = AFDOriginGroupCreate(loader=self)

from .custom.custom_afdx import AFDOriginGroupUpdate
self.command_table['afd origin-group update'] = AFDOriginGroupUpdate(loader=self)

from .custom.custom_afdx import AFDRouteCreate
self.command_table['afd route create'] = AFDRouteCreate(loader=self)

Expand Down
59 changes: 59 additions & 0 deletions src/azure-cli/azure/cli/command_modules/cdn/custom/custom_afdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
Create as _AFDProfileCreate, Update as _AFDProfileUpdate
from azure.cli.command_modules.cdn.aaz.latest.afd.endpoint import Show as _AFDEndpointShow, \
Create as _AFDEndpointCreate, Update as _AFDEndpointUpdate
from azure.cli.command_modules.cdn.aaz.latest.afd.origin_group import Show as _AFDOriginGroupShow, \
Create as _AFDOriginGroupCreate, Update as _AFDOriginGroupUpdate
from azure.cli.core.aaz import AAZStrArg, AAZBoolArg, AAZListArg, AAZDateArg
from knack.log import get_logger
from .custom_rule_util import (create_condition, create_action,
Expand Down Expand Up @@ -183,6 +185,63 @@ def pre_operations(self):
args.location = existing_location


class AFDOriginGroupCreate(_AFDOriginGroupCreate):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.enable_health_probe = AAZBoolArg(
options=['--enable-health-probe'],
help='Indicates whether to enable probe on the origin group.',
blank=True,
)
return args_schema

def pre_operations(self):
args = self.ctx.args
if not has_value(args.enable_health_probe) or args.enable_health_probe.to_serialized_data() is False:
args.probe_path = None
args.probe_protocol = None
args.probe_interval_in_seconds = None
args.probe_request_type = None


class AFDOriginGroupUpdate(_AFDOriginGroupUpdate):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
args_schema = super()._build_arguments_schema(*args, **kwargs)
args_schema.enable_health_probe = AAZBoolArg(
options=['--enable-health-probe'],
help='Indicates whether to enable probe on the origin group.',
blank=True,
)
return args_schema

def pre_operations(self):
args = self.ctx.args
existing = _AFDOriginGroupShow(cli_ctx=self.cli_ctx)(command_args={
'resource_group': args.resource_group,
'profile_name': args.profile_name,
'origin_group_name': args.origin_group_name
})
if not has_value(args.enable_health_probe):
if existing['healthProbeSettings'] is not None:
if 'probePath' in existing['healthProbeSettings'] \
or 'probeProtocol' in existing['healthProbeSettings'] \
or 'probeIntervalInSeconds' in existing['healthProbeSettings'] \
or 'probeRequestType' in existing['healthProbeSettings']:
args.enable_health_probe = True
else:
args.enable_health_probe = False
else:
args.enable_health_probe = False

if args.enable_health_probe.to_serialized_data() is False:
args.probe_path = None
args.probe_protocol = None
args.probe_interval_in_seconds = None
args.probe_request_type = None


class AFDOriginCreate(_AFDOriginCreate):
@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
Expand Down

0 comments on commit 33f5b24

Please sign in to comment.