Fix issues in naming and few other things
This commit is contained in:
parent
f919719b1e
commit
71279a968f
21 changed files with 274 additions and 281 deletions
|
|
@ -1,9 +1,10 @@
|
|||
import argparse
|
||||
import multiprocessing as mp
|
||||
import time
|
||||
import sys
|
||||
|
||||
from etcd3_wrapper import Etcd3Wrapper
|
||||
|
||||
from os.path import isdir
|
||||
from ucloud.common.etcd_wrapper import Etcd3Wrapper
|
||||
from ucloud.common.request import RequestEntry, RequestType
|
||||
from ucloud.config import (vm_pool, request_pool,
|
||||
etcd_client, running_vms,
|
||||
|
|
@ -18,7 +19,7 @@ from ucloud.host import logger
|
|||
def update_heartbeat(hostname):
|
||||
"""Update Last HeartBeat Time for :param hostname: in etcd"""
|
||||
client = Etcd3Wrapper(*etcd_wrapper_args, **etcd_wrapper_kwargs)
|
||||
host_pool = HostPool(client, config['etcd']['HOST_PREFIX'])
|
||||
host_pool = HostPool(client, config['etcd']['host_prefix'])
|
||||
this_host = next(filter(lambda h: h.hostname == hostname, host_pool.hosts), None)
|
||||
|
||||
while True:
|
||||
|
|
@ -72,9 +73,11 @@ def maintenance(host):
|
|||
running_vms.remove(_vm)
|
||||
|
||||
def check():
|
||||
if config['etcd']['STORAGE_BACKEND'] == 'filesystem' and not isdir(config['etcd']['VM_DIR']):
|
||||
if config['storage']['backend'] == 'filesystem' and \
|
||||
not isdir(config['storage']['vm_dir']):
|
||||
|
||||
print("You have set STORAGE_BACKEND to filesystem. So, the vm directory mentioned"
|
||||
" in .env file must exists. But, it don't.")
|
||||
" in /etc/ucloud/ucloud.conf file must exists. But, it don't.")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
|
@ -84,7 +87,7 @@ def main(hostname):
|
|||
|
||||
heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(hostname,))
|
||||
|
||||
host_pool = HostPool(etcd_client, config['etcd']['HOST_PREFIX'])
|
||||
host_pool = HostPool(etcd_client, config['etcd']['host_prefix'])
|
||||
host = next(filter(lambda h: h.hostname == hostname, host_pool.hosts), None)
|
||||
assert host is not None, "No such host with name = {}".format(hostname)
|
||||
|
||||
|
|
@ -106,8 +109,8 @@ def main(hostname):
|
|||
# beat updating mechanism in separated thread
|
||||
|
||||
for events_iterator in [
|
||||
etcd_client.get_prefix(config['etcd']['REQUEST_PREFIX'], value_in_json=True),
|
||||
etcd_client.watch_prefix(config['etcd']['REQUEST_PREFIX'], timeout=10, value_in_json=True),
|
||||
etcd_client.get_prefix(config['etcd']['request_prefix'], value_in_json=True),
|
||||
etcd_client.watch_prefix(config['etcd']['request_prefix'], timeout=10, value_in_json=True),
|
||||
]:
|
||||
for request_event in events_iterator:
|
||||
request_event = RequestEntry(request_event)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ def delete_network_interface(iface):
|
|||
|
||||
|
||||
def resolve_network(network_name, network_owner):
|
||||
network = etcd_client.get(join_path(config['etcd']["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(config['etcd']['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=config['etcd']["VXLAN_PHY_DEV"],
|
||||
_dev=config['network']['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(config['etcd']['VM_PREFIX'], _uuid))
|
||||
vm = get_vm(running_vms, join_path(config['etcd']['vm_prefix'], _uuid))
|
||||
|
||||
if vm:
|
||||
tunnel = sshtunnel.SSHTunnelForwarder(
|
||||
_host,
|
||||
ssh_username=config['ssh']["ssh_username"],
|
||||
ssh_pkey=config['ssh']["SSH_PRIVATEKEY"],
|
||||
ssh_username=config['ssh']['username'],
|
||||
ssh_pkey=config['ssh']['private_key_path'],
|
||||
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=config['etcd']["REQUEST_PREFIX"]
|
||||
request_prefix=config['etcd']['request_prefix']
|
||||
)
|
||||
request_pool.put(r)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue