Skip to content

Commit 55187ca

Browse files
kamalcaLiliDeng
authored andcommitted
Add hook azure_update_vm_capabilities
Add hook `azure_update_vm_capabilities` to allow editing of Azure VM SKU capabilities before being saved to cache. This will allow capability information to be inserted by extensions for internal SKUs or the processing of additional SKU information such as disk and network performance. Alternatively, SKUs can be removed from the results to restrict the SKUs that LISA will deploy.
1 parent 191b80d commit 55187ca

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lisa/sut_orchestrator/azure/hooks.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import re
22
from functools import partial
3-
from typing import Any, List, Pattern, Tuple
3+
from typing import Any, Dict, List, Pattern, Tuple
44

55
from lisa.environment import Environment
6+
from lisa.sut_orchestrator.azure.common import AzureCapability
67
from lisa.util import (
78
ResourceAwaitableException,
89
SkippedException,
@@ -34,6 +35,19 @@ def azure_update_arm_template(
3435
"""
3536
...
3637

38+
@hookspec
39+
def azure_update_vm_capabilities(
40+
self, capabilities: Dict[str, AzureCapability]
41+
) -> None:
42+
"""
43+
Implement it to update the vm capabilities.
44+
45+
Args:
46+
capabilities: the dict object mapping VM SKU name to Azure capability,
47+
which is compiled from the output of _resource_sku_to_capability()
48+
"""
49+
...
50+
3751

3852
class AzureHookSpecDefaultImpl:
3953
__error_maps: List[Tuple[str, Pattern[str], Any]] = [

lisa/sut_orchestrator/azure/platform_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,7 @@ def get_location_info(self, location: str, log: Logger) -> AzureLocation:
11111111
except Exception as e:
11121112
log.error(f"unknown sku: {sku_obj}")
11131113
raise e
1114+
plugin_manager.hook.azure_update_vm_capabilities(capabilities=all_skus)
11141115
location_data = AzureLocation(location=location, capabilities=all_skus)
11151116
log.debug(f"{location}: saving to disk")
11161117
with open(cached_file_name, "w") as f:

0 commit comments

Comments
 (0)