зеркало из https://github.com/microsoft/lisa.git
DisableCloudComponents
Transformer to disable cloud-init and walinuxagent so that an exported VHD can boot in a lab environment.
This commit is contained in:
Родитель
518306e21f
Коммит
da43877331
|
@ -62,6 +62,7 @@ if platform.system() == "Linux":
|
|||
except ModuleNotFoundError as e:
|
||||
print(f"libvirt package is not installed. [{e}]")
|
||||
|
||||
import lisa.transformers.disable_cloud_components # noqa: F401
|
||||
import lisa.transformers.dom0_kernel_installer # noqa: F401
|
||||
import lisa.transformers.dump_variables # noqa: F401
|
||||
import lisa.transformers.file_uploader # noqa: F401
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
from dataclasses import dataclass
|
||||
from pathlib import PurePosixPath
|
||||
from typing import Any, Dict, List, Type
|
||||
|
||||
from dataclasses_json import dataclass_json
|
||||
|
||||
from lisa import schema
|
||||
from lisa.operating_system import Posix
|
||||
from lisa.sut_orchestrator.azure.tools import Waagent
|
||||
from lisa.tools import Ls, Sed
|
||||
from lisa.transformers.deployment_transformer import (
|
||||
DeploymentTransformer,
|
||||
DeploymentTransformerSchema,
|
||||
)
|
||||
|
||||
|
||||
@dataclass_json()
|
||||
@dataclass
|
||||
class DisableCloudComponentsTransformerSchema(DeploymentTransformerSchema):
|
||||
pass
|
||||
|
||||
|
||||
class DisableCloudComponentsTransformer(DeploymentTransformer):
|
||||
"""
|
||||
This Transformer prepares a marketplace image for lab testing.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def type_name(cls) -> str:
|
||||
return "disable_cloud_components"
|
||||
|
||||
@classmethod
|
||||
def type_schema(cls) -> Type[schema.TypedSchema]:
|
||||
return DisableCloudComponentsTransformerSchema
|
||||
|
||||
@property
|
||||
def _output_names(self) -> List[str]:
|
||||
return []
|
||||
|
||||
def _internal_run(self) -> Dict[str, Any]:
|
||||
runbook: DisableCloudComponentsTransformerSchema = self.runbook
|
||||
assert isinstance(runbook, DisableCloudComponentsTransformerSchema)
|
||||
node = self._node
|
||||
sed = node.tools[Sed]
|
||||
ls = node.tools[Ls]
|
||||
|
||||
node.tools[Waagent].deprovision()
|
||||
if isinstance(node.os, Posix):
|
||||
node.os.uninstall_packages(["walinuxagent"])
|
||||
|
||||
node.execute("touch /var/lib/waagent/diable_agent", sudo=True)
|
||||
node.execute("touch /var/lib/waagent/provisioned", sudo=True)
|
||||
node.execute("touch /etc/cloud/cloud-init.disabled", sudo=True)
|
||||
|
||||
if ls.path_exists("/etc/netplan/50-cloud-init.yaml"):
|
||||
sed.delete_lines(
|
||||
"macaddress",
|
||||
PurePosixPath("/etc/netplan/50-cloud-init.yaml"),
|
||||
sudo=True,
|
||||
)
|
||||
|
||||
return {}
|
Загрузка…
Ссылка в новой задаче