Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions lisa/sut_orchestrator/azure/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,23 @@ def marketplace(self) -> Optional[AzureVmMarketplaceSchema]:
self.marketplace_raw = self.marketplace_raw.strip()

if self.marketplace_raw:
# Extract security_profile if present in brackets [profile1,profile2]
security_profile_match = re.search(r"\[(.*?)\]$", self.marketplace_raw)
security_profile_str = None
marketplace_base = self.marketplace_raw
Comment on lines +769 to +771
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you instead use one of the utility methods in lisa/lisa/util/init.py, like find_patterns_in_lines, get_matched_str


if security_profile_match:
security_profile_str = security_profile_match.group(1)
# Remove the security_profile part from the string
marketplace_base = self.marketplace_raw[
: security_profile_match.start()
].strip()

# Users decide the cases of image names,
# the inconsistent cases cause the mismatched error in notifiers.
# The lower() normalizes the image names,
# it has no impact on deployment.
marketplace_strings = re.split(r"[:\s]+", self.marketplace_raw.lower())
marketplace_strings = re.split(r"[:\s]+", marketplace_base.lower())

if len(marketplace_strings) == 4:
marketplace = AzureVmMarketplaceSchema(
Expand All @@ -778,6 +790,27 @@ def marketplace(self) -> Optional[AzureVmMarketplaceSchema]:
sku=marketplace_strings[2],
version=marketplace_strings[3],
)

# Parse security_profile if present
if security_profile_str:
# Split by comma and strip whitespace
profile_list = [
p.strip().lower() for p in security_profile_str.split(",")
]
# Convert to SecurityProfileType enum
security_profiles = []
for profile in profile_list:
try:
security_profiles.append(SecurityProfileType(profile))
except ValueError:
raise LisaException(
f"Invalid security_profile value: '{profile}'. "
f"Valid values: secureboot, cvm, stateless, none"
)
marketplace.security_profile = search_space.SetSpace(
is_allow_set=True, items=security_profiles
)

# marketplace_raw is used
self.marketplace_raw = marketplace.to_dict()
else:
Expand All @@ -786,7 +819,8 @@ def marketplace(self) -> Optional[AzureVmMarketplaceSchema]:
f"parameter: '{self.marketplace_raw}'."
f"The marketplace parameter should be in the format: "
f"'<Publisher> <Offer> <Sku> <Version>' "
f"or '<Publisher>:<Offer>:<Sku>:<Version>'"
f"or '<Publisher>:<Offer>:<Sku>:<Version>' "
f"or '<Publisher> <Offer> <Sku> <Version> [Profile1,Profile2]'"
)
Comment on lines +822 to 824
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new pattern for images in Azure?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are in discussion about this method. Maybe this PR will be abondoned

self._marketplace = marketplace
return (
Expand Down
Loading