зеркало из https://github.com/microsoft/lisa.git
Pylint: Enable eval-used
This commit is contained in:
Родитель
a3120fc015
Коммит
e3a962b3b9
|
@ -553,8 +553,7 @@ class Infiniband(AzureFeatureMixin, features.Infiniband):
|
|||
) -> Optional[schema.FeatureSettings]:
|
||||
raw_capabilities: Any = kwargs.get("raw_capabilities")
|
||||
|
||||
value = raw_capabilities.get("RdmaEnabled", None)
|
||||
if value and eval(value) is True:
|
||||
if raw_capabilities.get("RdmaEnabled", None) == "True":
|
||||
return schema.FeatureSettings.create(cls.name())
|
||||
|
||||
return None
|
||||
|
@ -1495,8 +1494,7 @@ class Hibernation(AzureFeatureMixin, features.Hibernation):
|
|||
) -> Optional[schema.FeatureSettings]:
|
||||
raw_capabilities: Any = kwargs.get("raw_capabilities")
|
||||
|
||||
value = raw_capabilities.get("HibernationSupported", None)
|
||||
if value and eval(value) is True:
|
||||
if raw_capabilities.get("HibernationSupported", None) == "True":
|
||||
return schema.FeatureSettings.create(cls.name())
|
||||
|
||||
return None
|
||||
|
@ -1552,8 +1550,11 @@ class SecurityProfile(AzureFeatureMixin, features.SecurityProfile):
|
|||
"standardMSv2Family",
|
||||
]:
|
||||
# https://learn.microsoft.com/en-us/azure/virtual-machines/trusted-launch#how-can-i-find-vm-sizes-that-support-trusted-launch # noqa: E501
|
||||
tvm_disable_value = raw_capabilities.get("TrustedLaunchDisabled", "False")
|
||||
if gen_value and ("V2" in str(gen_value)) and (not eval(tvm_disable_value)):
|
||||
if (
|
||||
gen_value
|
||||
and ("V2" in str(gen_value))
|
||||
and raw_capabilities.get("TrustedLaunchDisabled", "False") == "False"
|
||||
):
|
||||
capabilities.append(SecurityProfileType.SecureBoot)
|
||||
# https://learn.microsoft.com/en-us/azure/confidential-computing/confidential-vm-overview # noqa: E501
|
||||
if cvm_value and resource_sku.family in [
|
||||
|
|
|
@ -1527,14 +1527,10 @@ class AzurePlatform(Platform):
|
|||
)
|
||||
node_space.network_interface.max_nic_count = sku_nic_count
|
||||
|
||||
premium_io_supported = azure_raw_capabilities.get("PremiumIO", None)
|
||||
if premium_io_supported and eval(premium_io_supported) is True:
|
||||
if azure_raw_capabilities.get("PremiumIO", None) == "True":
|
||||
node_space.disk.disk_type.add(schema.DiskType.PremiumSSDLRS)
|
||||
|
||||
ephemeral_supported = azure_raw_capabilities.get(
|
||||
"EphemeralOSDiskSupported", None
|
||||
)
|
||||
if ephemeral_supported and eval(ephemeral_supported) is True:
|
||||
if azure_raw_capabilities.get("EphemeralOSDiskSupported", None) == "True":
|
||||
# Check if CachedDiskBytes is greater than 30GB
|
||||
# We use diff disk as cache disk for ephemeral OS disk
|
||||
cached_disk_bytes = azure_raw_capabilities.get("CachedDiskBytes", 0)
|
||||
|
@ -1543,8 +1539,7 @@ class AzurePlatform(Platform):
|
|||
node_space.disk.disk_type.add(schema.DiskType.Ephemeral)
|
||||
|
||||
# set AN
|
||||
an_enabled = azure_raw_capabilities.get("AcceleratedNetworkingEnabled", None)
|
||||
if an_enabled and eval(an_enabled) is True:
|
||||
if azure_raw_capabilities.get("AcceleratedNetworkingEnabled", None) == "True":
|
||||
# refer
|
||||
# https://docs.microsoft.com/en-us/azure/virtual-machines/dcv2-series#configuration
|
||||
# https://docs.microsoft.com/en-us/azure/virtual-machines/ncv2-series
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List, Type
|
||||
|
||||
import simpleeval # type: ignore
|
||||
from dataclasses_json import dataclass_json
|
||||
|
||||
from lisa import LisaException, schema
|
||||
|
@ -56,19 +57,31 @@ class ScriptTransformer(Transformer):
|
|||
runbook: ScriptTransformerSchema = self.runbook
|
||||
result: Dict[str, Any] = {}
|
||||
for item in runbook.scripts:
|
||||
variables: Dict[str, Any] = {}
|
||||
for key in item.variables:
|
||||
variables[key] = self._runbook_builder.variables[key].data
|
||||
variables: Dict[str, Any] = {
|
||||
key: self._runbook_builder.variables[key].data for key in item.variables
|
||||
}
|
||||
|
||||
evaluator = simpleeval.SimpleEval(
|
||||
# Update ex: DEFAULT_OPERATORS | {ast.BitXor, operator.xor}
|
||||
operators=simpleeval.DEFAULT_OPERATORS | {},
|
||||
# Update ex: DEFAULT_FUNCTIONS | {'floor': math.floor}
|
||||
functions=simpleeval.DEFAULT_FUNCTIONS | {},
|
||||
names=simpleeval.DEFAULT_NAMES | variables,
|
||||
)
|
||||
|
||||
try:
|
||||
eval_result = eval(item.script, variables.copy())
|
||||
except Exception as identifier:
|
||||
result[item.name] = evaluator.eval(item.script)
|
||||
|
||||
except simpleeval.InvalidExpression as e:
|
||||
raise LisaException(
|
||||
f"'{item.script}' failed, variables: {variables}. {identifier}"
|
||||
)
|
||||
result[item.name] = eval_result
|
||||
f"'{item.script}' failed, variables: {variables}. {e}"
|
||||
) from e
|
||||
|
||||
self._log.debug(
|
||||
f"script: '{item.script}', variables: {variables}, "
|
||||
f"result: {eval_result}"
|
||||
"script: '%s', variables: %s, result: '%s'",
|
||||
item.script,
|
||||
variables,
|
||||
result[item.name],
|
||||
)
|
||||
|
||||
return result
|
||||
|
|
1
pylintrc
1
pylintrc
|
@ -32,7 +32,6 @@ disable=
|
|||
abstract-method,
|
||||
broad-except,
|
||||
cyclic-import,
|
||||
eval-used,
|
||||
expression-not-assigned,
|
||||
keyword-arg-before-vararg,
|
||||
modified-iterating-list,
|
||||
|
|
|
@ -23,6 +23,7 @@ dependencies = [
|
|||
"randmac ~= 0.1",
|
||||
"retry ~= 0.9.2",
|
||||
"semver ~= 2.13.0",
|
||||
"simpleeval ~= 0.9.12",
|
||||
"spurplus ~= 2.3.4",
|
||||
"websockets ~= 10.3",
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче