set value for nodes_raw to avoid regression issue

This commit is contained in:
Lili Deng 2022-10-21 17:46:59 +08:00 коммит произвёл LiliDeng
Родитель 5fe45ee266
Коммит 677dce19fd
2 изменённых файлов: 5 добавлений и 1 удалений

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

@ -1155,6 +1155,8 @@ class Environment:
if self.nodes_raw: if self.nodes_raw:
for node_raw in self.nodes_raw: for node_raw in self.nodes_raw:
if not isinstance(node_raw, dict):
node_raw = node_raw.to_dict()
node_type = node_raw[constants.TYPE] node_type = node_raw[constants.TYPE]
if node_type == constants.ENVIRONMENTS_NODES_REQUIREMENT: if node_type == constants.ENVIRONMENTS_NODES_REQUIREMENT:
original_req: NodeSpace = load_by_type(NodeSpace, node_raw) original_req: NodeSpace = load_by_type(NodeSpace, node_raw)

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

@ -1042,12 +1042,14 @@ def load_environment(
# create mock environment from environments # create mock environment from environments
environment_runbook = schema.Environment() environment_runbook = schema.Environment()
if environment_runbook.nodes_raw is None:
environment_runbook.nodes_raw = []
compute_client = get_compute_client(platform) compute_client = get_compute_client(platform)
vms = compute_client.virtual_machines.list(resource_group_name) vms = compute_client.virtual_machines.list(resource_group_name)
for vm in vms: for vm in vms:
node_schema = schema.RemoteNode(name=vm.name) node_schema = schema.RemoteNode(name=vm.name)
environment_runbook.nodes.append(node_schema) environment_runbook.nodes_raw.append(node_schema)
environments = load_environments( environments = load_environments(
schema.EnvironmentRoot(environments=[environment_runbook]) schema.EnvironmentRoot(environments=[environment_runbook])