Fix flake8, black and pylint errors in code
Change-Id: Ic03f4d31e2ba9801be20d3679bd5749948cab39d
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/osm_ee/base_ee.py b/osm_ee/base_ee.py
index 6728c49..c7b1bed 100644
--- a/osm_ee/base_ee.py
+++ b/osm_ee/base_ee.py
@@ -36,15 +36,16 @@
HEALTH_CHECK_ACTION = "health-check"
def __init__(self):
- self.logger = logging.getLogger('osm_ee.base')
+ self.logger = logging.getLogger("osm_ee.base")
+ self.config_params = {}
# Check if configuration is stored and load it
if os.path.exists(self.CONFIG_FILE):
- with open(self.CONFIG_FILE, 'r') as file:
+ with open(self.CONFIG_FILE, "r") as file:
self.config_params = yaml.load(file, Loader=yaml.FullLoader)
- self.logger.debug("Load existing config from file: {}".format(self.config_params))
- else:
- self.config_params = {}
+ self.logger.debug(
+ "Load existing config from file: {}".format(self.config_params)
+ )
self.vnf_ee = VnfEE(self.config_params)
@@ -56,7 +57,9 @@
return ssh_key
async def run_action(self, id, name, params):
- self.logger.debug("Execute action id: {}, name: {}, params: {}".format(id, name, params))
+ self.logger.debug(
+ "Execute action id: {}, name: {}, params: {}".format(id, name, params)
+ )
try:
# Health-check
@@ -71,10 +74,13 @@
action_params = yaml.safe_load(params)
if name == "config":
- self.logger.debug("Store config info in file: {}".format(self.CONFIG_FILE))
+ self.logger.debug(
+ "Store config info in file: {}".format(self.CONFIG_FILE)
+ )
self.config_params.update(action_params)
- with open(self.CONFIG_FILE, 'w') as file:
+ with open(self.CONFIG_FILE, "w") as file:
config = yaml.dump(self.config_params, file)
+ self.logger.debug("Config info: {}".format(config))
async for return_status, detailed_message in method(id, action_params):
if return_status not in self.RETURN_STATUS_LIST:
@@ -82,15 +88,20 @@
else:
yield return_status, str(detailed_message)
except AttributeError as e:
- error_msg = "Action name: {} not implemented".format(name)
+ error_msg = "Action name: {} not implemented. Exception: {}".format(
+ name, str(e)
+ )
self.logger.error(error_msg)
yield "ERROR", error_msg
except Exception as e:
- self.logger.error("Error executing action id, name: {},{}: {}".format(id, name, str(e)), exc_info=True)
+ self.logger.error(
+ "Error executing action id, name: {},{}: {}".format(id, name, str(e)),
+ exc_info=True,
+ )
yield "ERROR", str(e)
-if __name__ == '__main__':
+if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
loop = asyncio.get_event_loop()