Skip to content

Commit 340f891

Browse files
LiliDengsquirrelsc
authored andcommitted
Support resource_group_tags for resource group
1 parent 773c59d commit 340f891

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lisa/sut_orchestrator/azure/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,7 @@ def check_or_create_resource_group(
18341834
location: str,
18351835
log: Logger,
18361836
managed_by: str = "",
1837+
resource_group_tags: Optional[Dict[str, str]] = None,
18371838
) -> None:
18381839
with get_resource_management_client(
18391840
credential, subscription_id, cloud
@@ -1845,7 +1846,9 @@ def check_or_create_resource_group(
18451846
if not az_shared_rg_exists:
18461847
log.info(f"Creating Resource group: '{resource_group_name}'")
18471848

1848-
rg_properties = {"location": location}
1849+
rg_properties: Dict[str, Any] = {"location": location}
1850+
if resource_group_tags:
1851+
rg_properties["tags"] = resource_group_tags
18491852
if managed_by:
18501853
log.debug(f"Using managed_by resource group: '{managed_by}'")
18511854
rg_properties["managed_by"] = managed_by

lisa/sut_orchestrator/azure/platform_.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ class AzurePlatformSchema:
279279
# specify shared resource group location
280280
shared_resource_group_location: str = field(default=RESOURCE_GROUP_LOCATION)
281281
resource_group_managed_by: str = field(default="")
282+
resource_group_tags: Optional[Dict[str, str]] = field(default=None)
282283
# specify the locations which used to retrieve marketplace image information
283284
# example: westus, westus2
284285
marketplace_image_information_location: Optional[Union[str, List[str]]] = field(
@@ -627,6 +628,7 @@ def _deploy_environment(self, environment: Environment, log: Logger) -> None:
627628
location=location,
628629
log=log,
629630
managed_by=self.resource_group_managed_by,
631+
resource_group_tags=self._azure_runbook.resource_group_tags,
630632
)
631633
else:
632634
log.info(f"reusing resource group: [{resource_group_name}]")
@@ -957,6 +959,7 @@ def _initialize(self, *args: Any, **kwargs: Any) -> None:
957959
azure_runbook.shared_resource_group_location,
958960
self._log,
959961
azure_runbook.resource_group_managed_by,
962+
azure_runbook.resource_group_tags,
960963
)
961964

962965
self._rm_client = get_resource_management_client(

0 commit comments

Comments
 (0)