Delete AMA extension at start in case its already installed (#3285)

* Update AzureMonitorAgentLinux.py

* Update AzureMonitorAgentLinux.py

* Update AzureMonitorAgentLinux.py

* Update AzureMonitorAgentLinux.py

* Update AzureMonitorAgentLinux.py

* fix indent

* fix indent
This commit is contained in:
Siddhartha Mathiharan 2024-04-29 18:35:28 -07:00 коммит произвёл GitHub
Родитель 7820764c99
Коммит 788bbe624d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 8 добавлений и 0 удалений

Просмотреть файл

@ -1,6 +1,7 @@
from typing import Any from typing import Any
from assertpy import assert_that from assertpy import assert_that
from azure.core.exceptions import HttpResponseError
from lisa import ( from lisa import (
Logger, Logger,
@ -52,6 +53,13 @@ class AzureMonitorAgentLinuxExtension(TestSuite):
# Run VM Extension # Run VM Extension
extension = node.features[AzureExtension] extension = node.features[AzureExtension]
try:
# Delete VM Extension if already present
extension.delete("AzureMonitorLinuxAgent")
except HttpResponseError as identifier:
if any(s in str(identifier) for s in ["was not found"]):
log.info("AzureMonitorLinuxAgent is not already installed")
extension_result = extension.create_or_update( extension_result = extension.create_or_update(
name="AzureMonitorLinuxAgent", name="AzureMonitorLinuxAgent",
publisher="Microsoft.Azure.Monitor", publisher="Microsoft.Azure.Monitor",