Skip to content

Commit 33f5b24

Browse files
Ptnan7Jingnan Xu
andauthored
[CDN] Fix #27744: az afd origin-group: Add parameter --enable-health-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>
1 parent 186dca0 commit 33f5b24

4 files changed

Lines changed: 413 additions & 232 deletions

File tree

src/azure-cli/azure/cli/command_modules/cdn/commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ def load_command_table(self, _):
272272
from .custom.custom_afdx import AFDOriginUpdate
273273
self.command_table['afd origin update'] = AFDOriginUpdate(loader=self)
274274

275+
from .custom.custom_afdx import AFDOriginGroupCreate
276+
self.command_table['afd origin-group create'] = AFDOriginGroupCreate(loader=self)
277+
278+
from .custom.custom_afdx import AFDOriginGroupUpdate
279+
self.command_table['afd origin-group update'] = AFDOriginGroupUpdate(loader=self)
280+
275281
from .custom.custom_afdx import AFDRouteCreate
276282
self.command_table['afd route create'] = AFDRouteCreate(loader=self)
277283

src/azure-cli/azure/cli/command_modules/cdn/custom/custom_afdx.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
Create as _AFDProfileCreate, Update as _AFDProfileUpdate
2525
from azure.cli.command_modules.cdn.aaz.latest.afd.endpoint import Show as _AFDEndpointShow, \
2626
Create as _AFDEndpointCreate, Update as _AFDEndpointUpdate
27+
from azure.cli.command_modules.cdn.aaz.latest.afd.origin_group import Show as _AFDOriginGroupShow, \
28+
Create as _AFDOriginGroupCreate, Update as _AFDOriginGroupUpdate
2729
from azure.cli.core.aaz import AAZStrArg, AAZBoolArg, AAZListArg, AAZDateArg
2830
from knack.log import get_logger
2931
from .custom_rule_util import (create_condition, create_action,
@@ -183,6 +185,63 @@ def pre_operations(self):
183185
args.location = existing_location
184186

185187

188+
class AFDOriginGroupCreate(_AFDOriginGroupCreate):
189+
@classmethod
190+
def _build_arguments_schema(cls, *args, **kwargs):
191+
args_schema = super()._build_arguments_schema(*args, **kwargs)
192+
args_schema.enable_health_probe = AAZBoolArg(
193+
options=['--enable-health-probe'],
194+
help='Indicates whether to enable probe on the origin group.',
195+
blank=True,
196+
)
197+
return args_schema
198+
199+
def pre_operations(self):
200+
args = self.ctx.args
201+
if not has_value(args.enable_health_probe) or args.enable_health_probe.to_serialized_data() is False:
202+
args.probe_path = None
203+
args.probe_protocol = None
204+
args.probe_interval_in_seconds = None
205+
args.probe_request_type = None
206+
207+
208+
class AFDOriginGroupUpdate(_AFDOriginGroupUpdate):
209+
@classmethod
210+
def _build_arguments_schema(cls, *args, **kwargs):
211+
args_schema = super()._build_arguments_schema(*args, **kwargs)
212+
args_schema.enable_health_probe = AAZBoolArg(
213+
options=['--enable-health-probe'],
214+
help='Indicates whether to enable probe on the origin group.',
215+
blank=True,
216+
)
217+
return args_schema
218+
219+
def pre_operations(self):
220+
args = self.ctx.args
221+
existing = _AFDOriginGroupShow(cli_ctx=self.cli_ctx)(command_args={
222+
'resource_group': args.resource_group,
223+
'profile_name': args.profile_name,
224+
'origin_group_name': args.origin_group_name
225+
})
226+
if not has_value(args.enable_health_probe):
227+
if existing['healthProbeSettings'] is not None:
228+
if 'probePath' in existing['healthProbeSettings'] \
229+
or 'probeProtocol' in existing['healthProbeSettings'] \
230+
or 'probeIntervalInSeconds' in existing['healthProbeSettings'] \
231+
or 'probeRequestType' in existing['healthProbeSettings']:
232+
args.enable_health_probe = True
233+
else:
234+
args.enable_health_probe = False
235+
else:
236+
args.enable_health_probe = False
237+
238+
if args.enable_health_probe.to_serialized_data() is False:
239+
args.probe_path = None
240+
args.probe_protocol = None
241+
args.probe_interval_in_seconds = None
242+
args.probe_request_type = None
243+
244+
186245
class AFDOriginCreate(_AFDOriginCreate):
187246
@classmethod
188247
def _build_arguments_schema(cls, *args, **kwargs):

0 commit comments

Comments
 (0)