From b40fad7acc2712ed8b78b37a2564daf78ecbd0ed Mon Sep 17 00:00:00 2001 From: zhongyehong Date: Sun, 20 May 2018 17:32:35 +0800 Subject: [PATCH] Add a parameter to control whether the add node function is enabled. --- conf/docklet.conf.template | 4 ++++ src/cloudmgr.py | 10 +++++++++- src/env.py | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/conf/docklet.conf.template b/conf/docklet.conf.template index 01f2e23..e9c838b 100644 --- a/conf/docklet.conf.template +++ b/conf/docklet.conf.template @@ -178,3 +178,7 @@ # The two ports next to '-' are inclueded. If there are several ranges, # Please seperate them by ',' , for example: 10000-20000,30000-40000 # ALLOCATED_PORTS=10000-65535 + +# ALLOW_SCALE_OUT: allow docklet to rent server on the cloud to scale out +# Only when you deploy docklet on the cloud can you set it to True +# ALLOW_SCALE_OUT=False diff --git a/src/cloudmgr.py b/src/cloudmgr.py index 936616d..2b8957a 100755 --- a/src/cloudmgr.py +++ b/src/cloudmgr.py @@ -162,6 +162,11 @@ class AliyunMgr(): thread.setDaemon(True) thread.start() +class EmptyMgr(): + def addNodeAsync(self): + logger.error("current cluster does not support scale out") + return False + class CloudMgr(): def getSettingFile(self): @@ -185,4 +190,7 @@ class CloudMgr(): def __init__(self): - self.engine = AliyunMgr() + if env.getenv("ALLOW_SCALE_OUT") == "True": + self.engine = AliyunMgr() + else: + self.engine = EmptyMgr() diff --git a/src/env.py b/src/env.py index 87ae996..3fcc8d1 100755 --- a/src/env.py +++ b/src/env.py @@ -77,5 +77,7 @@ def getenv(key): return os.environ.get("APPROVAL_RBT","ON") elif key =="ALLOCATED_PORTS": return os.environ.get("ALLOCATED_PORTS","10000-65535") + elif key =="ALLOW_SCALE_OUT": + return os.environ.get("ALLOW_SCALE_OUT", "False") else: return os.environ.get(key,"")