diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index e0e2db3a..eda68b10 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -102,9 +102,7 @@ class VirtualMachineHandler(Iface): def keyboard_interrupt_handler_playbooks(self): global active_playbooks for k, v in active_playbooks.items(): - LOG.info( - "Clearing traces of Playbook-VM for (openstack_id): {0}".format(k) - ) + LOG.info("Clearing traces of Playbook-VM for (openstack_id): {0}".format(k)) self.delete_keypair(key_name=self.redis.hget(k, "name").decode("utf-8")) v.stop(k) self.delete_server(openstack_id=k) @@ -175,9 +173,7 @@ def __init__(self, config): self.BIBIGRID_URL = self.BIBIGRID_URL.format( host=self.BIBIGRID_HOST, port=self.BIBIGRID_PORT ) - LOG.info( - msg="Bibigrd url loaded: {0}".format(self.BIBIGRID_URL) - ) + LOG.info(msg="Bibigrd url loaded: {0}".format(self.BIBIGRID_URL)) except Exception as e: LOG.exception(e) LOG.info("Bibigrid not loaded.") @@ -188,9 +184,7 @@ def __init__(self, config): self.RE_BACKEND_URL = cfg["forc"]["forc_url"] self.FORC_API_KEY = os.environ["FORC_API_KEY"] self.FORC_ALLOWED = cfg["forc"]["forc_allowed"] - LOG.info( - msg="Forc-Backend url loaded: {0}".format(self.RE_BACKEND_URL) - ) + LOG.info(msg="Forc-Backend url loaded: {0}".format(self.RE_BACKEND_URL)) LOG.info( "Client allows following research environments and respective versions: {0}".format( self.FORC_ALLOWED @@ -515,9 +509,7 @@ def get_server(self, openstack_id): try: server = self.conn.compute.get_server(openstack_id) except Exception as e: - LOG.exception( - "No Server found {0} | Error {1}".format(openstack_id, e) - ) + LOG.exception("No Server found {0} | Error {1}".format(openstack_id, e)) return VM(status="NOT FOUND") serv = server.to_dict() @@ -638,9 +630,7 @@ def get_network(self): def create_mount_init_script( self, volume_ids_path_new=None, volume_ids_path_attach=None ): - LOG.info( - "create init script for volume ids:{}".format(volume_ids_path_new) - ) + LOG.info("create init script for volume ids:{}".format(volume_ids_path_new)) if not volume_ids_path_new and not volume_ids_path_attach: return None @@ -1122,9 +1112,7 @@ def create_and_deploy_playbook( self, public_key, playbooks_information, openstack_id ): global active_playbooks - LOG.info( - msg="Starting Playbook for (openstack_id): {0}".format(openstack_id) - ) + LOG.info(msg="Starting Playbook for (openstack_id): {0}".format(openstack_id)) port = self.get_vm_ports(openstack_id=openstack_id) key = self.redis.hget(openstack_id, "key").decode("utf-8") playbook = Playbook( @@ -1707,9 +1695,7 @@ def check_server_status(self, openstack_id): server.status = self.BUILD return server except Exception as e: - LOG.exception( - "Check Status VM {0} error: {1}".format(openstack_id, e) - ) + LOG.exception("Check Status VM {0} error: {1}".format(openstack_id, e)) return None def openstack_server_to_thrift_server(self, server): @@ -1725,9 +1711,7 @@ def openstack_server_to_thrift_server(self, server): "size" ] except Exception as e: - LOG.exception( - "Could not found volume {}: {}".format(volume_id, e) - ) + LOG.exception("Could not found volume {}: {}".format(volume_id, e)) if server["OS-SRV-USG:launched_at"]: dt = datetime.datetime.strptime( @@ -1778,9 +1762,7 @@ def get_servers(self): server_list.append(thrift_server) except Exception as e: - LOG.exception( - "Could not transform to thrift_server: {}".format(e) - ) + LOG.exception("Could not transform to thrift_server: {}".format(e)) LOG.info( "Converted {} servers to thrift_server objects".format(len(server_list)) ) @@ -2023,9 +2005,7 @@ def create_snapshot(self, openstack_id, name, elixir_id, base_tags, description) server=openstack_id, name=name ) except ConflictException as e: - LOG.exception( - "Create snapshot {0} error: {1}".format(openstack_id, e) - ) + LOG.exception("Create snapshot {0} error: {1}".format(openstack_id, e)) raise conflictException(Reason="409") except Exception: @@ -2195,15 +2175,11 @@ def delete_server(self, openstack_id): return True except ConflictException as e: - LOG.exception( - "Delete Server {0} error: {1}".format(openstack_id, e) - ) + LOG.exception("Delete Server {0} error: {1}".format(openstack_id, e)) raise conflictException(Reason="409") except Exception as e: - LOG.exception( - "Delete Server {0} error: {1}".format(openstack_id, e) - ) + LOG.exception("Delete Server {0} error: {1}".format(openstack_id, e)) return False def delete_volume_attachment(self, volume_id, server_id): @@ -2352,9 +2328,7 @@ def resume_server(self, openstack_id): else: return False except ConflictException as e: - LOG.exception( - "Resume Server {0} error: {1}".format(openstack_id, e) - ) + LOG.exception("Resume Server {0} error: {1}".format(openstack_id, e)) raise conflictException(Reason="409") except Exception as e: @@ -2488,9 +2462,7 @@ def create_security_group( security_group_id=new_security_group["id"], ) if JUPYTERNOTEBOOK in resenv: - LOG.info( - "Add jupyternotebook rule to security group {}".format(name) - ) + LOG.info("Add jupyternotebook rule to security group {}".format(name)) self.conn.network.create_security_group_rule( direction="ingress", diff --git a/VirtualMachineService/ancon/Playbook.py b/VirtualMachineService/ancon/Playbook.py index d83f950e..638f220a 100644 --- a/VirtualMachineService/ancon/Playbook.py +++ b/VirtualMachineService/ancon/Playbook.py @@ -38,7 +38,7 @@ class Playbook(object): PLAYBOOK_FAILED = "PLAYBOOK_FAILED" def __init__( - self, ip, port, playbooks_information, osi_private_key, public_key, pool + self, ip, port, playbooks_information, osi_private_key, public_key, pool ): self.redis = redis.Redis(connection_pool=pool) # redis connection self.yaml_exec = ruamel.yaml.YAML() # yaml writer/reader @@ -240,9 +240,7 @@ def check_status(self, openstack_id): ) ) elif done != 0: - LOG.info( - "Playbook for (openstack_id) {0} has failed.".format(openstack_id) - ) + LOG.info("Playbook for (openstack_id) {0} has failed.".format(openstack_id)) self.redis.hset(openstack_id, "status", self.PLAYBOOK_FAILED) self.returncode = self.process.returncode self.process.wait()