How to use _add_azure_core_repo method in lisa

Best Python code snippet using lisa_python

tvmsuite.py

Source:tvmsuite.py Github

copy

Full Screen

...38 ),39 )40 def verify_secureboot_compatibility(self, node: Node) -> None:41 self._is_supported(node)42 self._add_azure_core_repo(node)43 posix_os: Posix = cast(Posix, node.os)44 posix_os.install_packages("azure-security", signed=False)45 cmd_result = node.execute("/usr/local/bin/sbinfo", sudo=True, timeout=1000)46 secure_boot_pattern = re.compile(47 r"(.*\"SBEnforcementStage\": \"Secure Boot (is|is not) enforced\".*)$", re.M48 )49 matched = find_patterns_in_lines(cmd_result.stdout, [secure_boot_pattern])50 if not (matched and matched[0]):51 raise LisaException("This OS image is not compatible with Secure Boot.")52 @TestCaseMetadata(53 description="""54 This case tests the image is compatible with Measured Boot.55 Steps:56 1. Enable repository azurecore from https://packages.microsoft.com/repos.57 2. Install package azure-compatscanner.58 3. Check image Measured Boot compatibility from output of mbinfo.59 """,60 priority=2,61 requirement=simple_requirement(62 supported_features=[SecureBootEnabled()],63 ),64 )65 def verify_measuredboot_compatibility(self, node: Node) -> None:66 self._is_supported(node)67 self._add_azure_core_repo(node)68 posix_os: Posix = cast(Posix, node.os)69 posix_os.install_packages("azure-compatscanner", signed=False)70 node.execute(71 "/usr/bin/mbinfo",72 sudo=True,73 expected_exit_code=0,74 expected_exit_code_failure_message=(75 "This OS image is not compatible with Measured Boot."76 ),77 )78 def _is_supported(self, node: Node) -> None:79 vm_generation = node.tools[VmGeneration].get_generation()80 if "1" == vm_generation:81 raise SkippedException("TVM cases only support generation 2 VM.")82 if (83 (isinstance(node.os, Debian) and node.os.information.version < "11.0.0")84 or (isinstance(node.os, Ubuntu) and node.os.information.version < "18.4.0")85 or (isinstance(node.os, Redhat) and node.os.information.version < "8.3.0")86 or (isinstance(node.os, Suse) and node.os.information.version < "15.2.0")87 ):88 raise SkippedException(89 UnsupportedDistroException(node.os, "TVM doesn't support this version.")90 )91 def _add_azure_core_repo(self, node: Node) -> None:92 if isinstance(node.os, Redhat):93 node.os.add_repository("https://packages.microsoft.com/yumrepos/azurecore/")94 elif isinstance(node.os, Debian):95 if not isinstance(node.os, Ubuntu):96 node.os.install_packages(["gnupg", "software-properties-common"])97 # no azure-compatscanner package in azurecore-debian98 # use azurecore instead99 codename = "bionic"100 repo_url = "http://packages.microsoft.com/repos/azurecore/"101 else:102 # there is no available repo for distro which higher than ubuntu 18.04,103 # use bionic for temp solution104 if node.os.information.version >= "18.4.0":105 codename = "bionic"...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful