From 6086fec633d6f368f574215631e8449c374b78dd Mon Sep 17 00:00:00 2001 From: meow Date: Mon, 6 Jan 2020 12:25:59 +0500 Subject: [PATCH] move settings under uncloud.common --- uncloud/api/common_fields.py | 2 +- uncloud/api/create_image_store.py | 2 +- uncloud/api/helper.py | 2 +- uncloud/api/main.py | 2 +- uncloud/api/schemas.py | 2 +- uncloud/cli/helper.py | 2 +- uncloud/common/network.py | 2 -- uncloud/{settings/__init__.py => common/settings.py} | 0 uncloud/common/storage_handlers.py | 2 +- uncloud/configure/main.py | 2 +- uncloud/docs/README.md | 12 ++++++++++++ uncloud/filescanner/main.py | 2 +- uncloud/host/main.py | 2 +- uncloud/host/virtualmachine.py | 2 +- uncloud/imagescanner/main.py | 2 +- uncloud/metadata/main.py | 2 +- uncloud/scheduler/helper.py | 2 +- uncloud/scheduler/main.py | 2 +- uncloud/shared/__init__.py | 2 +- 19 files changed, 28 insertions(+), 18 deletions(-) rename uncloud/{settings/__init__.py => common/settings.py} (100%) create mode 100644 uncloud/docs/README.md diff --git a/uncloud/api/common_fields.py b/uncloud/api/common_fields.py index 8bcf777..adf7cdc 100755 --- a/uncloud/api/common_fields.py +++ b/uncloud/api/common_fields.py @@ -1,7 +1,7 @@ import os from uncloud.shared import shared -from uncloud.settings import settings +from uncloud.common.settings import settings class Optional: diff --git a/uncloud/api/create_image_store.py b/uncloud/api/create_image_store.py index 9259be6..075f26f 100755 --- a/uncloud/api/create_image_store.py +++ b/uncloud/api/create_image_store.py @@ -4,7 +4,7 @@ import os from uuid import uuid4 from uncloud.shared import shared -from uncloud.settings import settings +from uncloud.common.settings import settings data = { 'is_public': True, diff --git a/uncloud/api/helper.py b/uncloud/api/helper.py index c806814..0e5fa19 100755 --- a/uncloud/api/helper.py +++ b/uncloud/api/helper.py @@ -8,7 +8,7 @@ import requests from pyotp import TOTP from uncloud.shared import shared -from uncloud.settings import settings +from uncloud.common.settings import settings logger = logging.getLogger(__name__) diff --git a/uncloud/api/main.py b/uncloud/api/main.py index 84eb28a..401c11f 100644 --- a/uncloud/api/main.py +++ b/uncloud/api/main.py @@ -13,7 +13,7 @@ from werkzeug.exceptions import HTTPException 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.common.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 8e06e8d..f606803 100755 --- a/uncloud/api/schemas.py +++ b/uncloud/api/schemas.py @@ -22,7 +22,7 @@ import bitmath from uncloud.common.host import HostStatus from uncloud.common.vm import VMStatus from uncloud.shared import shared -from uncloud.settings import settings +from uncloud.common.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/cli/helper.py b/uncloud/cli/helper.py index bdcce78..0495fac 100644 --- a/uncloud/cli/helper.py +++ b/uncloud/cli/helper.py @@ -5,7 +5,7 @@ import binascii from pyotp import TOTP from os.path import join as join_path -from uncloud.settings import settings +from uncloud.common.settings import settings def get_otp_parser(): diff --git a/uncloud/common/network.py b/uncloud/common/network.py index adba108..32f6951 100644 --- a/uncloud/common/network.py +++ b/uncloud/common/network.py @@ -1,8 +1,6 @@ import subprocess as sp import random import logging -import socket -from contextlib import closing logger = logging.getLogger(__name__) diff --git a/uncloud/settings/__init__.py b/uncloud/common/settings.py similarity index 100% rename from uncloud/settings/__init__.py rename to uncloud/common/settings.py diff --git a/uncloud/common/storage_handlers.py b/uncloud/common/storage_handlers.py index 06751c4..6f9b29e 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 uncloud.settings import settings as config +from uncloud.common.settings import settings as config class ImageStorageHandler(ABC): diff --git a/uncloud/configure/main.py b/uncloud/configure/main.py index f89a30c..64b40c0 100644 --- a/uncloud/configure/main.py +++ b/uncloud/configure/main.py @@ -1,7 +1,7 @@ import os import argparse -from uncloud.settings import settings +from uncloud.common.settings import settings from uncloud.shared import shared arg_parser = argparse.ArgumentParser('configure', add_help=False) diff --git a/uncloud/docs/README.md b/uncloud/docs/README.md new file mode 100644 index 0000000..a5afbaa --- /dev/null +++ b/uncloud/docs/README.md @@ -0,0 +1,12 @@ +# uncloud docs + +## Requirements +1. Python3 +2. Sphinx + +## Usage +Run `make build` to build docs. + +Run `make clean` to remove build directory. + +Run `make publish` to push build dir to https://ungleich.ch/ucloud/ \ No newline at end of file diff --git a/uncloud/filescanner/main.py b/uncloud/filescanner/main.py index 19c43ef..9d2b2f6 100755 --- a/uncloud/filescanner/main.py +++ b/uncloud/filescanner/main.py @@ -9,7 +9,7 @@ import bitmath from uuid import uuid4 from . import logger -from uncloud.settings import settings +from uncloud.common.settings import settings from uncloud.shared import shared diff --git a/uncloud/host/main.py b/uncloud/host/main.py index b7c8b1c..bed068b 100755 --- a/uncloud/host/main.py +++ b/uncloud/host/main.py @@ -6,7 +6,7 @@ from uuid import uuid4 from uncloud.common.request import RequestEntry, RequestType from uncloud.shared import shared -from uncloud.settings import settings +from uncloud.common.settings import settings from uncloud.common.vm import VMStatus from uncloud.vmm import VMM from os.path import join as join_path diff --git a/uncloud/host/virtualmachine.py b/uncloud/host/virtualmachine.py index b9a9e36..a37dee4 100755 --- a/uncloud/host/virtualmachine.py +++ b/uncloud/host/virtualmachine.py @@ -17,7 +17,7 @@ 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.common.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 a43a36c..cb13ac7 100755 --- a/uncloud/imagescanner/main.py +++ b/uncloud/imagescanner/main.py @@ -4,7 +4,7 @@ import argparse import subprocess as sp from os.path import join as join_path -from uncloud.settings import settings +from uncloud.common.settings import settings from uncloud.shared import shared from uncloud.imagescanner import logger diff --git a/uncloud/metadata/main.py b/uncloud/metadata/main.py index e2199b8..d20122e 100644 --- a/uncloud/metadata/main.py +++ b/uncloud/metadata/main.py @@ -5,7 +5,7 @@ from flask import Flask, request from flask_restful import Resource, Api from werkzeug.exceptions import HTTPException -from uncloud.settings import settings +from uncloud.common.settings import settings from uncloud.shared import shared app = Flask(__name__) diff --git a/uncloud/scheduler/helper.py b/uncloud/scheduler/helper.py index 7edf623..a7fec15 100755 --- a/uncloud/scheduler/helper.py +++ b/uncloud/scheduler/helper.py @@ -7,7 +7,7 @@ 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 +from uncloud.common.settings import settings def accumulated_specs(vms_specs): diff --git a/uncloud/scheduler/main.py b/uncloud/scheduler/main.py index 1ef6226..5143537 100755 --- a/uncloud/scheduler/main.py +++ b/uncloud/scheduler/main.py @@ -8,7 +8,7 @@ import argparse from uncloud.common.request import RequestEntry, RequestType from uncloud.shared import shared -from uncloud.settings import settings +from uncloud.common.settings import settings from .helper import (dead_host_mitigation, dead_host_detection, assign_host, NoSuitableHostFound) from . import logger diff --git a/uncloud/shared/__init__.py b/uncloud/shared/__init__.py index db2093f..918dd0c 100644 --- a/uncloud/shared/__init__.py +++ b/uncloud/shared/__init__.py @@ -1,4 +1,4 @@ -from uncloud.settings import settings +from uncloud.common.settings import settings from uncloud.common.vm import VmPool from uncloud.common.host import HostPool from uncloud.common.request import RequestPool