put instance config file to config folder

This commit is contained in:
mantaohuang 2020-12-20 13:09:32 -05:00
parent 62fc1aee5c
commit 8bed0a4b10
3 changed files with 7 additions and 3 deletions

View File

@ -8,4 +8,4 @@ cd /mop
python profile_scanner.py -c $CONFIG_FOLDER -a $AUTH_FILE
# run main script
python -u test.py -s /tmp
python -u test.py -s /tmp -l $INSTANCE_CONFIG

View File

@ -15,4 +15,5 @@ services:
- net_admin
environment:
CONFIG_FOLDER: /config
INSTANCE_CONFIG: /config/instances.json
AUTH_FILE: /config/fast.txt

View File

@ -13,13 +13,16 @@ ap.add_argument("-i", "--interface", required=False,
help="interface (default: eth0)", default="eth0")
ap.add_argument("-s", "--session_folder", required=True,
help="path to the session folder")
ap.add_argument("-l", "--load_instance_config", required=False,
help="instance config file (default: /config/instance.json)", default="/config/instance.json")
args = vars(ap.parse_args())
session_folder = args["session_folder"]
interface = args["interface"]
om = OManager(session_folder, interface)
root = os.path.dirname(__file__)
instance_config_fp = os.path.join(root, "config/instances.json")
instance_config_fp = args["load_instance_config"]
try:
instance_config = json.load(open(instance_config_fp, "r"))
@ -128,7 +131,7 @@ class ClearCacheInstatnceHandler(tornado.web.RequestHandler):
class SaveInstanceHandler(tornado.web.RequestHandler):
def get(self):
instances = om.serialize_instance_config()
with open(os.path.join(root, instance_config_fp), "w") as f:
with open(instance_config_fp, "w") as f:
f.write(json.dumps(instances))
self.write("OK")