Skip to content

Commit 9d6fbb5

Browse files
committed
Supporting resource Predictions types in mdp commands
1 parent 4a75319 commit 9d6fbb5

File tree

5 files changed

+290
-216
lines changed

5 files changed

+290
-216
lines changed

src/mdp/azext_mdp/aaz/latest/mdp/pool/_create.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ class Create(AAZCommand):
2525
--organization-profile "azure-dev-ops={organizations:[{url:'https://dev.azure.com/test-org',parallelism:2}],permissionProfile:{kind:'CreatorOnly'}}"
2626
--devcenter-project-resource-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example/providers/Microsoft.DevCenter/projects/contoso-proj"
2727
--fabric-profile "vmss={sku:{name:Standard_D2ads_v5},storageProfile:{osDiskStorageAccountType:Standard},images:[{resourceId:'/Subscriptions/00000000-0000-0000-0000-000000000000/Providers/Microsoft.Compute/Locations/eastus2/Publishers/canonical/ArtifactTypes/VMImage/Offers/0001-com-ubuntu-server-focal/Skus/20_04-lts-gen2/versions/latest',buffer:*}],osProfile:{secretsManagementSettings:{observedCertificates:[],keyExportable:false},logonType:Service}}"
28+
29+
:example: Create with agent profile resource predictions
30+
az mdp pool create --location "eastus" --name "cli-contoso-pool" --resource-group "rg1"
31+
--maximum-concurrency 3
32+
--agent-profile "{Stateless:{},resourcePredictionsProfile:{Manual:{}},resourcePredictions:{timezone:'UTC',daysData:[{},{},{},{'09:00:00':2,'11:00:00':0},{},{},{}]}}"
33+
--organization-profile "azure-dev-ops={organizations:[{url:'https://dev.azure.com/test-org',parallelism:2}],permissionProfile:{kind:'CreatorOnly'}}"
34+
--devcenter-project-resource-id "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example/providers/Microsoft.DevCenter/projects/contoso-proj"
35+
--fabric-profile "vmss={sku:{name:Standard_D2ads_v5},storageProfile:{osDiskStorageAccountType:Standard},images:[{resourceId:'/Subscriptions/00000000-0000-0000-0000-000000000000/Providers/Microsoft.Compute/Locations/eastus2/Publishers/canonical/ArtifactTypes/VMImage/Offers/0001-com-ubuntu-server-focal/Skus/20_04-lts-gen2/versions/latest',buffer:*}],osProfile:{secretsManagementSettings:{observedCertificates:[],keyExportable:false},logonType:Service}}"
2836
"""
2937

3038
_aaz_info = {
@@ -140,6 +148,25 @@ def _build_arguments_schema(cls, *args, **kwargs):
140148
enum={"Balanced": "Balanced", "BestPerformance": "BestPerformance", "MoreCostEffective": "MoreCostEffective", "MorePerformance": "MorePerformance", "MostCostEffective": "MostCostEffective"},
141149
)
142150

151+
resource_predictions = cls._args_schema.agent_profile.resource_predictions
152+
resource_predictions.timezone = AAZStrArg(
153+
options=["timezone", "timeZone"],
154+
help="Time zone of the predictive pool provisioning.",
155+
)
156+
157+
resource_predictions.days_data = AAZListArg(
158+
options=["days-data"],
159+
help="Resource predictions data per every day in a week.",
160+
)
161+
162+
days_data = cls._args_schema.agent_profile.resource_predictions.days_data
163+
days_data.Element = AAZDictArg(
164+
help="key value pairs with time and predicted count"
165+
)
166+
167+
_element = cls._args_schema.agent_profile.resource_predictions.days_data.Element
168+
_element.Element = AAZIntArg()
169+
143170
fabric_profile = cls._args_schema.fabric_profile
144171
fabric_profile.vmss = AAZObjectArg(
145172
options=["vmss"],
@@ -519,6 +546,19 @@ def content(self):
519546
resource_predictions_profile.discriminate_by("kind", "Automatic")
520547
resource_predictions_profile.discriminate_by("kind", "Manual")
521548

549+
resource_predictions = _builder.get(".properties.agentProfile.resourcePredictions")
550+
if resource_predictions is not None:
551+
resource_predictions.set_prop("timeZone", AAZStrType, ".timezone")
552+
resource_predictions.set_prop("daysData", AAZListType, ".days_data")
553+
554+
days_data = _builder.get(".properties.agentProfile.resourcePredictions.daysData")
555+
if days_data is not None:
556+
days_data.set_elements(AAZDictType, ".")
557+
558+
_elements = _builder.get(".properties.agentProfile.resourcePredictions.daysData[]")
559+
if _elements is not None:
560+
_elements.set_elements(AAZIntType, ".")
561+
522562
disc_automatic = _builder.get(".properties.agentProfile.resourcePredictionsProfile{kind:Automatic}")
523563
if disc_automatic is not None:
524564
disc_automatic.set_prop("predictionPreference", AAZStrType, ".automatic.prediction_preference")
@@ -782,6 +822,21 @@ def _build_schema_on_200_201(cls):
782822
serialized_name="maxAgentLifetime",
783823
)
784824

825+
resource_predictions = cls._schema_on_200_201.properties.agent_profile.resource_predictions
826+
resource_predictions.timezone = AAZStrType(
827+
serialized_name="timeZone",
828+
)
829+
830+
resource_predictions.days_data = AAZListType(
831+
serialized_name="daysData",
832+
)
833+
834+
days_data = cls._schema_on_200_201.properties.agent_profile.resource_predictions.days_data
835+
days_data.Element = AAZDictType()
836+
837+
_element = cls._schema_on_200_201.properties.agent_profile.resource_predictions.days_data.Element
838+
_element.Element = AAZIntType()
839+
785840
fabric_profile = cls._schema_on_200_201.properties.fabric_profile
786841
fabric_profile.kind = AAZStrType(
787842
flags={"required": True},

src/mdp/azext_mdp/aaz/latest/mdp/pool/_show.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,21 @@ def _build_schema_on_200(cls):
263263
serialized_name="maxAgentLifetime",
264264
)
265265

266+
resource_predictions = cls._schema_on_200.properties.agent_profile.resource_predictions
267+
resource_predictions.timezone = AAZStrType(
268+
serialized_name="timeZone",
269+
)
270+
271+
resource_predictions.days_data = AAZListType(
272+
serialized_name="daysData",
273+
)
274+
275+
days_data = cls._schema_on_200.properties.agent_profile.resource_predictions.days_data
276+
days_data.Element = AAZDictType()
277+
278+
_element = cls._schema_on_200.properties.agent_profile.resource_predictions.days_data.Element
279+
_element.Element = AAZIntType()
280+
266281
fabric_profile = cls._schema_on_200.properties.fabric_profile
267282
fabric_profile.kind = AAZStrType(
268283
flags={"required": True},

src/mdp/azext_mdp/aaz/latest/mdp/pool/_update.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,25 @@ def _build_arguments_schema(cls, *args, **kwargs):
142142
enum={"Balanced": "Balanced", "BestPerformance": "BestPerformance", "MoreCostEffective": "MoreCostEffective", "MorePerformance": "MorePerformance", "MostCostEffective": "MostCostEffective"},
143143
)
144144

145+
resource_predictions = cls._args_schema.agent_profile.resource_predictions
146+
resource_predictions.timezone = AAZStrArg(
147+
options=["timezone", "timeZone"],
148+
help="Time zone of the predictive pool provisioning.",
149+
)
150+
151+
resource_predictions.days_data = AAZListArg(
152+
options=["days-data"],
153+
help="Resource predictions data per every day in a week.",
154+
)
155+
156+
days_data = cls._args_schema.agent_profile.resource_predictions.days_data
157+
days_data.Element = AAZDictArg(
158+
help="key value pairs with time and predicted count"
159+
)
160+
161+
_element = cls._args_schema.agent_profile.resource_predictions.days_data.Element
162+
_element.Element = AAZIntArg()
163+
145164
fabric_profile = cls._args_schema.fabric_profile
146165
fabric_profile.vmss = AAZObjectArg(
147166
options=["vmss"],
@@ -710,6 +729,19 @@ def _update_instance(self, instance):
710729
if disc_stateful is not None:
711730
disc_stateful.set_prop("gracePeriodTimeSpan", AAZStrType, ".stateful.grace_period_time_span")
712731
disc_stateful.set_prop("maxAgentLifetime", AAZStrType, ".stateful.max_agent_lifetime")
732+
733+
resource_predictions = _builder.get(".properties.agentProfile.resourcePredictions")
734+
if resource_predictions is not None:
735+
resource_predictions.set_prop("timeZone", AAZStrType, ".timezone")
736+
resource_predictions.set_prop("daysData", AAZListType, ".days_data")
737+
738+
days_data = _builder.get(".properties.agentProfile.resourcePredictions.daysData")
739+
if days_data is not None:
740+
days_data.set_elements(AAZDictType, ".")
741+
742+
_elements = _builder.get(".properties.agentProfile.resourcePredictions.daysData[]")
743+
if _elements is not None:
744+
_elements.set_elements(AAZIntType, ".")
713745

714746
fabric_profile = _builder.get(".properties.fabricProfile")
715747
if fabric_profile is not None:
@@ -978,6 +1010,21 @@ def _build_schema_pool_read(cls, _schema):
9781010
serialized_name="maxAgentLifetime",
9791011
)
9801012

1013+
resource_predictions = _schema_pool_read.properties.agent_profile.resource_predictions
1014+
resource_predictions.timezone = AAZStrType(
1015+
serialized_name="timeZone",
1016+
)
1017+
1018+
resource_predictions.days_data = AAZListType(
1019+
serialized_name="daysData",
1020+
)
1021+
1022+
days_data = _schema_pool_read.properties.agent_profile.resource_predictions.days_data
1023+
days_data.Element = AAZDictType()
1024+
1025+
_element = _schema_pool_read.properties.agent_profile.resource_predictions.days_data.Element
1026+
_element.Element = AAZIntType()
1027+
9811028
fabric_profile = _schema_pool_read.properties.fabric_profile
9821029
fabric_profile.kind = AAZStrType(
9831030
flags={"required": True},

0 commit comments

Comments
 (0)