From c6fe2cb1c4274136d1d36f60b5aa885a15dd7e88 Mon Sep 17 00:00:00 2001 From: llnu Date: Sun, 8 Dec 2019 14:06:15 +0100 Subject: [PATCH] [host] virtualmachine.py refactored from env_vars to config --- ucloud/host/virtualmachine.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ucloud/host/virtualmachine.py b/ucloud/host/virtualmachine.py index 7524083..33e4433 100755 --- a/ucloud/host/virtualmachine.py +++ b/ucloud/host/virtualmachine.py @@ -22,7 +22,7 @@ from ucloud.common.helpers import get_ipv6_address from ucloud.common.request import RequestEntry, RequestType from ucloud.common.vm import VMEntry, VMStatus from ucloud.config import (etcd_client, request_pool, - running_vms, vm_pool, env_vars, + running_vms, vm_pool, config, image_storage_handler) from . import qmp from ucloud.host import logger @@ -46,7 +46,7 @@ def delete_network_interface(iface): def resolve_network(network_name, network_owner): - network = etcd_client.get(join_path(env_vars.get("NETWORK_PREFIX"), + network = etcd_client.get(join_path(config['etcd']["NETWORK_PREFIX"], network_owner, network_name), value_in_json=True) @@ -179,7 +179,7 @@ def get_start_command_args(vm_entry, vnc_sock_filename: str, migration=False, mi for network_mac_and_tap in vm_networks: network_name, mac, tap = network_mac_and_tap - _key = os.path.join(env_vars.get('NETWORK_PREFIX'), vm_entry.owner, network_name) + _key = os.path.join(config['etcd']['NETWORK_PREFIX'], vm_entry.owner, network_name) network = etcd_client.get(_key, value_in_json=True) network_type = network.value["type"] network_id = str(network.value["id"]) @@ -187,7 +187,7 @@ def get_start_command_args(vm_entry, vnc_sock_filename: str, migration=False, mi if network_type == "vxlan": tap = create_vxlan_br_tap(_id=network_id, - _dev=env_vars.get("VXLAN_PHY_DEV"), + _dev=config['etcd']["VXLAN_PHY_DEV"], tap_id=tap, ip=network_ipv6) update_radvd_conf(etcd_client) @@ -303,13 +303,13 @@ def transfer(request_event): _host, _port = request_event.parameters["host"], request_event.parameters["port"] _uuid = request_event.uuid _destination = request_event.destination_host_key - vm = get_vm(running_vms, join_path(env_vars.get('VM_PREFIX'), _uuid)) + vm = get_vm(running_vms, join_path(config['etcd']['VM_PREFIX'], _uuid)) if vm: tunnel = sshtunnel.SSHTunnelForwarder( _host, - ssh_username=env_vars.get("ssh_username"), - ssh_pkey=env_vars.get("ssh_pkey"), + ssh_username=config['ssh']["ssh_username"], + ssh_pkey=config['ssh']["SSH_PRIVATEKEY"], remote_bind_address=("127.0.0.1", _port), ssh_proxy_enabled=True, ssh_proxy=(_host, 22) @@ -373,7 +373,7 @@ def launch_vm(vm_entry, migration=False, migration_port=None, destination_host_k parameters={"host": get_ipv6_address(), "port": migration_port}, uuid=vm_entry.uuid, destination_host_key=destination_host_key, - request_prefix=env_vars.get("REQUEST_PREFIX") + request_prefix=config['etcd']["REQUEST_PREFIX"] ) request_pool.put(r) else: