From 59dd365dd56df85c2b239f7d4692384913f3d659 Mon Sep 17 00:00:00 2001 From: Ahmed Bilal Khalid Date: Wed, 28 Aug 2019 21:05:43 +0500 Subject: [PATCH 1/4] b --- .gitignore | 0 Pipfile | 2 ++ Pipfile.lock | 0 config.py | 6 ++++++ helper.py | 5 +---- main.py | 6 ++---- tests/test_basics.py | 5 ++--- tests/test_dead_host_mechanism.py | 6 ++---- 8 files changed, 15 insertions(+), 15 deletions(-) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 Pipfile mode change 100644 => 100755 Pipfile.lock create mode 100644 config.py mode change 100644 => 100755 helper.py mode change 100644 => 100755 main.py mode change 100644 => 100755 tests/test_basics.py mode change 100644 => 100755 tests/test_dead_host_mechanism.py diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/Pipfile b/Pipfile old mode 100644 new mode 100755 index b89aadf..6d65ed8 --- a/Pipfile +++ b/Pipfile @@ -7,12 +7,14 @@ verify_ssl = true bandit = "*" flake8 = "*" black = "==19.3b0" +pylint = "*" [packages] python-decouple = "*" pytest = "*" coverage = "*" python-etcd3 = {editable = true,git = "https://github.com/kragniz/python-etcd3"} +pylint = "*" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock old mode 100644 new mode 100755 diff --git a/config.py b/config.py new file mode 100644 index 0000000..0b3f0be --- /dev/null +++ b/config.py @@ -0,0 +1,6 @@ +from decouple import config +from etcd3_wrapper import Etcd3Wrapper + +etcd_client = Etcd3Wrapper( + host=config("ETCD_URL"), user="root", password=config("ETCD_PASSWORD") +) diff --git a/helper.py b/helper.py old mode 100644 new mode 100755 index 2dc2dff..b2f99be --- a/helper.py +++ b/helper.py @@ -5,12 +5,9 @@ from ucloud_common.vm import VmPool, VMStatus from ucloud_common.host import HostPool, HostStatus from ucloud_common.request import RequestEntry, RequestPool, RequestType -from etcd3_wrapper import Etcd3Wrapper from decouple import config +from config import etcd_client as client -client = Etcd3Wrapper( - host=config("ETCD_HOST"), port=int(config("ETCD_PORT")) - ) vm_pool = VmPool(client, config("VM_PREFIX")) host_pool = HostPool(client, config("HOST_PREFIX")) request_pool = RequestPool(client, config("REQUEST_PREFIX")) diff --git a/main.py b/main.py old mode 100644 new mode 100755 index 79fbe4b..c54751e --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ import logging from decouple import config -from etcd3_wrapper import Etcd3Wrapper +from config import etcd_client as client from ucloud_common.vm import VmPool from ucloud_common.host import HostPool @@ -28,9 +28,7 @@ logging.basicConfig( def main(vm_prefix, host_prefix, request_prefix): logging.info(f"{'*' * 5} SESSION STARTED {'*' * 5}") - client = Etcd3Wrapper( - host=config("ETCD_HOST"), port=int(config("ETCD_PORT")) - ) + vm_pool = VmPool(client, vm_prefix) host_pool = HostPool(client, host_prefix) request_pool = RequestPool(client, request_prefix) diff --git a/tests/test_basics.py b/tests/test_basics.py old mode 100644 new mode 100755 index edb3de6..227e84b --- a/tests/test_basics.py +++ b/tests/test_basics.py @@ -20,13 +20,12 @@ from main import ( main, ) -from etcd3_wrapper import Etcd3Wrapper - +from config import etcd_client class TestFunctions(unittest.TestCase): @classmethod def setUpClass(cls): - cls.client = Etcd3Wrapper() + cls.client = etcd_client cls.host_prefix = "/test/host" cls.vm_prefix = "/test/vm" diff --git a/tests/test_dead_host_mechanism.py b/tests/test_dead_host_mechanism.py old mode 100644 new mode 100755 index 477ae29..33bed23 --- a/tests/test_dead_host_mechanism.py +++ b/tests/test_dead_host_mechanism.py @@ -16,14 +16,12 @@ from main import ( dead_host_detection, dead_host_mitigation, main, + config ) -from etcd3_wrapper import Etcd3Wrapper - - class TestDeadHostMechanism(unittest.TestCase): def setUp(self): - self.client = Etcd3Wrapper() + self.client = config.etcd_client self.host_prefix = "/test/host" self.vm_prefix = "/test/vm" From 37b88606fe1b089b8610e74b8df8d6e6b0b267fc Mon Sep 17 00:00:00 2001 From: Ahmed Bilal Khalid Date: Fri, 30 Aug 2019 19:31:58 +0500 Subject: [PATCH 2/4] a --- Pipfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Pipfile b/Pipfile index 6d65ed8..a12130c 100755 --- a/Pipfile +++ b/Pipfile @@ -13,6 +13,7 @@ pylint = "*" python-decouple = "*" pytest = "*" coverage = "*" +grpcio = "*" python-etcd3 = {editable = true,git = "https://github.com/kragniz/python-etcd3"} pylint = "*" From 07e8d25bece98cbcda3b0314b1f9848f0f62472c Mon Sep 17 00:00:00 2001 From: Ahmed Bilal Khalid Date: Fri, 30 Aug 2019 23:40:43 +0500 Subject: [PATCH 3/4] a --- config.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 0b3f0be..4ed65fc 100644 --- a/config.py +++ b/config.py @@ -1,6 +1,7 @@ from decouple import config from etcd3_wrapper import Etcd3Wrapper -etcd_client = Etcd3Wrapper( - host=config("ETCD_URL"), user="root", password=config("ETCD_PASSWORD") -) +# TODO: Remove timeout, use certificate authentication +etcd_client = Etcd3Wrapper(host=config("ETCD_URL"), user="root", + password=config("ETCD_PASSWORD"), + timeout=2629746) From 07420e79f76aa532ccd0e8cb707bdae21255925e Mon Sep 17 00:00:00 2001 From: Ahmed Bilal Khalid Date: Sat, 31 Aug 2019 16:30:27 +0500 Subject: [PATCH 4/4] a --- config.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config.py b/config.py index 4ed65fc..2694fae 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,4 @@ from decouple import config from etcd3_wrapper import Etcd3Wrapper -# TODO: Remove timeout, use certificate authentication -etcd_client = Etcd3Wrapper(host=config("ETCD_URL"), user="root", - password=config("ETCD_PASSWORD"), - timeout=2629746) +etcd_client = Etcd3Wrapper(host=config("ETCD_URL"))