island: Get deployment type from file in env config

This commit is contained in:
Shreya Malviya 2021-09-10 17:31:33 +05:30
parent 2af3878e81
commit a62328dcf6
1 changed files with 13 additions and 2 deletions

View File

@ -2,23 +2,34 @@ from __future__ import annotations
import json
import os
from typing import Dict, List
from typing import Dict, List, Optional
from monkey_island.cc.environment.user_creds import UserCreds
from monkey_island.cc.resources.auth.auth_user import User
from monkey_island.cc.resources.auth.user_store import UserStore
from monkey_island.cc.server_utils.consts import MONKEY_ISLAND_ABS_PATH
class EnvironmentConfig:
def __init__(self, file_path):
self._server_config_path = os.path.expanduser(file_path)
self.server_config = None
self.deployment = None
self.deployment = self._get_deployment_from_file()
self.user_creds = None
self.aws = None
self._load_from_file(self._server_config_path)
def _get_deployment_from_file(self) -> Optional[str]:
deployment = None
deployment_info_file_path = os.path.join(MONKEY_ISLAND_ABS_PATH, "cc", "deployment.json")
with open(deployment_info_file_path, "r") as deployment_info_file:
deployment_info = json.load(deployment_info_file)
deployment = deployment_info["deployment"]
return deployment
def _load_from_file(self, file_path):
file_path = os.path.expanduser(file_path)