From 433a3b9817842113e5d0d5e027ab7517283b12e8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 31 Dec 2019 11:30:02 +0100 Subject: [PATCH] refactor #2 Signed-off-by: Nico Schottelius --- setup.py | 6 +++--- uncloud/api/common_fields.py | 4 ++-- uncloud/api/create_image_store.py | 4 ++-- uncloud/api/helper.py | 4 ++-- uncloud/api/main.py | 10 +++++----- uncloud/api/schemas.py | 10 +++++----- uncloud/common/host.py | 2 +- uncloud/common/storage_handlers.py | 2 +- uncloud/configure/main.py | 4 ++-- uncloud/docs/source/conf.py | 2 +- uncloud/filescanner/main.py | 4 ++-- uncloud/host/main.py | 12 ++++++------ uncloud/host/virtualmachine.py | 16 ++++++++-------- uncloud/imagescanner/main.py | 6 +++--- uncloud/metadata/main.py | 4 ++-- uncloud/scheduler/helper.py | 10 +++++----- uncloud/scheduler/main.py | 6 +++--- uncloud/scheduler/tests/test_basics.py | 2 +- uncloud/settings/__init__.py | 10 +++++----- uncloud/shared/__init__.py | 10 +++++----- uncloud/vmm/__init__.py | 2 +- 21 files changed, 65 insertions(+), 65 deletions(-) diff --git a/setup.py b/setup.py index 3cf10a0..b204f93 100644 --- a/setup.py +++ b/setup.py @@ -17,10 +17,10 @@ except: setup( - name="ucloud", + name="uncloud", version=version, - description="All ucloud server components.", - url="https://code.ungleich.ch/ucloud/ucloud", + description="uncloud cloud management", + url="https://code.ungleich.ch/uncloud/uncloud", long_description=long_description, long_description_content_type="text/markdown", classifiers=[ diff --git a/uncloud/api/common_fields.py b/uncloud/api/common_fields.py index 93f9e06..8bcf777 100755 --- a/uncloud/api/common_fields.py +++ b/uncloud/api/common_fields.py @@ -1,7 +1,7 @@ import os -from ucloud.shared import shared -from ucloud.settings import settings +from uncloud.shared import shared +from uncloud.settings import settings class Optional: diff --git a/uncloud/api/create_image_store.py b/uncloud/api/create_image_store.py index a433ce3..73b92f1 100755 --- a/uncloud/api/create_image_store.py +++ b/uncloud/api/create_image_store.py @@ -3,8 +3,8 @@ import os from uuid import uuid4 -from ucloud.shared import shared -from ucloud.settings import settings +from uncloud.shared import shared +from uncloud.settings import settings data = { "is_public": True, diff --git a/uncloud/api/helper.py b/uncloud/api/helper.py index 6fdeb30..c806814 100755 --- a/uncloud/api/helper.py +++ b/uncloud/api/helper.py @@ -7,8 +7,8 @@ import requests from pyotp import TOTP -from ucloud.shared import shared -from ucloud.settings import settings +from uncloud.shared import shared +from uncloud.settings import settings logger = logging.getLogger(__name__) diff --git a/uncloud/api/main.py b/uncloud/api/main.py index 85133df..6ac5d44 100644 --- a/uncloud/api/main.py +++ b/uncloud/api/main.py @@ -9,11 +9,11 @@ from flask import Flask, request from flask_restful import Resource, Api from werkzeug.exceptions import HTTPException -from ucloud.common import counters -from ucloud.common.vm import VMStatus -from ucloud.common.request import RequestEntry, RequestType -from ucloud.settings import settings -from ucloud.shared import shared +from uncloud.common import counters +from uncloud.common.vm import VMStatus +from uncloud.common.request import RequestEntry, RequestType +from uncloud.settings import settings +from uncloud.shared import shared from . import schemas from .helper import generate_mac, mac2ipv6 diff --git a/uncloud/api/schemas.py b/uncloud/api/schemas.py index 91289b0..65055c4 100755 --- a/uncloud/api/schemas.py +++ b/uncloud/api/schemas.py @@ -1,6 +1,6 @@ """ This module contain classes thats validates and intercept/modify -data coming from ucloud-cli (user) +data coming from uncloud-cli (user) It was primarily developed as an alternative to argument parser of Flask_Restful which is going to be deprecated. I also tried @@ -19,10 +19,10 @@ import os import bitmath -from ucloud.common.host import HostStatus -from ucloud.common.vm import VMStatus -from ucloud.shared import shared -from ucloud.settings import settings +from uncloud.common.host import HostStatus +from uncloud.common.vm import VMStatus +from uncloud.shared import shared +from uncloud.settings import settings from . import helper, logger from .common_fields import Field, VmUUIDField from .helper import check_otp, resolve_vm_name diff --git a/uncloud/common/host.py b/uncloud/common/host.py index 01e2091..f7bb7d5 100644 --- a/uncloud/common/host.py +++ b/uncloud/common/host.py @@ -7,7 +7,7 @@ from .classes import SpecificEtcdEntryBase class HostStatus: - """Possible Statuses of ucloud host.""" + """Possible Statuses of uncloud host.""" alive = "ALIVE" dead = "DEAD" diff --git a/uncloud/common/storage_handlers.py b/uncloud/common/storage_handlers.py index b337f23..06751c4 100644 --- a/uncloud/common/storage_handlers.py +++ b/uncloud/common/storage_handlers.py @@ -7,7 +7,7 @@ from abc import ABC from . import logger from os.path import join as join_path -from ucloud.settings import settings as config +from uncloud.settings import settings as config class ImageStorageHandler(ABC): diff --git a/uncloud/configure/main.py b/uncloud/configure/main.py index 31201f6..a9b4901 100644 --- a/uncloud/configure/main.py +++ b/uncloud/configure/main.py @@ -1,7 +1,7 @@ import os -from ucloud.settings import settings -from ucloud.shared import shared +from uncloud.settings import settings +from uncloud.shared import shared def update_config(section, kwargs): diff --git a/uncloud/docs/source/conf.py b/uncloud/docs/source/conf.py index 70307f8..c8138a7 100644 --- a/uncloud/docs/source/conf.py +++ b/uncloud/docs/source/conf.py @@ -17,7 +17,7 @@ # -- Project information ----------------------------------------------------- -project = "ucloud" +project = "uncloud" copyright = "2019, ungleich" author = "ungleich" diff --git a/uncloud/filescanner/main.py b/uncloud/filescanner/main.py index b12797b..7ce8654 100755 --- a/uncloud/filescanner/main.py +++ b/uncloud/filescanner/main.py @@ -7,8 +7,8 @@ import time from uuid import uuid4 from . import logger -from ucloud.settings import settings -from ucloud.shared import shared +from uncloud.settings import settings +from uncloud.shared import shared def sha512sum(file: str): diff --git a/uncloud/host/main.py b/uncloud/host/main.py index ed734b5..80527c9 100755 --- a/uncloud/host/main.py +++ b/uncloud/host/main.py @@ -2,11 +2,11 @@ import argparse import multiprocessing as mp import time -from ucloud.common.request import RequestEntry, RequestType -from ucloud.shared import shared -from ucloud.settings import settings -from ucloud.common.vm import VMStatus -from ucloud.vmm import VMM +from uncloud.common.request import RequestEntry, RequestType +from uncloud.shared import shared +from uncloud.settings import settings +from uncloud.common.vm import VMStatus +from uncloud.vmm import VMM from os.path import join as join_path from . import virtualmachine, logger @@ -48,7 +48,7 @@ def main(hostname): heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(hostname,)) heartbeat_updating_process.start() except Exception as e: - raise Exception("ucloud-host heartbeat updating mechanism is not working") from e + raise Exception("uncloud-host heartbeat updating mechanism is not working") from e for events_iterator in [ shared.etcd_client.get_prefix(settings["etcd"]["request_prefix"], value_in_json=True), diff --git a/uncloud/host/virtualmachine.py b/uncloud/host/virtualmachine.py index 8f6c79e..0bd20bf 100755 --- a/uncloud/host/virtualmachine.py +++ b/uncloud/host/virtualmachine.py @@ -11,14 +11,14 @@ import ipaddress from string import Template from os.path import join as join_path -from ucloud.common.request import RequestEntry, RequestType -from ucloud.common.vm import VMStatus, declare_stopped -from ucloud.common.network import create_dev, delete_network_interface -from ucloud.common.schemas import VMSchema, NetworkSchema -from ucloud.host import logger -from ucloud.shared import shared -from ucloud.settings import settings -from ucloud.vmm import VMM +from uncloud.common.request import RequestEntry, RequestType +from uncloud.common.vm import VMStatus, declare_stopped +from uncloud.common.network import create_dev, delete_network_interface +from uncloud.common.schemas import VMSchema, NetworkSchema +from uncloud.host import logger +from uncloud.shared import shared +from uncloud.settings import settings +from uncloud.vmm import VMM from marshmallow import ValidationError diff --git a/uncloud/imagescanner/main.py b/uncloud/imagescanner/main.py index e1960bc..93e4dd5 100755 --- a/uncloud/imagescanner/main.py +++ b/uncloud/imagescanner/main.py @@ -3,9 +3,9 @@ import os import subprocess as sp from os.path import join as join_path -from ucloud.settings import settings -from ucloud.shared import shared -from ucloud.imagescanner import logger +from uncloud.settings import settings +from uncloud.shared import shared +from uncloud.imagescanner import logger def qemu_img_type(path): diff --git a/uncloud/metadata/main.py b/uncloud/metadata/main.py index 2974e33..da993ae 100644 --- a/uncloud/metadata/main.py +++ b/uncloud/metadata/main.py @@ -4,8 +4,8 @@ from flask import Flask, request from flask_restful import Resource, Api from werkzeug.exceptions import HTTPException -from ucloud.settings import settings -from ucloud.shared import shared +from uncloud.settings import settings +from uncloud.shared import shared app = Flask(__name__) api = Api(app) diff --git a/uncloud/scheduler/helper.py b/uncloud/scheduler/helper.py index 2fb7a22..7edf623 100755 --- a/uncloud/scheduler/helper.py +++ b/uncloud/scheduler/helper.py @@ -3,11 +3,11 @@ from functools import reduce import bitmath -from ucloud.common.host import HostStatus -from ucloud.common.request import RequestEntry, RequestType -from ucloud.common.vm import VMStatus -from ucloud.shared import shared -from ucloud.settings import settings +from uncloud.common.host import HostStatus +from uncloud.common.request import RequestEntry, RequestType +from uncloud.common.vm import VMStatus +from uncloud.shared import shared +from uncloud.settings import settings def accumulated_specs(vms_specs): diff --git a/uncloud/scheduler/main.py b/uncloud/scheduler/main.py index d64017a..5a4014f 100755 --- a/uncloud/scheduler/main.py +++ b/uncloud/scheduler/main.py @@ -4,9 +4,9 @@ # 2. Introduce a status endpoint of the scheduler - # maybe expose a prometheus compatible output -from ucloud.common.request import RequestEntry, RequestType -from ucloud.shared import shared -from ucloud.settings import settings +from uncloud.common.request import RequestEntry, RequestType +from uncloud.shared import shared +from uncloud.settings import settings from .helper import ( dead_host_mitigation, dead_host_detection, diff --git a/uncloud/scheduler/tests/test_basics.py b/uncloud/scheduler/tests/test_basics.py index 68bd8ec..defeb23 100755 --- a/uncloud/scheduler/tests/test_basics.py +++ b/uncloud/scheduler/tests/test_basics.py @@ -15,7 +15,7 @@ from main import ( main, ) -from ucloud.config import etcd_client +from uncloud.config import etcd_client class TestFunctions(unittest.TestCase): diff --git a/uncloud/settings/__init__.py b/uncloud/settings/__init__.py index 906e857..90b938c 100644 --- a/uncloud/settings/__init__.py +++ b/uncloud/settings/__init__.py @@ -3,7 +3,7 @@ import logging import sys import os -from ucloud.common.etcd_wrapper import Etcd3Wrapper +from uncloud.common.etcd_wrapper import Etcd3Wrapper logger = logging.getLogger(__name__) @@ -14,7 +14,7 @@ class CustomConfigParser(configparser.RawConfigParser): result = super().__getitem__(key) except KeyError as err: raise KeyError( - "Key '{}' not found in configuration. Make sure you configure ucloud.".format( + "Key '{}' not found in configuration. Make sure you configure uncloud.".format( key ) ) from err @@ -24,9 +24,9 @@ class CustomConfigParser(configparser.RawConfigParser): class Settings(object): def __init__(self, config_key="/uncloud/config/"): - conf_name = "ucloud.conf" + conf_name = "uncloud.conf" conf_dir = os.environ.get( - "UCLOUD_CONF_DIR", os.path.expanduser("~/ucloud/") + "UCLOUD_CONF_DIR", os.path.expanduser("~/uncloud/") ) self.config_file = os.path.join(conf_dir, conf_name) @@ -109,7 +109,7 @@ class Settings(object): self.config_parser.read_dict(config_from_etcd.value) else: raise KeyError( - "Key '{}' not found in etcd. Please configure ucloud.".format( + "Key '{}' not found in etcd. Please configure uncloud.".format( self.config_key ) ) diff --git a/uncloud/shared/__init__.py b/uncloud/shared/__init__.py index 294e34a..db2093f 100644 --- a/uncloud/shared/__init__.py +++ b/uncloud/shared/__init__.py @@ -1,8 +1,8 @@ -from ucloud.settings import settings -from ucloud.common.vm import VmPool -from ucloud.common.host import HostPool -from ucloud.common.request import RequestPool -from ucloud.common.storage_handlers import get_storage_handler +from uncloud.settings import settings +from uncloud.common.vm import VmPool +from uncloud.common.host import HostPool +from uncloud.common.request import RequestPool +from uncloud.common.storage_handlers import get_storage_handler class Shared: diff --git a/uncloud/vmm/__init__.py b/uncloud/vmm/__init__.py index 4a7fc2f..6cdd938 100644 --- a/uncloud/vmm/__init__.py +++ b/uncloud/vmm/__init__.py @@ -102,7 +102,7 @@ class VMM: def __init__( self, qemu_path="/usr/bin/qemu-system-x86_64", - vmm_backend=os.path.expanduser("~/ucloud/vmm/"), + vmm_backend=os.path.expanduser("~/uncloud/vmm/"), ): self.qemu_path = qemu_path self.vmm_backend = vmm_backend