Skip to content

Commit

Permalink
RunCommandv1: uninstall extension before installing it
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliDeng committed Nov 25, 2024
1 parent 630122e commit bd80ec8
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from azure.core.exceptions import HttpResponseError

from lisa import (
LisaException,
Logger,
Node,
TestCaseMetadata,
Expand Down Expand Up @@ -37,10 +38,22 @@ def _create_and_verify_extension_run(
assert_exception: Optional[Any] = None,
) -> None:
extension = node.features[AzureExtension]
extension_name = "RunCommandv1"
try:
# Delete VM Extension if already present
extension.delete(extension_name)
except HttpResponseError as identifier:
if any(s in str(identifier) for s in ["was not found"]):
node.log.info(f"{extension_name} is not installed")
else:
raise LisaException(
f"unexpected exception happened {identifier} during delete"
f" extension {extension_name}"
) from identifier

def enable_extension() -> Any:
result = extension.create_or_update(
name="RunCommandv1",
name=extension_name,
publisher="Microsoft.CPlat.Core",
type_="RunCommandLinux",
type_handler_version="1.0",
Expand Down

0 comments on commit bd80ec8

Please sign in to comment.