From ff6258923185678b136c33e846efc8db20b2e6a4 Mon Sep 17 00:00:00 2001 From: dweinholz Date: Fri, 11 Feb 2022 16:26:18 +0100 Subject: [PATCH 1/5] adde pre-commit --- .pre-commit-config.yaml | 49 +++++++++++++++++++++++++++++++++++++++++ setup.cfg | 18 +++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 setup.cfg diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..4a250670 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,49 @@ +default_stages: [ commit ] + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + + - repo: https://github.com/psf/black + rev: 22.1.0 + hooks: + - id: black + - repo: https://github.com/sondrelg/pep585-upgrade + rev: 'v1' # Use the sha / tag you want to point at + hooks: + - id: upgrade-type-hints + + - repo: https://github.com/PyCQA/isort + rev: 5.10.1 + hooks: + - id: isort + - repo: https://github.com/neutrinoceros/flynt/ + rev: '' + hooks: + - id: flynt + + - repo: https://github.com/myint/autoflake + rev: v1.4 + hooks: + - id: autoflake + args: + - --in-place + - --remove-unused-variables + - --remove-all-unused-imports + + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + args: [ "--config=setup.cfg" ] + additional_dependencies: [ flake8-isort ] + +# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date +ci: + autoupdate_schedule: weekly + skip: [ ] + submodules: false diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..e634b145 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,18 @@ +[flake8] +max-line-length = 140 +exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,app/connector/VirtualMachineService.py + +[pycodestyle] +max-line-length = 140 +exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv + +[isort] +line_length = 88 +known_first_party = simple_vm_client,config +multi_line_output = 3 +default_section = THIRDPARTY +skip = venv/ +skip_glob = **/migrations/*.py +include_trailing_comma = true +force_grid_wrap = 0 +use_parentheses = true From a620f408bd8116af237e7db11548f06a17b500c2 Mon Sep 17 00:00:00 2001 From: dweinholz Date: Fri, 11 Feb 2022 16:30:15 +0100 Subject: [PATCH 2/5] run pre-commit on all files --- .github/workflows/blacked.yml | 2 +- .github/workflows/build_image.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/master-protection.yml | 2 - .github/workflows/publish_docker.yml | 2 - CHANGELOG.md | 10 +- Dockerfile | 2 +- Makefile | 8 +- PULL_REQUEST_TEMPLATE.md | 4 +- ProjectGateway.md | 20 +- README.md | 44 +- .../VirtualMachineHandler.py | 580 +++++------ VirtualMachineService/VirtualMachineServer.py | 26 +- .../VirtualMachineService-remote | 943 ++++++++++++------ .../VirtualMachineService.py | 627 ++++++------ VirtualMachineService/ancon/Playbook.py | 30 +- .../roles/guacamole/defaults/main.yml | 2 +- .../guacamole/files/guacamole.properties | 2 +- .../roles/guacamole/handlers/main.yml | 2 +- .../playbooks/roles/guacamole/meta/main.yml | 2 +- .../roles/guacamole/tasks/005-desktop.yml | 2 +- .../playbooks/roles/guacamole/tasks/main.yml | 2 +- .../guacamole/templates/user-mapping.xml.j2 | 2 +- .../playbooks/roles/guacamole/tests/inventory | 1 - .../playbooks/roles/guacamole/tests/test.yml | 2 +- .../playbooks/roles/guacamole/vars/main.yml | 2 +- .../theia/templates/theia-ide.service.j2 | 2 +- .../roles/theia/templates/theia-ide.sh.j2 | 2 +- VirtualMachineService/constants.py | 12 - VirtualMachineService/log/.gitignore | 2 +- VirtualMachineService/ttypes.py | 81 +- docker-compose.bibigrid.yml | 10 +- docker-compose.yml | 10 +- plays/setup_basics.yml | 2 +- plays/setup_client.yml | 14 +- scripts/bibigrid/clear_keys_cron | 2 +- scripts/gateway/gateway-setup-variables.yml | 2 +- scripts/gateway/gateway-setup.yml | 2 +- scripts/gateway/gateway_TCP.sh | 2 +- scripts/gateway/gateway_UDP.sh | 1 - scripts/generate_new_test_pems.sh | 4 +- setup.cfg | 4 +- setup.py | 4 +- troubleshooting/README.md | 6 +- 44 files changed, 1340 insertions(+), 1145 deletions(-) diff --git a/.github/workflows/blacked.yml b/.github/workflows/blacked.yml index f0d83780..d9251a14 100644 --- a/.github/workflows/blacked.yml +++ b/.github/workflows/blacked.yml @@ -24,7 +24,7 @@ jobs: title: Automated Blacked Linting body: | New Linting - - Fixed Linting Errors + - Fixed Linting Errors - Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index 68c3ca74..e85b2315 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -1,6 +1,6 @@ name: build-image on: pull_request -jobs: +jobs: build-test: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index da6bc877..7341edfe 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: uses: github/codeql-action/init@v1 with: languages: ${{ matrix.language }} - queries: +security-extended, security-and-quality + queries: +security-extended, security-and-quality # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. diff --git a/.github/workflows/master-protection.yml b/.github/workflows/master-protection.yml index ad1e7f1d..95f2c4e3 100644 --- a/.github/workflows/master-protection.yml +++ b/.github/workflows/master-protection.yml @@ -20,5 +20,3 @@ jobs: run: | stringContain() { [ -z "$1" ] || { [ -z "${2##*$1*}" ] && [ -n "$2" ];};} if stringContain ${{github.head_ref}} 'staging' || stringContain ${{github.head_ref}} 'hotfix'; then exit 0; else exit 1; fi - - diff --git a/.github/workflows/publish_docker.yml b/.github/workflows/publish_docker.yml index e64fe7a5..cd961ca8 100644 --- a/.github/workflows/publish_docker.yml +++ b/.github/workflows/publish_docker.yml @@ -34,5 +34,3 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} dockerfile: Dockerfile tags: ${{ steps.tag.outputs.TAG }} - - diff --git a/CHANGELOG.md b/CHANGELOG.md index ce9b76cb..057ecce8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,8 +23,8 @@ #### Features -* **Volume:** added resizing -* **mosh:** playbook for installing mosh +* **Volume:** added resizing +* **mosh:** playbook for installing mosh ## (2020-02-27) @@ -206,7 +206,7 @@ * **delete-vm:** * deletes all security groups of server with the same name - + ### Features * **bioconda:** init .bashrc and create alias for environment (#141) @@ -283,6 +283,6 @@ ### Features * **PR_TEMPLATE:** - * updated with changelog" + * updated with changelog" * added comment checks -* **pep:** set line max length to 100 +* **pep:** set line max length to 100 diff --git a/Dockerfile b/Dockerfile index 7d1378f5..fad4abf3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.10.1-buster -RUN apt-get update -y +RUN apt-get update -y RUN apt-get install -y build-essential WORKDIR /code ADD requirements.txt /code diff --git a/Makefile b/Makefile index 2bdb377b..36c06190 100644 --- a/Makefile +++ b/Makefile @@ -19,10 +19,10 @@ thrift_py: ## Builds python code from thrift file cp -a gen-py/VirtualMachineService/. VirtualMachineService rm -rf gen-py @echo Remember to fix the imports: for pip relative imports are needed, for others absolute imports - + dev-build: ## Build and Start the docker-compose.dev.yml docker-compose -f docker-compose.dev.yml up --build - + dev-d: ## Build and Start the docker-compose.dev.yml docker-compose -f docker-compose.dev.yml up -d @@ -43,13 +43,13 @@ dev-build-bibigrid-d: ## Build and Start the docker-compose.dev.yml with bibigri dev-bibigrid-d: ## Build and Start the docker-compose.dev.yml with bibigrid docker-compose -f docker-compose.dev.bibigrid.yml up -d - + production: ## Build Release from .env docker-compose -f docker-compose.yml up --build -d production-bibigrid: ## Build Release from .env and with bibigrid docker-compose -f docker-compose.bibigrid.yml up --build -d - + client_logs: ## Logs from Client docker logs client_portal-client_1 diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index 33617211..3b3ea2c9 100644 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -7,6 +7,6 @@ Try to fulfill the following points before the Pull Request is merged: For releases only: -- [ ] If the review of this PR is approved and the PR is followed by a release then the .env file - in the cloud-portal repo should also be updated. +- [ ] If the review of this PR is approved and the PR is followed by a release then the .env file + in the cloud-portal repo should also be updated. - [ ] If you are making a release then please sum up the changes since the last release on the release page using the [clog](https://github.com/clog-tool/clog-cli) tool with `clog -F` diff --git a/ProjectGateway.md b/ProjectGateway.md index 802b8941..4836e454 100644 --- a/ProjectGateway.md +++ b/ProjectGateway.md @@ -1,26 +1,26 @@ -# Project Gateway +# Project Gateway -The single VM feature of the de.NBI portal allows a registered user to start a virtual machine without having a project located at a specific cloud location. VMs are instantiated in a project associated to the portal. The association between the user and the virtual machine is done and only known by the de.NBI portal. +The single VM feature of the de.NBI portal allows a registered user to start a virtual machine without having a project located at a specific cloud location. VMs are instantiated in a project associated to the portal. The association between the user and the virtual machine is done and only known by the de.NBI portal. -The started VMs can be accessed using ssh (or any technology on top of it, e.g. x2go). However this needs a public available ip address (floating ip) for each running instance. If we don't have IP addresses available (ipv4 addresses are rare), we have to think of another solution. +The started VMs can be accessed using ssh (or any technology on top of it, e.g. x2go). However this needs a public available ip address (floating ip) for each running instance. If we don't have IP addresses available (ipv4 addresses are rare), we have to think of another solution. -A relative simple solution is to create a ssh gateway for the portal project with a fixed mapping between ports and local ip addresses. Linux can be easily configured to act as gateway/router between networks. This linux property is used by a lot of commercial routers. +A relative simple solution is to create a ssh gateway for the portal project with a fixed mapping between ports and local ip addresses. Linux can be easily configured to act as gateway/router between networks. This linux property is used by a lot of commercial routers. The tutorial was tested on Ubuntu 16.04 LTS, but should work on any modern linux OS since nothing Ubuntu-specific has been used. ## Assumptions - portal project with at least one portal user -- full configured project network (router, network/subnet e.g. 192.168.0.0/24) +- full configured project network (router, network/subnet e.g. 192.168.0.0/24) - one public ip address available (e.g. XX.XX.XX.XX) - accessible and contiguous port range (e.g. 30000-30255), at least one for each local ip address ## Step by Step -The step by step documentation configures one instance to be ssh gateway for another instance in the same network (192.168.0.0/24). +The step by step documentation configures one instance to be ssh gateway for another instance in the same network (192.168.0.0/24). -- **Create a two instance** (192.168.0.10, 192.168.0.11). +- **Create a two instance** (192.168.0.10, 192.168.0.11). - **Associate a floating ip** (XX.XX.XX.XX) to the first instance (192.168.0.10). This instance will be the ssh gateway for the second instance. - **Login into** the floating ip instance (XX.XX.XX.XX) and enable ip forwarding (as root). @@ -36,7 +36,7 @@ iptables -t nat -A PREROUTING -i ens3 -p tcp -m tcp --dport 30011 -j DNAT --to-d iptables -t nat -A POSTROUTING -d 192.168.00.11/32 -p tcp -m tcp --dport 22 -j SNAT --to-source 192.168.0.10 ``` -- **Add a OpenStack security group rule** to allow incoming tcp traffic on port 30011. +- **Add a OpenStack security group rule** to allow incoming tcp traffic on port 30011. - **Login** into the instance (192.168.0.11) is now possible without adding a floating ip. @@ -46,13 +46,13 @@ ssh -i my_cloud_key ubuntu@XX.XX.XX.XX -p 30011 ## Configuration using user data -Configure a project gateway manually is a bit plodding. However, since we have a fixed mapping between ports and local ip addresses, we can automate this step by writing a small script and provide it as user data at instance start. The script should do the following steps : +Configure a project gateway manually is a bit plodding. However, since we have a fixed mapping between ports and local ip addresses, we can automate this step by writing a small script and provide it as user data at instance start. The script should do the following steps : 1. wait for metadata server to be available 2. get the CIDR mask from the metadata service 3. enable ip forwarding 4. add a forwarding rules for ssh (Port 22) for each available ip address (2 ... 254) -5. create a new security group that allows incoming tcp connections from port 30002 to port 30254 and associate it to the gateway instance +5. create a new security group that allows incoming tcp connections from port 30002 to port 30254 and associate it to the gateway instance The full script could look like the following: diff --git a/README.md b/README.md index e66422fa..c17e5921 100644 --- a/README.md +++ b/README.md @@ -23,19 +23,19 @@ source NameOfRcFile.sh ~~~ #### Configuration -You can view (almost) all existing parameters in the [yaml file](VirtualMachineService/config/config.yml). -For local development: -Please copy this file and rename it to `config_local.yml` and fill in missing parameters. -For staging/production setup: -Please copy this file and rename it to `config_YOUR_LOCATION.yml` and fill in missing parameters. +You can view (almost) all existing parameters in the [yaml file](VirtualMachineService/config/config.yml). +For local development: +Please copy this file and rename it to `config_local.yml` and fill in missing parameters. +For staging/production setup: +Please copy this file and rename it to `config_YOUR_LOCATION.yml` and fill in missing parameters. Also you need to provide the path to your config file as the first param when starting a server. -Furthermore there are some parameters you must set in the .env file. Copy the [.env.in](.env.in) to .env and -fill in the missing parameters. +Furthermore there are some parameters you must set in the .env file. Copy the [.env.in](.env.in) to .env and +fill in the missing parameters. When starting with commandline you will need to export some of them manually. #### Security Groups -The config file contains a name for the default SimpleVM security group. +The config file contains a name for the default SimpleVM security group. It can be configured via the `default_simple_vm_security_group_name` key. The client will set this group for every SimpleVM machine. @@ -44,7 +44,7 @@ The client will set this group for every SimpleVM machine. The client can use a Gateway for starting and stopping machines which allows to use just one floating IP instead of one floating IP per Machine. You can read [here](ProjectGateway.md) how to setup a gateway on an OpenStack instance. You can also find complete scripts in the [gateway](gateway) folder. -The client will provide all images with at least one tag, which will be filtered for in the cloud-api. +The client will provide all images with at least one tag, which will be filtered for in the cloud-api. Also the client provides all flavors, which will also be filtered in the cloud-api. _**Attention**_: If you are also using the machine where you run the client as a gateway, it is very important to configure the iptables before installing and using docker, otherwise docker could destroy the rules! @@ -141,7 +141,7 @@ This command will generate python code from the thrift file. In order for the cloud-api to use the new/changed methods, [VirtualMachineService.py](VirtualMachineService/VirtualMachineService.py), [ttypes.py](VirtualMachineService/ttypes.py) and [constants.py](VirtualMachineService/constants.py) must be copied over. -Because docker can't use relative imports, you also need to change the import of [ttypes.py](VirtualMachineService/ttypes.py) in [constants.py](VirtualMachineService/constants.py) and [VirtualMachineService.py](VirtualMachineService/VirtualMachineService.py): +Because docker can't use relative imports, you also need to change the import of [ttypes.py](VirtualMachineService/ttypes.py) in [constants.py](VirtualMachineService/constants.py) and [VirtualMachineService.py](VirtualMachineService/VirtualMachineService.py): ```python from .ttypes import * @@ -156,7 +156,7 @@ _**Attention**_: The cloud-api needs the files with the relative imports (from . A detailed instruction, how to write a thrift file can be found on this link: [thrift](http://thrift-tutorial.readthedocs.io/en/latest/usage-example.html#generating-code-with-thrift) -To use the methods declared in the thrift file you need to write a handler which implements the Iface from the VirtualMachineService. +To use the methods declared in the thrift file you need to write a handler which implements the Iface from the VirtualMachineService. The handler contains the logic for the methods. Then you can start a server which uses your handler. Example python code for the server: ```python @@ -188,9 +188,9 @@ REMOTE_IP ansible_user=ubuntu ansible_ssh_private_key_file=PATH_TO_SSH_FILE ansi ~~~ where - + * REMOTE_IP is the IP of your staging machine - + * PATH_TO_SSH_FILE is the path to the ssh key of the virtual machine #### 2.Set SSH keyforwarding @@ -199,7 +199,7 @@ In order to checkout the GitHub project you will have to enable SSH Key forwarding in your `~/.ssh/config` file. ~~~BASH -Host IP +Host IP ForwardAgent yes ~~~ @@ -219,12 +219,12 @@ ansible-galaxy install -r ansible_requirements.yml #### 6.Set all variables -Set all variables that can be found in `.env` and `VirtualMachineService/config/config.yml` file. -You can have more than one `.env` file (`.env` and `.env_*` are not tracked by git) and specify which you want to copy -by using the `env_file` variable. -You can have more than one `VirtualMachineService/config/config.yml` file (`VirtualMachineService/config/config_*` are -not tracked by git) and specify which you want to copy by using the `client_config` variable. -These options are useful when maintaining multiple client sites. +Set all variables that can be found in `.env` and `VirtualMachineService/config/config.yml` file. +You can have more than one `.env` file (`.env` and `.env_*` are not tracked by git) and specify which you want to copy +by using the `env_file` variable. +You can have more than one `VirtualMachineService/config/config.yml` file (`VirtualMachineService/config/config_*` are +not tracked by git) and specify which you want to copy by using the `client_config` variable. +These options are useful when maintaining multiple client sites. #### 7.Run the playbook @@ -234,10 +234,10 @@ You can run the playbook using the following command: ansible-playbook -i inventory_openstack site.yml ~~~ -where +where * inventory_openstack is your inventory file which you created in the first step. - + * If you also want to start bibigrid use the tag "bibigrid" **Choose different files** diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index 4515fd96..15e58c9c 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -8,22 +8,28 @@ from uuid import uuid4 try: - from VirtualMachineService import Iface - from ttypes import serverNotFoundException - from ttypes import imageNotFoundException - from ttypes import networkNotFoundException - from ttypes import authenticationException - from ttypes import otherException - from ttypes import flavorNotFoundException - from ttypes import ressourceException - from ttypes import conflictException - from ttypes import Flavor, Image, VM, PlaybookResult, Backend, ClusterInfo, Volume + from ancon.Playbook import ALL_TEMPLATES, Playbook from constants import VERSION - from ancon.Playbook import ( - Playbook, - ALL_TEMPLATES, + from ttypes import ( + VM, + Backend, + ClusterInfo, + Flavor, + Image, + PlaybookResult, + Volume, + authenticationException, + conflictException, + flavorNotFoundException, + imageNotFoundException, + networkNotFoundException, + otherException, + ressourceException, + serverNotFoundException, ) + from VirtualMachineService import Iface + except Exception: from .VirtualMachineService import Iface from .ttypes import serverNotFoundException @@ -111,7 +117,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(f"Clearing traces of Playbook-VM for (openstack_id): {k}") self.delete_keypair(key_name=self.redis.hget(k, "name").decode("utf-8")) v.stop(k) self.delete_server(openstack_id=k) @@ -214,7 +220,7 @@ def __init__(self, config): self.create_deactivate_update_script() ) - LOG.info(msg="Bibigrd url loaded: {0}".format(self.BIBIGRID_URL)) + LOG.info(msg=f"Bibigrd url loaded: {self.BIBIGRID_URL}") except Exception as e: LOG.exception(e) LOG.info("Bibigrid not loaded.") @@ -228,12 +234,12 @@ def __init__(self, config): self.FORC_REMOTE_ID = cfg["forc"]["forc_remote_id"] self.GITHUB_PLAYBOOKS_REPO = cfg["forc"]["github_playbooks_repo"] if ( - not self.RE_BACKEND_URL - or not self.FORC_API_KEY - or not self.GITHUB_PLAYBOOKS_REPO + not self.RE_BACKEND_URL + or not self.FORC_API_KEY + or not self.GITHUB_PLAYBOOKS_REPO ): raise ValueError - LOG.info(msg="Forc-Backend url loaded: {0}".format(self.RE_BACKEND_URL)) + LOG.info(msg=f"Forc-Backend url loaded: {self.RE_BACKEND_URL}") except ValueError as ve: LOG.exception(ve) LOG.info( @@ -259,7 +265,7 @@ def __init__(self, config): "udp_port_calc_formular" ] - LOG.info("Gateway IP is {}".format(self.GATEWAY_IP)) + LOG.info(f"Gateway IP is {self.GATEWAY_IP}") self.update_playbooks() self.conn = self.create_connection() @@ -297,9 +303,7 @@ def findUser(keystone, name): keystone.users.update(user, password=password) return password except Exception as e: - LOG.exception( - "Set Password for user {0} failed : {1}".format(user, str(e)) - ) + LOG.exception(f"Set Password for user {user} failed : {str(e)}") return otherException(Reason=str(e)) else: raise otherException(Reason="Not allowed") @@ -327,7 +331,7 @@ def get_Flavors(self): flavors.append(flavor) return flavors except Exception as e: - LOG.exception("Get Flavors Error: {0}".format(e)) + LOG.exception(f"Get Flavors Error: {e}") return () @deprecated( @@ -351,7 +355,7 @@ def check_Version(self, version): else: return False except Exception as e: - LOG.exception("Compare Version Error: {0}".format(e)) + LOG.exception(f"Compare Version Error: {e}") return False def get_client_version(self): @@ -373,10 +377,10 @@ def get_Images(self): images = list() try: for img in filter( - lambda x: "tags" in x - and len(x["tags"]) > 0 - and x["status"] == "active", - self.conn.list_images(), + lambda x: "tags" in x + and len(x["tags"]) > 0 + and x["status"] == "active", + self.conn.list_images(), ): metadata = img["metadata"] @@ -384,9 +388,9 @@ def get_Images(self): tags = img.get("tags") LOG.info(set(self.ALL_TEMPLATES).intersection(tags)) if len( - set(self.ALL_TEMPLATES).intersection(tags) + set(self.ALL_TEMPLATES).intersection(tags) ) > 0 and not self.cross_check_forc_image(tags): - LOG.info("Resenv check: Skipping {0}.".format(img["name"])) + LOG.info(f"Resenv check: Skipping {img['name']}.") continue image_type = img.get("image_type", "image") if description is None: @@ -410,7 +414,7 @@ def get_Images(self): return images except Exception as e: - LOG.exception("Get Images Error: {0}".format(e)) + LOG.exception(f"Get Images Error: {e}") return () def prepare_image(self, img): @@ -420,9 +424,9 @@ def prepare_image(self, img): tags = img.get("tags") LOG.info(set(self.ALL_TEMPLATES).intersection(tags)) if len( - set(self.ALL_TEMPLATES).intersection(tags) + set(self.ALL_TEMPLATES).intersection(tags) ) > 0 and not self.cross_check_forc_image(tags): - LOG.info("Resenv check: Skipping {0}.".format(img["name"])) + LOG.info(f"Resenv check: Skipping {img['name']}.") return None image_type = img.get("image_type", "image") if description is None: @@ -443,7 +447,7 @@ def prepare_image(self, img): LOG.info(image) return image except Exception as e: - LOG.exception("Prepare image Error: {0}".format(e)) + LOG.exception(f"Prepare image Error: {e}") return None def get_public_Images(self): @@ -456,11 +460,11 @@ def get_public_Images(self): images = list() try: for img in filter( - lambda x: "tags" in x - and len(x["tags"]) > 0 - and x["status"] == "active" - and x["visibility"] == "public", - self.conn.list_images(), + lambda x: "tags" in x + and len(x["tags"]) > 0 + and x["status"] == "active" + and x["visibility"] == "public", + self.conn.list_images(), ): image = self.prepare_image(img) if image is None: @@ -469,7 +473,7 @@ def get_public_Images(self): images.append(image) return images except Exception as e: - LOG.exception("Get Images Error: {0}".format(e)) + LOG.exception(f"Get Images Error: {e}") return () def get_private_Images(self): @@ -482,11 +486,11 @@ def get_private_Images(self): images = list() try: for img in filter( - lambda x: "tags" in x - and len(x["tags"]) > 0 - and x["status"] == "active" - and x["visibility"] == "private", - self.conn.list_images(), + lambda x: "tags" in x + and len(x["tags"]) > 0 + and x["status"] == "active" + and x["visibility"] == "private", + self.conn.list_images(), ): image = self.prepare_image(img) if image is None: @@ -495,7 +499,7 @@ def get_private_Images(self): images.append(image) return images except Exception as e: - LOG.exception("Get Images Error: {0}".format(e)) + LOG.exception(f"Get Images Error: {e}") return () def get_Image_with_Tag(self, id): @@ -505,7 +509,7 @@ def get_Image_with_Tag(self, id): :param id: Id of the image :return: Image instance """ - LOG.info("Get Image {0} with tags".format(id)) + LOG.info(f"Get Image {id} with tags") try: img = self.conn.get_image(name_or_id=id) if not img: @@ -526,7 +530,7 @@ def get_Image_with_Tag(self, id): ) return image except Exception as e: - LOG.exception("Get Image {0} with Tag Error: {1}".format(id, e)) + LOG.exception(f"Get Image {id} with Tag Error: {e}") return Image() def get_Images_by_filter(self, filter_list): @@ -535,14 +539,14 @@ def get_Images_by_filter(self, filter_list): :return: List of image instances. """ - LOG.info("Get filtered Images: {0}".format(filter_list)) + LOG.info(f"Get filtered Images: {filter_list}") images = list() try: for img in filter( - lambda x: "tags" in x - and len(x["tags"]) > 0 - and x["status"] == "active", - self.conn.list_images(), + lambda x: "tags" in x + and len(x["tags"]) > 0 + and x["status"] == "active", + self.conn.list_images(), ): tags = img.get("tags") if "resenv" in filter_list: @@ -554,7 +558,7 @@ def get_Images_by_filter(self, filter_list): description = metadata.get("description") image_type = img.get("image_type", "image") if description is None: - LOG.warning("No Description for {0}".format(img["name"])) + LOG.warning(f"No Description for {img['name']}") image = Image( name=img["name"], @@ -574,7 +578,7 @@ def get_Images_by_filter(self, filter_list): return images except Exception as e: - LOG.exception("Get Images Error: {0}".format(e)) + LOG.exception(f"Get Images Error: {e}") return () def delete_keypair(self, key_name): @@ -593,7 +597,7 @@ def import_keypair(self, keyname, public_key): try: keypair = self.conn.compute.find_keypair(keyname) if not keypair: - LOG.info("Create Keypair {0}".format(keyname)) + LOG.info(f"Create Keypair {keyname}") keypair = self.conn.compute.create_keypair( name=keyname, public_key=public_key @@ -608,7 +612,7 @@ def import_keypair(self, keyname, public_key): return keypair return keypair except Exception as e: - LOG.exception("Import Keypair {0} error:{1}".format(keyname, e)) + LOG.exception(f"Import Keypair {keyname} error:{e}") return None def openstack_flav_to_thrift_flav(self, flavor): @@ -650,11 +654,11 @@ def get_server(self, openstack_id): """ floating_ip = None fixed_ip = None - LOG.info("Get Server {0}".format(openstack_id)) + LOG.info(f"Get Server {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(f"No Server found {openstack_id} | Error {e}") return VM(status=self.NOT_FOUND) serv = server.to_dict() @@ -729,12 +733,12 @@ def get_server(self, openstack_id): def get_servers_by_ids(self, ids): servers = [] for id in ids: - LOG.info("Get server {}".format(id)) + LOG.info(f"Get server {id}") try: server = self.conn.get_server_by_id(id) servers.append(server) except Exception as e: - LOG.exception("Requested VM {} not found!\n {}".format(id, e)) + LOG.exception(f"Requested VM {id} not found!\n {e}") server_list = [] for server in servers: if server: @@ -742,13 +746,13 @@ def get_servers_by_ids(self, ids): return server_list def check_server_task_state(self, openstack_id): - LOG.info("Checking Task State: {}".format(openstack_id)) + LOG.info(f"Checking Task State: {openstack_id}") server = self.conn.get_server_by_id(openstack_id) LOG.info(server) if not server: return "No server found" task_state = server.get("task_state", None) - LOG.info("Task State: {}".format(task_state)) + LOG.info(f"Task State: {task_state}") if task_state: return task_state else: @@ -758,28 +762,26 @@ def get_image(self, image): image = self.conn.get_image(name_or_id=image) if image is None: - LOG.exception("Image {0} not found!".format(image)) - raise imageNotFoundException(Reason=("Image {0} not found".format(image))) + LOG.exception(f"Image {image} not found!") + raise imageNotFoundException(Reason=f"Image {image} not found") return image def get_flavor(self, flavor): flavor = self.conn.compute.find_flavor(flavor) if flavor is None: - LOG.exception("Flavor {0} not found!".format(flavor)) - raise flavorNotFoundException(Reason="Flavor {0} not found!".format(flavor)) + LOG.exception(f"Flavor {flavor} not found!") + raise flavorNotFoundException(Reason=f"Flavor {flavor} not found!") return flavor def get_network(self): network = self.conn.network.find_network(self.NETWORK) if network is None: - LOG.exception("Network {0} not found!".format(network)) - raise networkNotFoundException( - Reason="Network {0} not found!".format(network) - ) + LOG.exception(f"Network {network} not found!") + raise networkNotFoundException(Reason=f"Network {network} not found!") return network def create_add_keys_script(self, keys): - LOG.info(f"create add key script") + LOG.info("create add key script") fileDir = os.path.dirname(os.path.abspath(__file__)) key_script = os.path.join(fileDir, "scripts/bash/add_keys_to_authorized.sh") bash_keys_array = "(" @@ -795,9 +797,9 @@ def create_add_keys_script(self, keys): return key_script def create_mount_init_script( - self, volume_ids_path_new=None, volume_ids_path_attach=None + 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(f"create init script for volume ids:{volume_ids_path_new}") if not volume_ids_path_new and not volume_ids_path_attach: return None @@ -891,7 +893,7 @@ def get_or_refresh_token(self): "token": res.headers["X-Subject-Token"], "expires_at": expires_at, } - LOG.info("New Token: {}".format(self.API_TOKEN)) + LOG.info(f"New Token: {self.API_TOKEN}") else: LOG.info("Check existing token") now = datetime.datetime.now() @@ -901,9 +903,7 @@ def get_or_refresh_token(self): if now.time() > api_token_expires_at.time(): expired_since = api_token_expires_at - now LOG.info( - "Old token is expired since {} minutes!".format( - expired_since.seconds // 60 - ) + f"Old token is expired since {expired_since.seconds // 60} minutes!" ) self.API_TOKEN = None self.get_api_token() @@ -925,7 +925,7 @@ def create_volume(self, volume_name, volume_storage, metadata): :param volume_storage: volume_storage in GB for new volume :return: Id of new volume """ - LOG.info("Creating volume with {0} GB diskspace".format(volume_storage)) + LOG.info(f"Creating volume with {volume_storage} GB diskspace") try: volume = self.conn.block_storage.create_volume( @@ -935,26 +935,24 @@ def create_volume(self, volume_name, volume_storage, metadata): return {"volume_id": volume["id"]} except Exception as e: LOG.exception( - "Trying to create volume with {0} GB error : {1}".format( - volume_storage, e - ), + f"Trying to create volume with {volume_storage} GB error : {e}", exc_info=True, ) raise ressourceException(Reason=str(e)) def volume_ids( - self, - flavor, - image, - public_key, - servername, - metadata, - https, - http, - resenv, - volume_ids_path_new, - volume_ids_path_attach, + self, + flavor, + image, + public_key, + servername, + metadata, + https, + http, + resenv, + volume_ids_path_new, + volume_ids_path_attach, ): image = self.get_image(image=image) flavor = self.get_flavor(flavor=flavor) @@ -991,7 +989,7 @@ def volume_ids( self.delete_keypair(key_name) for security_group in custom_security_groups: self.conn.network.delete_security_group(security_group) - LOG.exception("Start Server {1} error:{0}".format(e, servername)) + LOG.exception(f"Start Server {servername} error:{e}") return {} def prepare_security_groups_new_server(self, resenv, servername, http, https): @@ -1027,18 +1025,18 @@ def prepare_security_groups_new_server(self, resenv, servername, http, https): return custom_security_groups def start_server_without_playbook( - self, - flavor, - image, - public_key, - servername, - metadata, - https, - http, - resenv, - volume_ids_path_new=None, - volume_ids_path_attach=None, - additional_keys=None, + self, + flavor, + image, + public_key, + servername, + metadata, + https, + http, + resenv, + volume_ids_path_new=None, + volume_ids_path_attach=None, + additional_keys=None, ): """ Start a new Server. @@ -1055,7 +1053,7 @@ def start_server_without_playbook( :param resenv: array with names of requested resenvs :return: {'openstackid': serverId, 'volumeId': volumeId} """ - LOG.info("Start Server {0}".format(servername)) + LOG.info(f"Start Server {servername}") custom_security_groups = self.prepare_security_groups_new_server( resenv=resenv, servername=servername, http=http, https=https ) @@ -1087,9 +1085,9 @@ def start_server_without_playbook( if init_script: add_key_script = self.create_add_keys_script(keys=additional_keys) init_script = ( - add_key_script - + encodeutils.safe_encode("\n".encode("utf-8")) - + init_script + add_key_script + + encodeutils.safe_encode("\n".encode("utf-8")) + + init_script ) else: @@ -1118,21 +1116,21 @@ def start_server_without_playbook( for security_group in custom_security_groups: self.conn.network.delete_security_group(security_group) - LOG.exception("Start Server {1} error:{0}".format(e, servername)) + LOG.exception(f"Start Server {servername} error:{e}") return {} def start_server( - self, - flavor, - image, - public_key, - servername, - metadata, - diskspace, - volumename, - https, - http, - resenv, + self, + flavor, + image, + public_key, + servername, + metadata, + diskspace, + volumename, + https, + http, + resenv, ): """ Start a new Server. @@ -1149,7 +1147,7 @@ def start_server( :param resenv: array with names of requested resenvs :return: {'openstackid': serverId, 'volumeId': volumeId} """ - LOG.info("Start Server {0}".format(servername)) + LOG.info(f"Start Server {servername}") custom_security_groups = self.prepare_security_groups_new_server( resenv=resenv, servername=servername, http=http, https=https ) @@ -1182,20 +1180,20 @@ def start_server( self.delete_keypair(key_name) for security_group in custom_security_groups: self.conn.network.delete_security_group(security_group) - LOG.exception("Start Server {1} error:{0}".format(e, servername)) + LOG.exception(f"Start Server {servername} error:{e}") return {} def start_server_with_custom_key( - self, - flavor, - image, - servername, - metadata, - http, - https, - resenv, - volume_ids_path_new=None, - volume_ids_path_attach=None, + self, + flavor, + image, + servername, + metadata, + http, + https, + resenv, + volume_ids_path_new=None, + volume_ids_path_attach=None, ): """ @@ -1210,7 +1208,7 @@ def start_server_with_custom_key( :param volumename: Name of the volume :return: {'openstackid': serverId, 'volumeId': volumeId} """ - LOG.info("Start Server {} with custom key".format(servername)) + LOG.info(f"Start Server {servername} with custom key") custom_security_groups = self.prepare_security_groups_new_server( resenv=resenv, servername=servername, http=http, https=https ) @@ -1267,14 +1265,14 @@ def start_server_with_custom_key( self.delete_keypair(key_name=servername) for security_group in custom_security_groups: self.conn.network.delete_security_group(security_group) - LOG.exception("Start Server {1} error:{0}".format(e, servername)) + LOG.exception(f"Start Server {servername} error:{e}") return {} def create_and_deploy_playbook( - self, public_key, playbooks_information, openstack_id + 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=f"Starting Playbook for (openstack_id): {openstack_id}") port = self.get_vm_ports(openstack_id=openstack_id) key = self.redis.hget(openstack_id, "key").decode("utf-8") playbook = Playbook( @@ -1303,7 +1301,7 @@ def get_forc_url(self): return f"https:{url[1]}/" def cross_check_forc_image(self, tags): - get_url = "{0}templates/".format(self.RE_BACKEND_URL) + get_url = f"{self.RE_BACKEND_URL}templates/" try: response = req.get( get_url, @@ -1316,12 +1314,12 @@ def cross_check_forc_image(self, tags): else: templates = response.json() except Exception as e: - LOG.error("Could not get templates from FORC.\n {0}".format(e)) + LOG.error(f"Could not get templates from FORC.\n {e}") cross_tags = list(set(self.ALL_TEMPLATES).intersection(tags)) for template_dict in templates: if ( - template_dict["name"] in self.FORC_ALLOWED - and template_dict["name"] in cross_tags + template_dict["name"] in self.FORC_ALLOWED + and template_dict["name"] in cross_tags ): if template_dict["version"] in self.FORC_ALLOWED[template_dict["name"]]: return True @@ -1337,7 +1335,7 @@ def create_backend(self, elixir_id, user_key_url, template, upstream_url): ) return {} try: - post_url = "{0}backends/".format(self.RE_BACKEND_URL) + post_url = f"{self.RE_BACKEND_URL}backends/" backend_info = { "owner": elixir_id, "user_key_url": user_key_url, @@ -1370,14 +1368,14 @@ def create_backend(self, elixir_id, user_key_url, template, upstream_url): template_version=data["template_version"], ) except Timeout as e: - LOG.info(msg="create_backend timed out. {0}".format(e)) + LOG.info(msg=f"create_backend timed out. {e}") return {} except Exception as e: LOG.exception(e) return {} def get_backends(self): - get_url = "{0}/backends/".format(self.RE_BACKEND_URL) + get_url = f"{self.RE_BACKEND_URL}/backends/" try: response = req.get( get_url, @@ -1401,11 +1399,11 @@ def get_backends(self): ) return backends except Timeout as e: - LOG.info(msg="create_backend timed out. {0}".format(e)) + LOG.info(msg=f"create_backend timed out. {e}") return None def get_backends_by_owner(self, elixir_id): - get_url = "{0}/backends/byOwner/{1}".format(self.RE_BACKEND_URL, elixir_id) + get_url = f"{self.RE_BACKEND_URL}/backends/byOwner/{elixir_id}" try: response = req.get( get_url, @@ -1429,11 +1427,11 @@ def get_backends_by_owner(self, elixir_id): ) return backends except Timeout as e: - LOG.info(msg="create_backend timed out. {0}".format(e)) + LOG.info(msg=f"create_backend timed out. {e}") return None def get_backends_by_template(self, template): - get_url = "{0}/backends/byTemplate/{1}".format(self.RE_BACKEND_URL, template) + get_url = f"{self.RE_BACKEND_URL}/backends/byTemplate/{template}" try: response = req.get( get_url, @@ -1457,11 +1455,11 @@ def get_backends_by_template(self, template): ) return backends except Timeout as e: - LOG.info(msg="create_backend timed out. {0}".format(e)) + LOG.info(msg=f"create_backend timed out. {e}") return None def get_backend_by_id(self, id): - get_url = "{0}/backends/{1}".format(self.RE_BACKEND_URL, id) + get_url = f"{self.RE_BACKEND_URL}/backends/{id}" try: response = req.get( get_url, @@ -1482,11 +1480,11 @@ def get_backend_by_id(self, id): template_version=data["template_version"], ) except Timeout as e: - LOG.info(msg="create_backend timed out. {0}".format(e)) + LOG.info(msg=f"create_backend timed out. {e}") return None def delete_backend(self, id): - delete_url = "{0}/backends/{1}".format(self.RE_BACKEND_URL, id) + delete_url = f"{self.RE_BACKEND_URL}/backends/{id}" try: response = req.delete( delete_url, @@ -1502,7 +1500,7 @@ def delete_backend(self, id): elif response.status_code == 200: return str(True) except Timeout as e: - LOG.info(msg="create_backend timed out. {0}".format(e)) + LOG.info(msg=f"create_backend timed out. {e}") return str(-1) except Exception as e: LOG.exception(e) @@ -1510,7 +1508,7 @@ def delete_backend(self, id): def add_user_to_backend(self, backend_id, owner_id, user_id): try: - post_url = "{0}users/{1}".format(self.RE_BACKEND_URL, backend_id) + post_url = f"{self.RE_BACKEND_URL}users/{backend_id}" user_info = { "owner": owner_id, "user": user_id, @@ -1533,14 +1531,14 @@ def add_user_to_backend(self, backend_id, owner_id, user_id): return {"Error": "Error in POST."} return data except Timeout as e: - LOG.info(msg="create_backend timed out. {0}".format(e)) + LOG.info(msg=f"create_backend timed out. {e}") return {"Error": "Timeout."} except Exception as e: LOG.exception(e) return {"Error": "An error occured."} def get_users_from_backend(self, backend_id): - get_url = "{0}/users/{1}".format(self.RE_BACKEND_URL, backend_id) + get_url = f"{self.RE_BACKEND_URL}/users/{backend_id}" try: response = req.get( get_url, @@ -1553,11 +1551,11 @@ def get_users_from_backend(self, backend_id): else: return response.json() except Timeout as e: - LOG.info(msg="Get users for backend timed out. {0}".format(e)) + LOG.info(msg=f"Get users for backend timed out. {e}") return [] def delete_user_from_backend(self, backend_id, owner_id, user_id): - delete_url = "{0}/users/{1}".format(self.RE_BACKEND_URL, backend_id) + delete_url = f"{self.RE_BACKEND_URL}/users/{backend_id}" user_info = { "owner": owner_id, "user": user_id, @@ -1572,7 +1570,7 @@ def delete_user_from_backend(self, backend_id, owner_id, user_id): ) return response.json() except Timeout as e: - LOG.info(msg="Delete user from backend timed out. {0}".format(e)) + LOG.info(msg=f"Delete user from backend timed out. {e}") return {"Error": "Timeout."} except Exception as e: LOG.exception(e) @@ -1624,7 +1622,7 @@ def get_allowed_templates(self): return templates_metada def get_templates_by_template(self, template_name): - get_url = "{0}/templates/{1}".format(self.RE_BACKEND_URL, template_name) + get_url = f"{self.RE_BACKEND_URL}/templates/{template_name}" try: response = req.get( get_url, @@ -1637,13 +1635,11 @@ def get_templates_by_template(self, template_name): else: return response.json() except Timeout as e: - LOG.info(msg="get_templates_by_template timed out. {0}".format(e)) + LOG.info(msg=f"get_templates_by_template timed out. {e}") return None def check_template(self, template_name, template_version): - get_url = "{0}/templates/{1}/{2}".format( - self.RE_BACKEND_URL, template_name, template_version - ) + get_url = f"{self.RE_BACKEND_URL}/templates/{template_name}/{template_version}" try: response = req.get( get_url, @@ -1656,7 +1652,7 @@ def check_template(self, template_name, template_version): else: return response.json() except Timeout as e: - LOG.info(msg="check_template timed out. {0}".format(e)) + LOG.info(msg=f"check_template timed out. {e}") return None def get_playbook_logs(self, openstack_id): @@ -1675,7 +1671,7 @@ def get_playbook_logs(self, openstack_id): return PlaybookResult(status=-2, stdout="", stderr="") def get_volumes_by_ids(self, volume_ids): - LOG.info("Get Volumes {}".format(volume_ids)) + LOG.info(f"Get Volumes {volume_ids}") volumes = [] for id in volume_ids: @@ -1698,12 +1694,12 @@ def get_volumes_by_ids(self, volume_ids): volumes.append(thrift_volume) except Exception: - LOG.exception("Could not find volume {}".format(id)) + LOG.exception(f"Could not find volume {id}") return volumes def get_volume(self, volume_id): - LOG.info("Get Volume {}".format(volume_id)) + LOG.info(f"Get Volume {volume_id}") try: os_volume = self.conn.get_volume_by_id(id=volume_id) @@ -1724,7 +1720,7 @@ def get_volume(self, volume_id): ) return thrift_volume except Exception: - LOG.exception("Could not find volume {}".format(id)) + LOG.exception(f"Could not find volume {id}") return Volume(status=self.NOT_FOUND) def attach_volume_to_server(self, openstack_id, volume_id): @@ -1738,12 +1734,10 @@ def attach_volume_to_server(self, openstack_id, volume_id): server = self.conn.compute.get_server(openstack_id) if server is None: - LOG.exception("No Server {0} ".format(openstack_id)) - raise serverNotFoundException(Reason="No Server {0}".format(openstack_id)) + LOG.exception(f"No Server {openstack_id} ") + raise serverNotFoundException(Reason=f"No Server {openstack_id}") - LOG.info( - "Attaching volume {0} to virtualmachine {1}".format(volume_id, openstack_id) - ) + LOG.info(f"Attaching volume {volume_id} to virtualmachine {openstack_id}") try: attachment = self.conn.compute.create_volume_attachment( server=server, volumeId=volume_id @@ -1751,17 +1745,13 @@ def attach_volume_to_server(self, openstack_id, volume_id): return {"device": attachment["device"]} except ConflictException as e: LOG.exception( - "Trying to attach volume {0} to vm {1} error : {2}".format( - volume_id, openstack_id, e - ), + f"Trying to attach volume {volume_id} to vm {openstack_id} error : {e}", exc_info=True, ) raise conflictException(Reason="409") except Exception as e: LOG.exception( - "Trying to attach volume {0} to vm {1} error : {2}".format( - volume_id, openstack_id, e - ), + f"Trying to attach volume {volume_id} to vm {openstack_id} error : {e}", exc_info=True, ) return {"error": e} @@ -1778,15 +1768,15 @@ def check_server_status(self, openstack_id): """ # TODO: Remove diskspace param, if volume_id exist it can be attached # diskspace not need - LOG.info("Check Status VM {0}".format(openstack_id)) + LOG.info(f"Check Status VM {openstack_id}") try: server = self.conn.compute.get_server(openstack_id) except Exception: - LOG.exception("No Server with id {0} ".format(openstack_id)) + LOG.exception(f"No Server with id {openstack_id} ") return VM(status=self.NOT_FOUND) if server is None: - LOG.exception("No Server with id {0} ".format(openstack_id)) + LOG.exception(f"No Server with id {openstack_id} ") return VM(status=self.NOT_FOUND) serv = server.to_dict() @@ -1799,7 +1789,7 @@ def check_server_status(self, openstack_id): if self.USE_GATEWAY: serv_cop = self.get_server(openstack_id) server_base = serv_cop.fixed_ip.split(".")[-1] - x = int(server_base) + int(server_base) host = str(self.GATEWAY_IP) port = eval(self.SSH_FORMULAR) elif self.get_server(openstack_id).floating_ip is None: @@ -1840,11 +1830,11 @@ 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(f"Check Status VM {openstack_id} error: {e}") return VM(status=self.ERROR) def openstack_server_to_thrift_server(self, server): - LOG.info("Convert server {} to thrift server".format(server)) + LOG.info(f"Convert server {server} to thrift server") fixed_ip = None floating_ip = None diskspace = 0 @@ -1856,7 +1846,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(f"Could not found volume {volume_id}: {e}") if server["OS-SRV-USG:launched_at"]: dt = datetime.datetime.strptime( @@ -1899,7 +1889,7 @@ def openstack_server_to_thrift_server(self, server): def get_servers(self): LOG.info("Get all servers") servers = self.conn.list_servers() - LOG.info("Found {} servers".format(len(servers))) + LOG.info(f"Found {len(servers)} servers") server_list = [] for server in servers: try: @@ -1907,10 +1897,8 @@ def get_servers(self): server_list.append(thrift_server) except Exception as e: - LOG.exception("Could not transform to thrift_server: {}".format(e)) - LOG.info( - "Converted {} servers to thrift_server objects".format(len(server_list)) - ) + LOG.exception(f"Could not transform to thrift_server: {e}") + LOG.info(f"Converted {len(server_list)} servers to thrift_server objects") # LOG.info(server_list) return server_list @@ -1924,17 +1912,15 @@ def add_udp_security_group(self, server_id): :param server_id: The id of the server :return: """ - LOG.info("Setting up UDP security group for {0}".format(server_id)) + LOG.info(f"Setting up UDP security group for {server_id}") server = self.conn.get_server(name_or_id=server_id) if server is None: - LOG.exception("Instance {0} not found".format(server_id)) + LOG.exception(f"Instance {server_id} not found") raise serverNotFoundException sec = self.conn.get_security_group(name_or_id=server.name + "_udp") if sec: LOG.info( - "UDP Security group with name {} already exists.".format( - server.name + "_udp" - ) + f"UDP Security group with name {server.name + '_udp'} already exists." ) server_security_groups = self.conn.list_server_security_groups(server) for sg in server_security_groups: @@ -1954,10 +1940,10 @@ def add_udp_security_group(self, server_id): ip_base = ( list(self.conn.compute.server_ips(server=server_id))[0] - .to_dict()["address"] - .split(".")[-1] + .to_dict()["address"] + .split(".")[-1] ) - x = int(ip_base) + int(ip_base) udp_port_start = eval(self.UDP_FORMULAR) security_group = self.create_security_group( @@ -1970,9 +1956,7 @@ def add_udp_security_group(self, server_id): description="UDP", ) LOG.info(security_group) - LOG.info( - "Add security group {} to server {} ".format(security_group.id, server_id) - ) + LOG.info(f"Add security group {security_group.id} to server {server_id} ") self.conn.compute.add_security_group_to_server( server=server_id, security_group=security_group ) @@ -1980,9 +1964,7 @@ def add_udp_security_group(self, server_id): return True def detach_ip_from_server(self, server_id, floating_ip): - LOG.info( - "Detaching floating ip {} from server {}".format(floating_ip, server_id) - ) + LOG.info(f"Detaching floating ip {floating_ip} from server {server_id}") try: self.conn.compute.remove_floating_ip_from_server( server=server_id, address=floating_ip @@ -1990,9 +1972,7 @@ def detach_ip_from_server(self, server_id, floating_ip): return True except Exception: LOG.exception( - "Could not detach floating ip {} from server {}".format( - floating_ip, server_id - ) + f"Could not detach floating ip {floating_ip} from server {server_id}" ) return False @@ -2011,10 +1991,10 @@ def get_vm_ports(self, openstack_id): :param openstack_id: Id of the server :return: {'PORT': port, 'UDP':start_port} """ - LOG.info("Get IP and PORT for server {0}".format(openstack_id)) + LOG.info(f"Get IP and PORT for server {openstack_id}") server = self.get_server(openstack_id) server_base = server.fixed_ip.split(".")[-1] - x = int(server_base) + int(server_base) port = eval(self.SSH_FORMULAR) udp_port_start = eval(self.UDP_FORMULAR) return {"port": str(port), "udp": str(udp_port_start)} @@ -2023,7 +2003,7 @@ def terminate_cluster(self, cluster_id): headers = {"content-Type": "application/json"} body = {"mode": "openstack"} response = req.delete( - url="{}terminate/{}".format(self.BIBIGRID_URL, cluster_id), + url=f"{self.BIBIGRID_URL}terminate/{cluster_id}", json=body, headers=headers, verify=self.PRODUCTION, @@ -2032,14 +2012,14 @@ def terminate_cluster(self, cluster_id): return response.json() def get_cluster_status(self, cluster_id): - LOG.info("Get Cluster {} status".format(cluster_id)) + LOG.info(f"Get Cluster {cluster_id} status") headers = {"content-Type": "application/json"} body = {"mode": "openstack"} request_url = self.BIBIGRID_URL + "info/" + cluster_id response = req.get( url=request_url, json=body, headers=headers, verify=self.PRODUCTION ) - LOG.info("Cluster {} status: {} ".format(cluster_id, response.content)) + LOG.info(f"Cluster {cluster_id} status: {response.content} ") json_resp = response.json(strict=False) json_resp["log"] = str(json_resp.get("log", "")) json_resp["msg"] = str(json_resp.get("msg", "")) @@ -2086,9 +2066,9 @@ def get_active_image_by_os_version(self, os_version, os_distro): image_os_distro = metadata.get("os_distro", None) base_image_ref = metadata.get("base_image_ref", None) if ( - os_version == image_os_version - and image.status == "active" - and base_image_ref is None + os_version == image_os_version + and image.status == "active" + and base_image_ref is None ): if os_distro and os_distro == image_os_distro: return image @@ -2107,16 +2087,16 @@ def create_deactivate_update_script(self): return deactivate_update_script def add_cluster_machine( - self, - cluster_id, - cluster_user, - cluster_group_id, - image, - flavor, - name, - key_name, - batch_idx, - worker_idx, + self, + cluster_id, + cluster_user, + cluster_group_id, + image, + flavor, + name, + key_name, + batch_idx, + worker_idx, ): LOG.info(f"Add machine to {cluster_id} - {key_name}") image = self.get_image(image=image) @@ -2140,9 +2120,9 @@ def add_cluster_machine( network = self.get_network() metadata = { "bibigrid-id": cluster_id, - "user": cluster_user or '', + "user": cluster_user or "", "worker-batch": str(batch_idx), - "name": name or '', + "name": name or "", "worker-index": str(worker_idx), } @@ -2157,12 +2137,12 @@ def add_cluster_machine( availability_zone=self.AVAIALABILITY_ZONE, security_groups=cluster_group_id, ) - LOG.info("Created cluster machine:{}".format(server["id"])) + LOG.info(f"Created cluster machine:{server['id']}") return server["id"] def scale_up_cluster( - self, cluster_id, image, flavor, count, names, start_idx, batch_index + self, cluster_id, image, flavor, count, names, start_idx, batch_index ): cluster_info = self.get_cluster_info(cluster_id=cluster_id) image = self.get_image(image=image) @@ -2196,7 +2176,7 @@ def scale_up_cluster( "worker-index": str(start_idx + i), } - LOG.info("Create cluster machine: {}".format(metadata)) + LOG.info(f"Create cluster machine: {metadata}") server = self.conn.create_server( name=names[i], @@ -2209,7 +2189,7 @@ def scale_up_cluster( availability_zone=self.AVAIALABILITY_ZONE, security_groups=cluster_info.group_id, ) - LOG.info("Created cluster machine:{}".format(server["id"])) + LOG.info(f"Created cluster machine:{server['id']}") openstack_ids.append(server["id"]) LOG.info(openstack_ids) @@ -2235,7 +2215,7 @@ def get_cluster_info(self, cluster_id): cluster_id=info["cluster-id"], key_name=info["key name"], ) - LOG.info("CLuster info : {}".format(cluster_info)) + LOG.info(f"CLuster info : {cluster_info}") return cluster_info return None @@ -2298,11 +2278,11 @@ 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(f"Create snapshot {openstack_id} error: {e}") raise conflictException(Reason="409") except Exception: - LOG.exception("Instance {0} not found".format(openstack_id)) + LOG.exception(f"Instance {openstack_id} not found") return None try: snapshot = self.conn.get_image_by_id(snapshot_munch["id"]) @@ -2344,18 +2324,16 @@ def delete_image(self, image_id): :param image_id: Id of the image :return: True if deleted, False if not """ - LOG.info("Delete Image {0}".format(image_id)) + LOG.info(f"Delete Image {image_id}") try: image = self.conn.compute.get_image(image_id) if image is None: - LOG.exception("Image {0} not found!".format(image)) - raise imageNotFoundException( - Reason=("Image {0} not found".format(image)) - ) + LOG.exception(f"Image {image} not found!") + raise imageNotFoundException(Reason=f"Image {image} not found") self.conn.compute.delete_image(image) return True except Exception as e: - LOG.exception("Delete Image {0} error : {1}".format(image_id, e)) + LOG.exception(f"Delete Image {image_id} error : {e}") return False def add_floating_ip_to_server(self, openstack_id, network): @@ -2370,7 +2348,7 @@ def add_floating_ip_to_server(self, openstack_id, network): server = self.conn.compute.get_server(openstack_id) if server is None: - LOG.exception("Instance {0} not found".format(openstack_id)) + LOG.exception(f"Instance {openstack_id} not found") raise serverNotFoundException LOG.info("Checking if Server already got an Floating Ip") for values in server.addresses.values(): @@ -2405,9 +2383,7 @@ def add_floating_ip_to_server(self, openstack_id, network): return floating_ip except Exception as e: LOG.exception( - "Adding Floating IP to {0} with network {1} error:{2}".format( - openstack_id, network, e - ) + f"Adding Floating IP to {openstack_id} with network {network} error:{e}" ) return None @@ -2419,12 +2395,10 @@ def netcat(self, host, port): :param port: Port to connect :return: True if successfully connected, False if not """ - LOG.info("Checking SSH Connection {0}:{1}".format(host, port)) + LOG.info(f"Checking SSH Connection {host}:{port}") with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: r = sock.connect_ex((host, port)) - LOG.info( - "Checking SSH Connection {0}:{1} Result = {2}".format(host, port, r) - ) + LOG.info(f"Checking SSH Connection {host}:{port} Result = {r}") if r == 0: return True else: @@ -2444,13 +2418,13 @@ def delete_server(self, openstack_id): if server is None: server = self.conn.compute.get_server(openstack_id) if server is None: - LOG.error("Instance {0} not found".format(openstack_id)) + LOG.error(f"Instance {openstack_id} not found") return False task_state = self.check_server_task_state(openstack_id) if ( - task_state == "image_snapshot" - or task_state == "image_pending_upload" - or task_state == "image_uploading" + task_state == "image_snapshot" + or task_state == "image_pending_upload" + or task_state == "image_uploading" ): raise ConflictException("task_state in image creating") security_groups = self.conn.list_server_security_groups(server=server) @@ -2459,11 +2433,11 @@ def delete_server(self, openstack_id): sec for sec in security_groups if sec.name != self.DEFAULT_SECURITY_GROUP_NAME - and not "bibigrid" in sec.name + and "bibigrid" not in sec.name ] if security_groups is not None: for sg in security_groups: - LOG.info("Delete security group {0}".format(sg.name)) + LOG.info(f"Delete security group {sg.name}") self.conn.compute.remove_security_group_from_server( server=server, security_group=sg ) @@ -2474,11 +2448,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(f"Delete Server {openstack_id} error: {e}") raise conflictException(Reason="409") except Exception as e: - LOG.exception("Delete Server {0} error: {1}".format(openstack_id, e)) + LOG.exception(f"Delete Server {openstack_id} error: {e}") return False def delete_volume_attachment(self, volume_id, server_id): @@ -2495,20 +2469,18 @@ def delete_volume_attachment(self, volume_id, server_id): volume_attachment_id = attachment["id"] instance_id = attachment["server_id"] if instance_id == server_id: - LOG.info( - "Delete Volume Attachment {0}".format(volume_attachment_id) - ) + LOG.info(f"Delete Volume Attachment {volume_attachment_id}") self.conn.compute.delete_volume_attachment( volume_attachment=volume_attachment_id, server=server_id ) return True - except ConflictException as e: + except ConflictException: LOG.exception( f"Delete volume attachment (server: {server_id} volume: {volume_id}) error" ) raise conflictException(Reason="409") - except Exception as e: + except Exception: LOG.exception(f"Delete Volume Attachment {volume_attachment_id} error") return False @@ -2521,14 +2493,14 @@ def delete_volume(self, volume_id): """ try: - LOG.info("Delete Volume {0}".format(volume_id)) + LOG.info(f"Delete Volume {volume_id}") self.conn.block_storage.delete_volume(volume=volume_id) return True - except ConflictException as e: + except ConflictException: LOG.exception(f"Delete volume {volume_id} error") raise conflictException(Reason="409") - except Exception as e: + except Exception: LOG.exception(f"Delete Volume {volume_id} error") return False @@ -2551,11 +2523,11 @@ def stop_server(self, openstack_id): return True else: return False - except ConflictException as e: + except ConflictException: LOG.exception(f"Stop Server {openstack_id} error") raise conflictException(Reason="409") - except Exception as e: + except Exception: LOG.exception(f"Stop Server {openstack_id} error:") return False @@ -2568,20 +2540,20 @@ def reboot_server(self, server_id, reboot_type): :param reboot_type: HARD or SOFT :return: True if resumed, False if not """ - LOG.info("Reboot Server {} {}".format(server_id, reboot_type)) + LOG.info(f"Reboot Server {server_id} {reboot_type}") try: server = self.conn.compute.get_server(server_id) if server is None: - LOG.exception("Instance {0} not found".format(server_id)) + LOG.exception(f"Instance {server_id} not found") raise serverNotFoundException else: self.conn.compute.reboot_server(server, reboot_type) return True - except ConflictException as e: + except ConflictException: LOG.exception(f"Reboot Server {server_id} error") raise conflictException(Reason="409") - except Exception as e: + except Exception: LOG.exception(f"Reboot Server {server_id} {reboot_type} Error") return False @@ -2592,11 +2564,11 @@ def resume_server(self, openstack_id): :param openstack_id: Id of the server. :return: True if resumed, False if not """ - LOG.info("Resume Server {0}".format(openstack_id)) + LOG.info(f"Resume Server {openstack_id}") try: server = self.conn.compute.get_server(openstack_id) if server is None: - LOG.exception("Instance {0} not found".format(openstack_id)) + LOG.exception(f"Instance {openstack_id} not found") raise serverNotFoundException if server.status == self.SHUTOFF: self.conn.compute.start_server(server) @@ -2612,26 +2584,26 @@ def resume_server(self, openstack_id): return False def create_security_group( - self, - name, - udp_port_start=None, - ssh=True, - http=False, - https=False, - udp=False, - description=None, - resenv=[], + self, + name, + udp_port_start=None, + ssh=True, + http=False, + https=False, + udp=False, + description=None, + resenv=[], ): - LOG.info("Create new security group {}".format(name)) + LOG.info(f"Create new security group {name}") sec = self.conn.get_security_group(name_or_id=name) if sec: - LOG.info("Security group with name {} already exists.".format(name)) + LOG.info(f"Security group with name {name} already exists.") return sec new_security_group = self.conn.create_security_group( name=name, description=description ) if http: - LOG.info("Add http rule to security group {}".format(name)) + LOG.info(f"Add http rule to security group {name}") self.conn.network.create_security_group_rule( direction="ingress", protocol="tcp", @@ -2649,7 +2621,7 @@ def create_security_group( ) if https: - LOG.info("Add https rule to security group {}".format(name)) + LOG.info(f"Add https rule to security group {name}") self.conn.network.create_security_group_rule( direction="ingress", @@ -2689,7 +2661,7 @@ def create_security_group( security_group_id=new_security_group["id"], ) if ssh: - LOG.info("Add ssh rule to security group {}".format(name)) + LOG.info(f"Add ssh rule to security group {name}") self.conn.network.create_security_group_rule( direction="ingress", @@ -2709,9 +2681,7 @@ def create_security_group( for research_enviroment in resenv: if research_enviroment in self.loaded_resenv_metadata: LOG.info( - "Add " - + research_enviroment - + " rule to security group {}".format(name) + "Add " + research_enviroment + f" rule to security group {name}" ) resenv_metadata = self.loaded_resenv_metadata[research_enviroment] self.conn.network.create_security_group_rule( @@ -2833,9 +2803,7 @@ def update_forc_allowed(self, template_metadata): name = template_metadata[TEMPLATE_NAME] allowed_versions = [] for forc_version in template_metadata[FORC_VERSIONS]: - get_url = "{0}/templates/{1}/{2}".format( - self.RE_BACKEND_URL, name, forc_version - ) + get_url = f"{self.RE_BACKEND_URL}/templates/{name}/{forc_version}" try: response = req.get( get_url, @@ -2846,7 +2814,7 @@ def update_forc_allowed(self, template_metadata): if response.status_code == 200: allowed_versions.append(forc_version) except Timeout as e: - LOG.info(msg="checking template/version timed out. {0}".format(e)) + LOG.info(msg=f"checking template/version timed out. {e}") allowed_versions.sort(key=LooseVersion) allowed_versions.reverse() self.FORC_ALLOWED[name] = allowed_versions @@ -2854,15 +2822,15 @@ def update_forc_allowed(self, template_metadata): class ResenvMetadata: def __init__( - self, - name, - port, - security_group_name, - security_group_description, - security_group_ssh, - direction, - protocol, - information_for_display, + self, + name, + port, + security_group_name, + security_group_description, + security_group_ssh, + direction, + protocol, + information_for_display, ): self.name = name self.port = port diff --git a/VirtualMachineService/VirtualMachineServer.py b/VirtualMachineService/VirtualMachineServer.py index fe8c4369..fce4c878 100644 --- a/VirtualMachineService/VirtualMachineServer.py +++ b/VirtualMachineService/VirtualMachineServer.py @@ -2,9 +2,9 @@ import sys try: - from VirtualMachineService.VirtualMachineService import Client, Processor + from VirtualMachineService.VirtualMachineService import Processor except Exception: - from VirtualMachineService import Client, Processor + from VirtualMachineService import Processor try: from VirtualMachineService.VirtualMachineHandler import VirtualMachineHandler @@ -12,15 +12,15 @@ print(e) from VirtualMachineHandler import VirtualMachineHandler -from thrift.transport import TSSLSocket, TSocket -from thrift.transport import TTransport -from thrift.protocol import TBinaryProtocol -from thrift.server import TServer -import yaml -import click import signal import ssl +import click +import yaml +from thrift.protocol import TBinaryProtocol +from thrift.server import TServer +from thrift.transport import TSocket, TSSLSocket, TTransport + USERNAME = "OS_USERNAME" PASSWORD = "OS_PASSWORD" PROJECT_NAME = "OS_PROJECT_NAME" @@ -46,11 +46,7 @@ @click.argument("config") def startServer(config): def catch_shutdown(signal, frame): - click.echo( - "Caught SIGTERM. Shutting down. Signal: {0} Frame: {1}".format( - signal, frame - ) - ) + click.echo(f"Caught SIGTERM. Shutting down. Signal: {signal} Frame: {frame}") handler.keyboard_interrupt_handler_playbooks() click.echo("SIGTERM was handled. Exiting with Exitcode: -1.") sys.exit(-1) @@ -67,7 +63,7 @@ def catch_shutdown(signal, frame): if USE_SSL: CERTFILE = cfg["openstack_connection"]["certfile"] THREADS = cfg["openstack_connection"]["threads"] - click.echo("Server is running on port {}".format(PORT)) + click.echo(f"Server is running on port {PORT}") handler = VirtualMachineHandler(CONFIG_FILE) processor = Processor(handler) if USE_SSL: @@ -92,7 +88,7 @@ def catch_shutdown(signal, frame): def check_environment_variables(envs): def check_env(var): if var not in os.environ: - click.echo("ERROR: There is no {} set in environment.".format(var)) + click.echo(f"ERROR: There is no {var} set in environment.") click.echo("Please make sure you have sourced your OpenStack rc file") sys.exit() diff --git a/VirtualMachineService/VirtualMachineService-remote b/VirtualMachineService/VirtualMachineService-remote index 86011e3d..db66f7f8 100755 --- a/VirtualMachineService/VirtualMachineService-remote +++ b/VirtualMachineService/VirtualMachineService-remote @@ -7,98 +7,127 @@ # options string: py # -import sys import pprint +import sys + if sys.version_info[0] > 2: from urllib.parse import urlparse else: from urlparse import urlparse -from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient + from thrift.protocol.TBinaryProtocol import TBinaryProtocol +from thrift.transport import THttpClient, TSocket, TSSLSocket, TTransport from VirtualMachineService import VirtualMachineService -from VirtualMachineService.ttypes import * - -if len(sys.argv) <= 1 or sys.argv[1] == '--help': - print('') - print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]') - print('') - print('Functions:') - print(' bool check_Version(double version)') - print(' string get_client_version()') - print(' get_gateway_ip()') - print(' get_calculation_formulars()') - print(' string import_keypair(string keyname, string public_key)') - print(' get_vm_ports(string openstack_id)') - print(' get_Flavors()') - print(' get_Images()') - print(' get_public_Images()') - print(' get_private_Images()') - print(' Image get_Image_with_Tag(string openstack_id)') - print(' get_Images_by_filter( filter_json)') - print(' Volume get_volume(string volume_id)') - print(' get_volumes_by_ids( volume_ids)') - print(' int resize_volume(string volume_id, int size)') - print(' bool delete_server(string openstack_id)') - print(' add_metadata_to_server(string servername, metadata)') - print(' delete_metadata_from_server(string servername, keys)') - print(' string add_floating_ip_to_server(string openstack_id, string network)') - print(' bool create_connection(string username, string password, string auth_url, string user_domain_name, string project_domain_name)') - print(' start_server_without_playbook(string flavor, string image, string public_key, string servername, metadata, bool https, bool http, resenv, volume_ids_path_new, volume_ids_path_attach, additional_keys)') - print(' bool bibigrid_available()') - print(' bool detach_ip_from_server(string server_id, string floating_ip)') - print(' start_server_with_mounted_volume(string flavor, string image, string public_key, string servername, metadata, bool https, bool http, resenv, volume_ids_path_new, volume_ids_path_attach)') - print(' start_server(string flavor, string image, string public_key, string servername, metadata, string diskspace, string volumename, bool https, bool http, resenv)') - print(' start_server_with_custom_key(string flavor, string image, string servername, metadata, bool http, bool https, resenv, volume_ids_path_new, volume_ids_path_attach)') - print(' bool exist_server(string name)') - print(' int create_and_deploy_playbook(string public_key, playbooks_information, string openstack_id)') - print(' PlaybookResult get_playbook_logs(string openstack_id)') - print(' bool has_forc()') - print(' string get_forc_url()') - print(' Backend create_backend(string elixir_id, string user_key_url, string template, string upstream_url)') - print(' get_backends()') - print(' get_backends_by_owner(string elixir_id)') - print(' get_backends_by_template(string template)') - print(' Backend get_backend_by_id(i64 id)') - print(' string delete_backend(i64 id)') - print(' add_user_to_backend(i64 backend_id, string owner_id, string user_id)') - print(' get_users_from_backend(i64 backend_id)') - print(' delete_user_from_backend(i64 backend_id, string owner_id, string user_id)') - print(' get_templates()') - print(' get_allowed_templates()') - print(' get_templates_by_template(string template_name)') - print(' check_template(string template_name, string template_version)') - print(' bool add_udp_security_group(string server_id)') - print(' get_servers()') - print(' get_servers_by_ids( server_ids)') - print(' string check_server_task_state(string openstack_id)') - print(' get_servers_by_bibigrid_id(string bibigrid_id)') - print(' scale_up_cluster(string cluster_id, string image, string flavor, int count, names, int start_idx, int batch_idx)') - print(' string add_cluster_machine(string cluster_id, string cluster_user, string cluster_group_id, string image, string flavor, string name, string key_name, int batch_idx, int worker_idx)') - print(' ClusterInfo get_cluster_info(string cluster_id)') - print(' get_cluster_status(string cluster_id)') - print(' VM get_server(string openstack_id)') - print(' bool stop_server(string openstack_id)') - print(' string create_snapshot(string openstack_id, string name, string elixir_id, base_tags, string description)') - print(' get_limits()') - print(' start_cluster(string public_key, ClusterInstance master_instance, worker_instance, string user)') - print(' terminate_cluster(string cluster_id)') - print(' bool delete_image(string image_id)') - print(' bool delete_volume_attachment(string volume_id, string server_id)') - print(' bool delete_volume(string volume_id)') - print(' attach_volume_to_server(string openstack_id, string volume_id)') - print(' VM check_server_status(string openstack_id)') - print(' string setUserPassword(string user, string password)') - print(' bool resume_server(string openstack_id)') - print(' create_volume(string volume_name, int volume_storage, metadata)') - print(' bool reboot_server(string server_id, string reboot_type)') - print('') + +if len(sys.argv) <= 1 or sys.argv[1] == "--help": + print("") + print( + "Usage: " + + sys.argv[0] + + " [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]" + ) + print("") + print("Functions:") + print(" bool check_Version(double version)") + print(" string get_client_version()") + print(" get_gateway_ip()") + print(" get_calculation_formulars()") + print(" string import_keypair(string keyname, string public_key)") + print(" get_vm_ports(string openstack_id)") + print(" get_Flavors()") + print(" get_Images()") + print(" get_public_Images()") + print(" get_private_Images()") + print(" Image get_Image_with_Tag(string openstack_id)") + print(" get_Images_by_filter( filter_json)") + print(" Volume get_volume(string volume_id)") + print(" get_volumes_by_ids( volume_ids)") + print(" int resize_volume(string volume_id, int size)") + print(" bool delete_server(string openstack_id)") + print(" add_metadata_to_server(string servername, metadata)") + print(" delete_metadata_from_server(string servername, keys)") + print(" string add_floating_ip_to_server(string openstack_id, string network)") + print( + " bool create_connection(string username, string password, string auth_url, string user_domain_name, string project_domain_name)" + ) + print( + " start_server_without_playbook(string flavor, string image, string public_key, string servername, metadata, bool https, bool http, resenv, volume_ids_path_new, volume_ids_path_attach, additional_keys)" + ) + print(" bool bibigrid_available()") + print(" bool detach_ip_from_server(string server_id, string floating_ip)") + print( + " start_server_with_mounted_volume(string flavor, string image, string public_key, string servername, metadata, bool https, bool http, resenv, volume_ids_path_new, volume_ids_path_attach)" + ) + print( + " start_server(string flavor, string image, string public_key, string servername, metadata, string diskspace, string volumename, bool https, bool http, resenv)" + ) + print( + " start_server_with_custom_key(string flavor, string image, string servername, metadata, bool http, bool https, resenv, volume_ids_path_new, volume_ids_path_attach)" + ) + print(" bool exist_server(string name)") + print( + " int create_and_deploy_playbook(string public_key, playbooks_information, string openstack_id)" + ) + print(" PlaybookResult get_playbook_logs(string openstack_id)") + print(" bool has_forc()") + print(" string get_forc_url()") + print( + " Backend create_backend(string elixir_id, string user_key_url, string template, string upstream_url)" + ) + print(" get_backends()") + print(" get_backends_by_owner(string elixir_id)") + print(" get_backends_by_template(string template)") + print(" Backend get_backend_by_id(i64 id)") + print(" string delete_backend(i64 id)") + print(" add_user_to_backend(i64 backend_id, string owner_id, string user_id)") + print(" get_users_from_backend(i64 backend_id)") + print( + " delete_user_from_backend(i64 backend_id, string owner_id, string user_id)" + ) + print(" get_templates()") + print(" get_allowed_templates()") + print(" get_templates_by_template(string template_name)") + print(" check_template(string template_name, string template_version)") + print(" bool add_udp_security_group(string server_id)") + print(" get_servers()") + print(" get_servers_by_ids( server_ids)") + print(" string check_server_task_state(string openstack_id)") + print(" get_servers_by_bibigrid_id(string bibigrid_id)") + print( + " scale_up_cluster(string cluster_id, string image, string flavor, int count, names, int start_idx, int batch_idx)" + ) + print( + " string add_cluster_machine(string cluster_id, string cluster_user, string cluster_group_id, string image, string flavor, string name, string key_name, int batch_idx, int worker_idx)" + ) + print(" ClusterInfo get_cluster_info(string cluster_id)") + print(" get_cluster_status(string cluster_id)") + print(" VM get_server(string openstack_id)") + print(" bool stop_server(string openstack_id)") + print( + " string create_snapshot(string openstack_id, string name, string elixir_id, base_tags, string description)" + ) + print(" get_limits()") + print( + " start_cluster(string public_key, ClusterInstance master_instance, worker_instance, string user)" + ) + print(" terminate_cluster(string cluster_id)") + print(" bool delete_image(string image_id)") + print(" bool delete_volume_attachment(string volume_id, string server_id)") + print(" bool delete_volume(string volume_id)") + print(" attach_volume_to_server(string openstack_id, string volume_id)") + print(" VM check_server_status(string openstack_id)") + print(" string setUserPassword(string user, string password)") + print(" bool resume_server(string openstack_id)") + print(" create_volume(string volume_name, int volume_storage, metadata)") + print(" bool reboot_server(string server_id, string reboot_type)") + print("") sys.exit(0) pp = pprint.PrettyPrinter(indent=2) -host = 'localhost' +host = "localhost" port = 9090 -uri = '' +uri = "" framed = False ssl = False validate = True @@ -108,16 +137,16 @@ certfile = None http = False argi = 1 -if sys.argv[argi] == '-h': - parts = sys.argv[argi + 1].split(':') +if sys.argv[argi] == "-h": + parts = sys.argv[argi + 1].split(":") host = parts[0] if len(parts) > 1: port = int(parts[1]) argi += 2 -if sys.argv[argi] == '-u': +if sys.argv[argi] == "-u": url = urlparse(sys.argv[argi + 1]) - parts = url[1].split(':') + parts = url[1].split(":") host = parts[0] if len(parts) > 1: port = int(parts[1]) @@ -125,42 +154,49 @@ if sys.argv[argi] == '-u': port = 80 uri = url[2] if url[4]: - uri += '?%s' % url[4] + uri += f"?{url[4]}" http = True argi += 2 -if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed': +if sys.argv[argi] == "-f" or sys.argv[argi] == "-framed": framed = True argi += 1 -if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl': +if sys.argv[argi] == "-s" or sys.argv[argi] == "-ssl": ssl = True argi += 1 -if sys.argv[argi] == '-novalidate': +if sys.argv[argi] == "-novalidate": validate = False argi += 1 -if sys.argv[argi] == '-ca_certs': - ca_certs = sys.argv[argi+1] +if sys.argv[argi] == "-ca_certs": + ca_certs = sys.argv[argi + 1] argi += 2 -if sys.argv[argi] == '-keyfile': - keyfile = sys.argv[argi+1] +if sys.argv[argi] == "-keyfile": + keyfile = sys.argv[argi + 1] argi += 2 -if sys.argv[argi] == '-certfile': - certfile = sys.argv[argi+1] +if sys.argv[argi] == "-certfile": + certfile = sys.argv[argi + 1] argi += 2 cmd = sys.argv[argi] -args = sys.argv[argi + 1:] +args = sys.argv[argi + 1 :] if http: transport = THttpClient.THttpClient(host, port, uri) else: if ssl: - socket = TSSLSocket.TSSLSocket(host, port, validate=validate, ca_certs=ca_certs, keyfile=keyfile, certfile=certfile) + socket = TSSLSocket.TSSLSocket( + host, + port, + validate=validate, + ca_certs=ca_certs, + keyfile=keyfile, + certfile=certfile, + ) else: socket = TSocket.TSocket(host, port) if framed: @@ -171,416 +207,711 @@ protocol = TBinaryProtocol(transport) client = VirtualMachineService.Client(protocol) transport.open() -if cmd == 'check_Version': +if cmd == "check_Version": if len(args) != 1: - print('check_Version requires 1 args') + print("check_Version requires 1 args") sys.exit(1) - pp.pprint(client.check_Version(eval(args[0]),)) + pp.pprint( + client.check_Version( + eval(args[0]), + ) + ) -elif cmd == 'get_client_version': +elif cmd == "get_client_version": if len(args) != 0: - print('get_client_version requires 0 args') + print("get_client_version requires 0 args") sys.exit(1) pp.pprint(client.get_client_version()) -elif cmd == 'get_gateway_ip': +elif cmd == "get_gateway_ip": if len(args) != 0: - print('get_gateway_ip requires 0 args') + print("get_gateway_ip requires 0 args") sys.exit(1) pp.pprint(client.get_gateway_ip()) -elif cmd == 'get_calculation_formulars': +elif cmd == "get_calculation_formulars": if len(args) != 0: - print('get_calculation_formulars requires 0 args') + print("get_calculation_formulars requires 0 args") sys.exit(1) pp.pprint(client.get_calculation_formulars()) -elif cmd == 'import_keypair': +elif cmd == "import_keypair": if len(args) != 2: - print('import_keypair requires 2 args') + print("import_keypair requires 2 args") sys.exit(1) - pp.pprint(client.import_keypair(args[0], args[1],)) + pp.pprint( + client.import_keypair( + args[0], + args[1], + ) + ) -elif cmd == 'get_vm_ports': +elif cmd == "get_vm_ports": if len(args) != 1: - print('get_vm_ports requires 1 args') + print("get_vm_ports requires 1 args") sys.exit(1) - pp.pprint(client.get_vm_ports(args[0],)) + pp.pprint( + client.get_vm_ports( + args[0], + ) + ) -elif cmd == 'get_Flavors': +elif cmd == "get_Flavors": if len(args) != 0: - print('get_Flavors requires 0 args') + print("get_Flavors requires 0 args") sys.exit(1) pp.pprint(client.get_Flavors()) -elif cmd == 'get_Images': +elif cmd == "get_Images": if len(args) != 0: - print('get_Images requires 0 args') + print("get_Images requires 0 args") sys.exit(1) pp.pprint(client.get_Images()) -elif cmd == 'get_public_Images': +elif cmd == "get_public_Images": if len(args) != 0: - print('get_public_Images requires 0 args') + print("get_public_Images requires 0 args") sys.exit(1) pp.pprint(client.get_public_Images()) -elif cmd == 'get_private_Images': +elif cmd == "get_private_Images": if len(args) != 0: - print('get_private_Images requires 0 args') + print("get_private_Images requires 0 args") sys.exit(1) pp.pprint(client.get_private_Images()) -elif cmd == 'get_Image_with_Tag': +elif cmd == "get_Image_with_Tag": if len(args) != 1: - print('get_Image_with_Tag requires 1 args') + print("get_Image_with_Tag requires 1 args") sys.exit(1) - pp.pprint(client.get_Image_with_Tag(args[0],)) + pp.pprint( + client.get_Image_with_Tag( + args[0], + ) + ) -elif cmd == 'get_Images_by_filter': +elif cmd == "get_Images_by_filter": if len(args) != 1: - print('get_Images_by_filter requires 1 args') + print("get_Images_by_filter requires 1 args") sys.exit(1) - pp.pprint(client.get_Images_by_filter(eval(args[0]),)) + pp.pprint( + client.get_Images_by_filter( + eval(args[0]), + ) + ) -elif cmd == 'get_volume': +elif cmd == "get_volume": if len(args) != 1: - print('get_volume requires 1 args') + print("get_volume requires 1 args") sys.exit(1) - pp.pprint(client.get_volume(args[0],)) + pp.pprint( + client.get_volume( + args[0], + ) + ) -elif cmd == 'get_volumes_by_ids': +elif cmd == "get_volumes_by_ids": if len(args) != 1: - print('get_volumes_by_ids requires 1 args') + print("get_volumes_by_ids requires 1 args") sys.exit(1) - pp.pprint(client.get_volumes_by_ids(eval(args[0]),)) + pp.pprint( + client.get_volumes_by_ids( + eval(args[0]), + ) + ) -elif cmd == 'resize_volume': +elif cmd == "resize_volume": if len(args) != 2: - print('resize_volume requires 2 args') + print("resize_volume requires 2 args") sys.exit(1) - pp.pprint(client.resize_volume(args[0], eval(args[1]),)) + pp.pprint( + client.resize_volume( + args[0], + eval(args[1]), + ) + ) -elif cmd == 'delete_server': +elif cmd == "delete_server": if len(args) != 1: - print('delete_server requires 1 args') + print("delete_server requires 1 args") sys.exit(1) - pp.pprint(client.delete_server(args[0],)) + pp.pprint( + client.delete_server( + args[0], + ) + ) -elif cmd == 'add_metadata_to_server': +elif cmd == "add_metadata_to_server": if len(args) != 2: - print('add_metadata_to_server requires 2 args') + print("add_metadata_to_server requires 2 args") sys.exit(1) - pp.pprint(client.add_metadata_to_server(args[0], eval(args[1]),)) + pp.pprint( + client.add_metadata_to_server( + args[0], + eval(args[1]), + ) + ) -elif cmd == 'delete_metadata_from_server': +elif cmd == "delete_metadata_from_server": if len(args) != 2: - print('delete_metadata_from_server requires 2 args') + print("delete_metadata_from_server requires 2 args") sys.exit(1) - pp.pprint(client.delete_metadata_from_server(args[0], eval(args[1]),)) + pp.pprint( + client.delete_metadata_from_server( + args[0], + eval(args[1]), + ) + ) -elif cmd == 'add_floating_ip_to_server': +elif cmd == "add_floating_ip_to_server": if len(args) != 2: - print('add_floating_ip_to_server requires 2 args') + print("add_floating_ip_to_server requires 2 args") sys.exit(1) - pp.pprint(client.add_floating_ip_to_server(args[0], args[1],)) + pp.pprint( + client.add_floating_ip_to_server( + args[0], + args[1], + ) + ) -elif cmd == 'create_connection': +elif cmd == "create_connection": if len(args) != 5: - print('create_connection requires 5 args') - sys.exit(1) - pp.pprint(client.create_connection(args[0], args[1], args[2], args[3], args[4],)) - -elif cmd == 'start_server_without_playbook': + print("create_connection requires 5 args") + sys.exit(1) + pp.pprint( + client.create_connection( + args[0], + args[1], + args[2], + args[3], + args[4], + ) + ) + +elif cmd == "start_server_without_playbook": if len(args) != 11: - print('start_server_without_playbook requires 11 args') - sys.exit(1) - pp.pprint(client.start_server_without_playbook(args[0], args[1], args[2], args[3], eval(args[4]), eval(args[5]), eval(args[6]), eval(args[7]), eval(args[8]), eval(args[9]), eval(args[10]),)) - -elif cmd == 'bibigrid_available': + print("start_server_without_playbook requires 11 args") + sys.exit(1) + pp.pprint( + client.start_server_without_playbook( + args[0], + args[1], + args[2], + args[3], + eval(args[4]), + eval(args[5]), + eval(args[6]), + eval(args[7]), + eval(args[8]), + eval(args[9]), + eval(args[10]), + ) + ) + +elif cmd == "bibigrid_available": if len(args) != 0: - print('bibigrid_available requires 0 args') + print("bibigrid_available requires 0 args") sys.exit(1) pp.pprint(client.bibigrid_available()) -elif cmd == 'detach_ip_from_server': +elif cmd == "detach_ip_from_server": if len(args) != 2: - print('detach_ip_from_server requires 2 args') + print("detach_ip_from_server requires 2 args") sys.exit(1) - pp.pprint(client.detach_ip_from_server(args[0], args[1],)) + pp.pprint( + client.detach_ip_from_server( + args[0], + args[1], + ) + ) -elif cmd == 'start_server_with_mounted_volume': +elif cmd == "start_server_with_mounted_volume": if len(args) != 10: - print('start_server_with_mounted_volume requires 10 args') - sys.exit(1) - pp.pprint(client.start_server_with_mounted_volume(args[0], args[1], args[2], args[3], eval(args[4]), eval(args[5]), eval(args[6]), eval(args[7]), eval(args[8]), eval(args[9]),)) - -elif cmd == 'start_server': + print("start_server_with_mounted_volume requires 10 args") + sys.exit(1) + pp.pprint( + client.start_server_with_mounted_volume( + args[0], + args[1], + args[2], + args[3], + eval(args[4]), + eval(args[5]), + eval(args[6]), + eval(args[7]), + eval(args[8]), + eval(args[9]), + ) + ) + +elif cmd == "start_server": if len(args) != 10: - print('start_server requires 10 args') - sys.exit(1) - pp.pprint(client.start_server(args[0], args[1], args[2], args[3], eval(args[4]), args[5], args[6], eval(args[7]), eval(args[8]), eval(args[9]),)) - -elif cmd == 'start_server_with_custom_key': + print("start_server requires 10 args") + sys.exit(1) + pp.pprint( + client.start_server( + args[0], + args[1], + args[2], + args[3], + eval(args[4]), + args[5], + args[6], + eval(args[7]), + eval(args[8]), + eval(args[9]), + ) + ) + +elif cmd == "start_server_with_custom_key": if len(args) != 9: - print('start_server_with_custom_key requires 9 args') - sys.exit(1) - pp.pprint(client.start_server_with_custom_key(args[0], args[1], args[2], eval(args[3]), eval(args[4]), eval(args[5]), eval(args[6]), eval(args[7]), eval(args[8]),)) - -elif cmd == 'exist_server': + print("start_server_with_custom_key requires 9 args") + sys.exit(1) + pp.pprint( + client.start_server_with_custom_key( + args[0], + args[1], + args[2], + eval(args[3]), + eval(args[4]), + eval(args[5]), + eval(args[6]), + eval(args[7]), + eval(args[8]), + ) + ) + +elif cmd == "exist_server": if len(args) != 1: - print('exist_server requires 1 args') + print("exist_server requires 1 args") sys.exit(1) - pp.pprint(client.exist_server(args[0],)) + pp.pprint( + client.exist_server( + args[0], + ) + ) -elif cmd == 'create_and_deploy_playbook': +elif cmd == "create_and_deploy_playbook": if len(args) != 3: - print('create_and_deploy_playbook requires 3 args') + print("create_and_deploy_playbook requires 3 args") sys.exit(1) - pp.pprint(client.create_and_deploy_playbook(args[0], eval(args[1]), args[2],)) + pp.pprint( + client.create_and_deploy_playbook( + args[0], + eval(args[1]), + args[2], + ) + ) -elif cmd == 'get_playbook_logs': +elif cmd == "get_playbook_logs": if len(args) != 1: - print('get_playbook_logs requires 1 args') + print("get_playbook_logs requires 1 args") sys.exit(1) - pp.pprint(client.get_playbook_logs(args[0],)) + pp.pprint( + client.get_playbook_logs( + args[0], + ) + ) -elif cmd == 'has_forc': +elif cmd == "has_forc": if len(args) != 0: - print('has_forc requires 0 args') + print("has_forc requires 0 args") sys.exit(1) pp.pprint(client.has_forc()) -elif cmd == 'get_forc_url': +elif cmd == "get_forc_url": if len(args) != 0: - print('get_forc_url requires 0 args') + print("get_forc_url requires 0 args") sys.exit(1) pp.pprint(client.get_forc_url()) -elif cmd == 'create_backend': +elif cmd == "create_backend": if len(args) != 4: - print('create_backend requires 4 args') - sys.exit(1) - pp.pprint(client.create_backend(args[0], args[1], args[2], args[3],)) - -elif cmd == 'get_backends': + print("create_backend requires 4 args") + sys.exit(1) + pp.pprint( + client.create_backend( + args[0], + args[1], + args[2], + args[3], + ) + ) + +elif cmd == "get_backends": if len(args) != 0: - print('get_backends requires 0 args') + print("get_backends requires 0 args") sys.exit(1) pp.pprint(client.get_backends()) -elif cmd == 'get_backends_by_owner': +elif cmd == "get_backends_by_owner": if len(args) != 1: - print('get_backends_by_owner requires 1 args') + print("get_backends_by_owner requires 1 args") sys.exit(1) - pp.pprint(client.get_backends_by_owner(args[0],)) + pp.pprint( + client.get_backends_by_owner( + args[0], + ) + ) -elif cmd == 'get_backends_by_template': +elif cmd == "get_backends_by_template": if len(args) != 1: - print('get_backends_by_template requires 1 args') + print("get_backends_by_template requires 1 args") sys.exit(1) - pp.pprint(client.get_backends_by_template(args[0],)) + pp.pprint( + client.get_backends_by_template( + args[0], + ) + ) -elif cmd == 'get_backend_by_id': +elif cmd == "get_backend_by_id": if len(args) != 1: - print('get_backend_by_id requires 1 args') + print("get_backend_by_id requires 1 args") sys.exit(1) - pp.pprint(client.get_backend_by_id(eval(args[0]),)) + pp.pprint( + client.get_backend_by_id( + eval(args[0]), + ) + ) -elif cmd == 'delete_backend': +elif cmd == "delete_backend": if len(args) != 1: - print('delete_backend requires 1 args') + print("delete_backend requires 1 args") sys.exit(1) - pp.pprint(client.delete_backend(eval(args[0]),)) + pp.pprint( + client.delete_backend( + eval(args[0]), + ) + ) -elif cmd == 'add_user_to_backend': +elif cmd == "add_user_to_backend": if len(args) != 3: - print('add_user_to_backend requires 3 args') + print("add_user_to_backend requires 3 args") sys.exit(1) - pp.pprint(client.add_user_to_backend(eval(args[0]), args[1], args[2],)) + pp.pprint( + client.add_user_to_backend( + eval(args[0]), + args[1], + args[2], + ) + ) -elif cmd == 'get_users_from_backend': +elif cmd == "get_users_from_backend": if len(args) != 1: - print('get_users_from_backend requires 1 args') + print("get_users_from_backend requires 1 args") sys.exit(1) - pp.pprint(client.get_users_from_backend(eval(args[0]),)) + pp.pprint( + client.get_users_from_backend( + eval(args[0]), + ) + ) -elif cmd == 'delete_user_from_backend': +elif cmd == "delete_user_from_backend": if len(args) != 3: - print('delete_user_from_backend requires 3 args') + print("delete_user_from_backend requires 3 args") sys.exit(1) - pp.pprint(client.delete_user_from_backend(eval(args[0]), args[1], args[2],)) + pp.pprint( + client.delete_user_from_backend( + eval(args[0]), + args[1], + args[2], + ) + ) -elif cmd == 'get_templates': +elif cmd == "get_templates": if len(args) != 0: - print('get_templates requires 0 args') + print("get_templates requires 0 args") sys.exit(1) pp.pprint(client.get_templates()) -elif cmd == 'get_allowed_templates': +elif cmd == "get_allowed_templates": if len(args) != 0: - print('get_allowed_templates requires 0 args') + print("get_allowed_templates requires 0 args") sys.exit(1) pp.pprint(client.get_allowed_templates()) -elif cmd == 'get_templates_by_template': +elif cmd == "get_templates_by_template": if len(args) != 1: - print('get_templates_by_template requires 1 args') + print("get_templates_by_template requires 1 args") sys.exit(1) - pp.pprint(client.get_templates_by_template(args[0],)) + pp.pprint( + client.get_templates_by_template( + args[0], + ) + ) -elif cmd == 'check_template': +elif cmd == "check_template": if len(args) != 2: - print('check_template requires 2 args') + print("check_template requires 2 args") sys.exit(1) - pp.pprint(client.check_template(args[0], args[1],)) + pp.pprint( + client.check_template( + args[0], + args[1], + ) + ) -elif cmd == 'add_udp_security_group': +elif cmd == "add_udp_security_group": if len(args) != 1: - print('add_udp_security_group requires 1 args') + print("add_udp_security_group requires 1 args") sys.exit(1) - pp.pprint(client.add_udp_security_group(args[0],)) + pp.pprint( + client.add_udp_security_group( + args[0], + ) + ) -elif cmd == 'get_servers': +elif cmd == "get_servers": if len(args) != 0: - print('get_servers requires 0 args') + print("get_servers requires 0 args") sys.exit(1) pp.pprint(client.get_servers()) -elif cmd == 'get_servers_by_ids': +elif cmd == "get_servers_by_ids": if len(args) != 1: - print('get_servers_by_ids requires 1 args') + print("get_servers_by_ids requires 1 args") sys.exit(1) - pp.pprint(client.get_servers_by_ids(eval(args[0]),)) + pp.pprint( + client.get_servers_by_ids( + eval(args[0]), + ) + ) -elif cmd == 'check_server_task_state': +elif cmd == "check_server_task_state": if len(args) != 1: - print('check_server_task_state requires 1 args') + print("check_server_task_state requires 1 args") sys.exit(1) - pp.pprint(client.check_server_task_state(args[0],)) + pp.pprint( + client.check_server_task_state( + args[0], + ) + ) -elif cmd == 'get_servers_by_bibigrid_id': +elif cmd == "get_servers_by_bibigrid_id": if len(args) != 1: - print('get_servers_by_bibigrid_id requires 1 args') + print("get_servers_by_bibigrid_id requires 1 args") sys.exit(1) - pp.pprint(client.get_servers_by_bibigrid_id(args[0],)) + pp.pprint( + client.get_servers_by_bibigrid_id( + args[0], + ) + ) -elif cmd == 'scale_up_cluster': +elif cmd == "scale_up_cluster": if len(args) != 7: - print('scale_up_cluster requires 7 args') - sys.exit(1) - pp.pprint(client.scale_up_cluster(args[0], args[1], args[2], eval(args[3]), eval(args[4]), eval(args[5]), eval(args[6]),)) - -elif cmd == 'add_cluster_machine': + print("scale_up_cluster requires 7 args") + sys.exit(1) + pp.pprint( + client.scale_up_cluster( + args[0], + args[1], + args[2], + eval(args[3]), + eval(args[4]), + eval(args[5]), + eval(args[6]), + ) + ) + +elif cmd == "add_cluster_machine": if len(args) != 9: - print('add_cluster_machine requires 9 args') - sys.exit(1) - pp.pprint(client.add_cluster_machine(args[0], args[1], args[2], args[3], args[4], args[5], args[6], eval(args[7]), eval(args[8]),)) - -elif cmd == 'get_cluster_info': + print("add_cluster_machine requires 9 args") + sys.exit(1) + pp.pprint( + client.add_cluster_machine( + args[0], + args[1], + args[2], + args[3], + args[4], + args[5], + args[6], + eval(args[7]), + eval(args[8]), + ) + ) + +elif cmd == "get_cluster_info": if len(args) != 1: - print('get_cluster_info requires 1 args') + print("get_cluster_info requires 1 args") sys.exit(1) - pp.pprint(client.get_cluster_info(args[0],)) + pp.pprint( + client.get_cluster_info( + args[0], + ) + ) -elif cmd == 'get_cluster_status': +elif cmd == "get_cluster_status": if len(args) != 1: - print('get_cluster_status requires 1 args') + print("get_cluster_status requires 1 args") sys.exit(1) - pp.pprint(client.get_cluster_status(args[0],)) + pp.pprint( + client.get_cluster_status( + args[0], + ) + ) -elif cmd == 'get_server': +elif cmd == "get_server": if len(args) != 1: - print('get_server requires 1 args') + print("get_server requires 1 args") sys.exit(1) - pp.pprint(client.get_server(args[0],)) + pp.pprint( + client.get_server( + args[0], + ) + ) -elif cmd == 'stop_server': +elif cmd == "stop_server": if len(args) != 1: - print('stop_server requires 1 args') + print("stop_server requires 1 args") sys.exit(1) - pp.pprint(client.stop_server(args[0],)) + pp.pprint( + client.stop_server( + args[0], + ) + ) -elif cmd == 'create_snapshot': +elif cmd == "create_snapshot": if len(args) != 5: - print('create_snapshot requires 5 args') - sys.exit(1) - pp.pprint(client.create_snapshot(args[0], args[1], args[2], eval(args[3]), args[4],)) - -elif cmd == 'get_limits': + print("create_snapshot requires 5 args") + sys.exit(1) + pp.pprint( + client.create_snapshot( + args[0], + args[1], + args[2], + eval(args[3]), + args[4], + ) + ) + +elif cmd == "get_limits": if len(args) != 0: - print('get_limits requires 0 args') + print("get_limits requires 0 args") sys.exit(1) pp.pprint(client.get_limits()) -elif cmd == 'start_cluster': +elif cmd == "start_cluster": if len(args) != 4: - print('start_cluster requires 4 args') - sys.exit(1) - pp.pprint(client.start_cluster(args[0], eval(args[1]), eval(args[2]), args[3],)) - -elif cmd == 'terminate_cluster': + print("start_cluster requires 4 args") + sys.exit(1) + pp.pprint( + client.start_cluster( + args[0], + eval(args[1]), + eval(args[2]), + args[3], + ) + ) + +elif cmd == "terminate_cluster": if len(args) != 1: - print('terminate_cluster requires 1 args') + print("terminate_cluster requires 1 args") sys.exit(1) - pp.pprint(client.terminate_cluster(args[0],)) + pp.pprint( + client.terminate_cluster( + args[0], + ) + ) -elif cmd == 'delete_image': +elif cmd == "delete_image": if len(args) != 1: - print('delete_image requires 1 args') + print("delete_image requires 1 args") sys.exit(1) - pp.pprint(client.delete_image(args[0],)) + pp.pprint( + client.delete_image( + args[0], + ) + ) -elif cmd == 'delete_volume_attachment': +elif cmd == "delete_volume_attachment": if len(args) != 2: - print('delete_volume_attachment requires 2 args') + print("delete_volume_attachment requires 2 args") sys.exit(1) - pp.pprint(client.delete_volume_attachment(args[0], args[1],)) + pp.pprint( + client.delete_volume_attachment( + args[0], + args[1], + ) + ) -elif cmd == 'delete_volume': +elif cmd == "delete_volume": if len(args) != 1: - print('delete_volume requires 1 args') + print("delete_volume requires 1 args") sys.exit(1) - pp.pprint(client.delete_volume(args[0],)) + pp.pprint( + client.delete_volume( + args[0], + ) + ) -elif cmd == 'attach_volume_to_server': +elif cmd == "attach_volume_to_server": if len(args) != 2: - print('attach_volume_to_server requires 2 args') + print("attach_volume_to_server requires 2 args") sys.exit(1) - pp.pprint(client.attach_volume_to_server(args[0], args[1],)) + pp.pprint( + client.attach_volume_to_server( + args[0], + args[1], + ) + ) -elif cmd == 'check_server_status': +elif cmd == "check_server_status": if len(args) != 1: - print('check_server_status requires 1 args') + print("check_server_status requires 1 args") sys.exit(1) - pp.pprint(client.check_server_status(args[0],)) + pp.pprint( + client.check_server_status( + args[0], + ) + ) -elif cmd == 'setUserPassword': +elif cmd == "setUserPassword": if len(args) != 2: - print('setUserPassword requires 2 args') + print("setUserPassword requires 2 args") sys.exit(1) - pp.pprint(client.setUserPassword(args[0], args[1],)) + pp.pprint( + client.setUserPassword( + args[0], + args[1], + ) + ) -elif cmd == 'resume_server': +elif cmd == "resume_server": if len(args) != 1: - print('resume_server requires 1 args') + print("resume_server requires 1 args") sys.exit(1) - pp.pprint(client.resume_server(args[0],)) + pp.pprint( + client.resume_server( + args[0], + ) + ) -elif cmd == 'create_volume': +elif cmd == "create_volume": if len(args) != 3: - print('create_volume requires 3 args') + print("create_volume requires 3 args") sys.exit(1) - pp.pprint(client.create_volume(args[0], eval(args[1]), eval(args[2]),)) + pp.pprint( + client.create_volume( + args[0], + eval(args[1]), + eval(args[2]), + ) + ) -elif cmd == 'reboot_server': +elif cmd == "reboot_server": if len(args) != 2: - print('reboot_server requires 2 args') + print("reboot_server requires 2 args") sys.exit(1) - pp.pprint(client.reboot_server(args[0], args[1],)) + pp.pprint( + client.reboot_server( + args[0], + args[1], + ) + ) else: - print('Unrecognized method %s' % cmd) + print(f"Unrecognized method {cmd}") sys.exit(1) transport.close() diff --git a/VirtualMachineService/VirtualMachineService.py b/VirtualMachineService/VirtualMachineService.py index f3faa344..4fa74bd8 100644 --- a/VirtualMachineService/VirtualMachineService.py +++ b/VirtualMachineService/VirtualMachineService.py @@ -6,21 +6,13 @@ # options string: py # -from thrift.Thrift import ( - TType, - TMessageType, - TFrozenDict, - TException, - TApplicationException, -) -from thrift.protocol.TProtocol import TProtocolException -from thrift.TRecursive import fix_spec - -import sys import logging -from ttypes import * -from thrift.Thrift import TProcessor +import sys + +from thrift.Thrift import TApplicationException, TMessageType, TProcessor, TType from thrift.transport import TTransport +from thrift.TRecursive import fix_spec +from ttypes import * all_structs = [] @@ -37,7 +29,6 @@ def check_Version(self, version): - version """ - pass def get_client_version(self): """ @@ -45,14 +36,12 @@ def get_client_version(self): Returns Version of the client """ - pass def get_gateway_ip(self): """ Gets the gateway ip. """ - pass def get_calculation_formulars(self): pass @@ -67,7 +56,6 @@ def import_keypair(self, keyname, public_key): - public_key: The public key """ - pass def get_vm_ports(self, openstack_id): """ @@ -78,7 +66,6 @@ def get_vm_ports(self, openstack_id): - openstack_id: Id of server """ - pass def get_Flavors(self): """ @@ -86,7 +73,6 @@ def get_Flavors(self): Returns: List of flavor instances. """ - pass def get_Images(self): """ @@ -94,7 +80,6 @@ def get_Images(self): Returns: List of Image instances. """ - pass def get_public_Images(self): """ @@ -102,7 +87,6 @@ def get_public_Images(self): Returns: List of public Image instances. """ - pass def get_private_Images(self): """ @@ -110,7 +94,6 @@ def get_private_Images(self): Returns: List of private Image instances. """ - pass def get_Image_with_Tag(self, openstack_id): """ @@ -121,7 +104,6 @@ def get_Image_with_Tag(self, openstack_id): - openstack_id """ - pass def get_Images_by_filter(self, filter_json): """ @@ -132,7 +114,6 @@ def get_Images_by_filter(self, filter_json): - filter_json """ - pass def get_volume(self, volume_id): """ @@ -140,7 +121,6 @@ def get_volume(self, volume_id): - volume_id """ - pass def get_volumes_by_ids(self, volume_ids): """ @@ -148,7 +128,6 @@ def get_volumes_by_ids(self, volume_ids): - volume_ids """ - pass def resize_volume(self, volume_id, size): """ @@ -157,7 +136,6 @@ def resize_volume(self, volume_id, size): - size """ - pass def delete_server(self, openstack_id): """ @@ -168,7 +146,6 @@ def delete_server(self, openstack_id): - openstack_id: Id of the server. """ - pass def add_metadata_to_server(self, servername, metadata): """ @@ -177,7 +154,6 @@ def add_metadata_to_server(self, servername, metadata): - metadata """ - pass def delete_metadata_from_server(self, servername, keys): """ @@ -186,7 +162,6 @@ def delete_metadata_from_server(self, servername, keys): - keys """ - pass def add_floating_ip_to_server(self, openstack_id, network): """ @@ -198,7 +173,6 @@ def add_floating_ip_to_server(self, openstack_id, network): - network: Network name of the network which provides the floating Ip. """ - pass def create_connection( self, username, password, auth_url, user_domain_name, project_domain_name @@ -218,7 +192,6 @@ def create_connection( - project_domain_name: Project domain name of OpenStack """ - pass def start_server_without_playbook( self, @@ -249,7 +222,6 @@ def start_server_without_playbook( - additional_keys """ - pass def bibigrid_available(self): pass @@ -261,7 +233,6 @@ def detach_ip_from_server(self, server_id, floating_ip): - floating_ip """ - pass def start_server_with_mounted_volume( self, @@ -290,7 +261,6 @@ def start_server_with_mounted_volume( - volume_ids_path_attach """ - pass def start_server( self, @@ -321,7 +291,6 @@ def start_server( - resenv """ - pass def start_server_with_custom_key( self, @@ -350,7 +319,6 @@ def start_server_with_custom_key( - volume_ids_path_attach """ - pass def exist_server(self, name): """ @@ -360,7 +328,6 @@ def exist_server(self, name): - name """ - pass def create_and_deploy_playbook( self, public_key, playbooks_information, openstack_id @@ -374,7 +341,6 @@ def create_and_deploy_playbook( - openstack_id """ - pass def get_playbook_logs(self, openstack_id): """ @@ -384,14 +350,12 @@ def get_playbook_logs(self, openstack_id): - openstack_id """ - pass def has_forc(self): """ Get boolean if client has backend url configured """ - pass def get_forc_url(self): pass @@ -407,14 +371,12 @@ def create_backend(self, elixir_id, user_key_url, template, upstream_url): - upstream_url """ - pass def get_backends(self): """ Get all backends """ - pass def get_backends_by_owner(self, elixir_id): """ @@ -424,7 +386,6 @@ def get_backends_by_owner(self, elixir_id): - elixir_id """ - pass def get_backends_by_template(self, template): """ @@ -434,7 +395,6 @@ def get_backends_by_template(self, template): - template """ - pass def get_backend_by_id(self, id): """ @@ -444,7 +404,6 @@ def get_backend_by_id(self, id): - id """ - pass def delete_backend(self, id): """ @@ -454,7 +413,6 @@ def delete_backend(self, id): - id """ - pass def add_user_to_backend(self, backend_id, owner_id, user_id): """ @@ -466,7 +424,6 @@ def add_user_to_backend(self, backend_id, owner_id, user_id): - user_id """ - pass def get_users_from_backend(self, backend_id): """ @@ -476,7 +433,6 @@ def get_users_from_backend(self, backend_id): - backend_id """ - pass def delete_user_from_backend(self, backend_id, owner_id, user_id): """ @@ -488,7 +444,6 @@ def delete_user_from_backend(self, backend_id, owner_id, user_id): - user_id """ - pass def get_templates(self): pass @@ -502,7 +457,6 @@ def get_templates_by_template(self, template_name): - template_name """ - pass def check_template(self, template_name, template_version): """ @@ -511,7 +465,6 @@ def check_template(self, template_name, template_version): - template_version """ - pass def add_udp_security_group(self, server_id): """ @@ -521,7 +474,6 @@ def add_udp_security_group(self, server_id): - server_id: OpenStack id of the server """ - pass def get_servers(self): """ @@ -529,7 +481,6 @@ def get_servers(self): Returns: List of server instances. """ - pass def get_servers_by_ids(self, server_ids): """ @@ -540,7 +491,6 @@ def get_servers_by_ids(self, server_ids): - server_ids """ - pass def check_server_task_state(self, openstack_id): """ @@ -548,7 +498,6 @@ def check_server_task_state(self, openstack_id): - openstack_id """ - pass def get_servers_by_bibigrid_id(self, bibigrid_id): """ @@ -559,7 +508,6 @@ def get_servers_by_bibigrid_id(self, bibigrid_id): - bibigrid_id """ - pass def scale_up_cluster( self, cluster_id, image, flavor, count, names, start_idx, batch_idx @@ -575,7 +523,6 @@ def scale_up_cluster( - batch_idx """ - pass def add_cluster_machine( self, @@ -602,7 +549,6 @@ def add_cluster_machine( - worker_idx """ - pass def get_cluster_info(self, cluster_id): """ @@ -610,7 +556,6 @@ def get_cluster_info(self, cluster_id): - cluster_id """ - pass def get_cluster_status(self, cluster_id): """ @@ -618,7 +563,6 @@ def get_cluster_status(self, cluster_id): - cluster_id """ - pass def get_server(self, openstack_id): """ @@ -629,7 +573,6 @@ def get_server(self, openstack_id): - openstack_id: Id of the server. """ - pass def stop_server(self, openstack_id): """ @@ -640,7 +583,6 @@ def stop_server(self, openstack_id): - openstack_id: Id of the server. """ - pass def create_snapshot(self, openstack_id, name, elixir_id, base_tags, description): """ @@ -656,7 +598,6 @@ def create_snapshot(self, openstack_id, name, elixir_id, base_tags, description) - description: Description of the new snapshot """ - pass def get_limits(self): """ @@ -666,7 +607,6 @@ def get_limits(self): 'totalInstancesUsed': totalInstancesUsed} """ - pass def start_cluster(self, public_key, master_instance, worker_instance, user): """ @@ -677,7 +617,6 @@ def start_cluster(self, public_key, master_instance, worker_instance, user): - user """ - pass def terminate_cluster(self, cluster_id): """ @@ -685,7 +624,6 @@ def terminate_cluster(self, cluster_id): - cluster_id """ - pass def delete_image(self, image_id): """ @@ -696,7 +634,6 @@ def delete_image(self, image_id): - image_id: Id of image """ - pass def delete_volume_attachment(self, volume_id, server_id): """ @@ -708,7 +645,6 @@ def delete_volume_attachment(self, volume_id, server_id): - server_id: Id of the server where the volume is attached """ - pass def delete_volume(self, volume_id): """ @@ -719,7 +655,6 @@ def delete_volume(self, volume_id): - volume_id """ - pass def attach_volume_to_server(self, openstack_id, volume_id): """ @@ -731,7 +666,6 @@ def attach_volume_to_server(self, openstack_id, volume_id): - volume_id: Id of volume """ - pass def check_server_status(self, openstack_id): """ @@ -742,7 +676,6 @@ def check_server_status(self, openstack_id): - openstack_id: Id of the server """ - pass def setUserPassword(self, user, password): """ @@ -754,7 +687,6 @@ def setUserPassword(self, user, password): - password: New password """ - pass def resume_server(self, openstack_id): """ @@ -765,7 +697,6 @@ def resume_server(self, openstack_id): - openstack_id: Id of the server """ - pass def create_volume(self, volume_name, volume_storage, metadata): """ @@ -778,7 +709,6 @@ def create_volume(self, volume_name, volume_storage, metadata): - metadata: Metadata for the new volume """ - pass def reboot_server(self, server_id, reboot_type): """ @@ -790,7 +720,6 @@ def reboot_server(self, server_id, reboot_type): - reboot_type: HARD or SOFT """ - pass class Client(Iface): @@ -3890,7 +3819,7 @@ def process(self, iprot, oprot): iprot.skip(TType.STRUCT) iprot.readMessageEnd() x = TApplicationException( - TApplicationException.UNKNOWN_METHOD, "Unknown function %s" % (name) + TApplicationException.UNKNOWN_METHOD, f"Unknown function {name}" ) oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) x.write(oprot) @@ -5929,8 +5858,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6006,8 +5935,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6061,8 +5990,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6137,8 +6066,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6192,8 +6121,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6282,8 +6211,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6337,8 +6266,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6427,8 +6356,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6531,8 +6460,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6623,8 +6552,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6707,8 +6636,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6806,8 +6735,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6861,8 +6790,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6938,8 +6867,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -6993,8 +6922,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7070,8 +6999,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7125,8 +7054,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7202,8 +7131,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7257,8 +7186,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7334,8 +7263,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7418,8 +7347,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7496,8 +7425,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7594,8 +7523,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7680,8 +7609,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7764,8 +7693,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7842,8 +7771,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -7932,8 +7861,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8018,8 +7947,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8114,8 +8043,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8198,8 +8127,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8282,8 +8211,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8383,8 +8312,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8515,8 +8444,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8633,8 +8562,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8750,8 +8679,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8860,8 +8789,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -8971,8 +8900,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -9087,8 +9016,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -9268,8 +9197,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -9386,8 +9315,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -9735,8 +9664,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -9988,8 +9917,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -10092,8 +10021,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -10160,8 +10089,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -10264,8 +10193,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -10348,8 +10277,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -10664,8 +10593,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -10910,8 +10839,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -11223,8 +11152,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -11469,8 +11398,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -11814,8 +11743,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12054,8 +11983,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12185,8 +12114,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12262,8 +12191,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12422,8 +12351,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12519,8 +12448,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12603,8 +12532,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12681,8 +12610,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12736,8 +12665,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12804,8 +12733,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12859,8 +12788,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -12935,8 +12864,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13079,8 +13008,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13178,8 +13107,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13233,8 +13162,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13310,8 +13239,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13394,8 +13323,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13480,8 +13409,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13564,8 +13493,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13650,8 +13579,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13726,8 +13655,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13804,8 +13733,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13880,8 +13809,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -13965,8 +13894,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14081,8 +14010,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14194,8 +14123,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14270,8 +14199,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14361,8 +14290,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14477,8 +14406,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14590,8 +14519,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14645,8 +14574,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14747,8 +14676,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14802,8 +14731,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14884,8 +14813,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -14968,8 +14897,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15079,8 +15008,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15183,8 +15112,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15289,8 +15218,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15373,8 +15302,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15474,8 +15403,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15543,8 +15472,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15620,8 +15549,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15710,8 +15639,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15796,8 +15725,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15880,8 +15809,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -15965,8 +15894,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -16049,8 +15978,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -16135,8 +16064,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -16317,8 +16246,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -16466,8 +16395,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -16688,8 +16617,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -16829,8 +16758,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -16913,8 +16842,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -16991,8 +16920,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -17075,8 +17004,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -17174,8 +17103,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -17258,8 +17187,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -17348,8 +17277,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -17439,8 +17368,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -17540,8 +17469,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -17722,8 +17651,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -17859,8 +17788,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -17928,8 +17857,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18018,8 +17947,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18154,8 +18083,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18274,8 +18203,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18358,8 +18287,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18457,8 +18386,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18541,8 +18470,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18630,8 +18559,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18741,8 +18670,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18849,8 +18778,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -18947,8 +18876,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -19036,8 +18965,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -19147,8 +19076,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -19277,8 +19206,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -19375,8 +19304,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -19477,8 +19406,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -19593,8 +19522,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -19697,8 +19626,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -19788,8 +19717,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -19889,8 +19818,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -20033,8 +19962,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -20158,8 +20087,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -20269,8 +20198,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -20377,8 +20306,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ diff --git a/VirtualMachineService/ancon/Playbook.py b/VirtualMachineService/ancon/Playbook.py index 6bab855f..8cbbee33 100644 --- a/VirtualMachineService/ancon/Playbook.py +++ b/VirtualMachineService/ancon/Playbook.py @@ -1,9 +1,9 @@ import logging +import os import shlex import shutil import subprocess from tempfile import NamedTemporaryFile, TemporaryDirectory -import os import redis import ruamel.yaml @@ -154,12 +154,12 @@ def load_vars(): if k == MOSH: data[playbook_name + "_defined"][k] = v - site_specific_yml = "/{0}{1}.yml".format(playbook_name, "-" + self.cloud_site) + site_specific_yml = f"/{playbook_name}{'-' + self.cloud_site}.yml" playbook_name_local = playbook_name if os.path.isfile(self.playbooks_dir + site_specific_yml): playbook_name_local = playbook_name + "-" + self.cloud_site - playbook_yml = "/{0}.yml".format(playbook_name_local) - playbook_var_yml = "/{0}_vars_file.yml".format(playbook_name) + playbook_yml = f"/{playbook_name_local}.yml" + playbook_var_yml = f"/{playbook_name}_vars_file.yml" try: shutil.copy(self.playbooks_dir + playbook_yml, self.directory.name) try: @@ -189,7 +189,7 @@ def add_to_playbook_lists(self, playbook_name_local, playbook_name): self.vars_files.append(playbook_name + "_vars_file.yml") self.tasks.append( dict( - name="Running {0} tasks".format(playbook_name_local), + name=f"Running {playbook_name_local} tasks", import_tasks=playbook_name_local + ".yml", ) ) @@ -205,7 +205,7 @@ def add_to_playbook_lists(self, playbook_name_local, playbook_name): def add_tasks_only(self, playbook_name): self.tasks.append( dict( - name="Running {0} tasks".format(playbook_name), + name=f"Running {playbook_name} tasks", import_tasks=playbook_name + ".yml", ) ) @@ -214,7 +214,7 @@ def add_to_playbook_always_lists(self, playbook_name): self.vars_files.append(playbook_name + "_vars_file.yml") self.always_tasks.append( dict( - name="Running {0} tasks".format(playbook_name), + name=f"Running {playbook_name} tasks", import_tasks=playbook_name + ".yml", ) ) @@ -222,7 +222,7 @@ def add_to_playbook_always_lists(self, playbook_name): def add_always_tasks_only(self, playbook_name): self.always_tasks.append( dict( - name="Running {0} tasks".format(playbook_name), + name=f"Running {playbook_name} tasks", import_tasks=playbook_name + ".yml", ) ) @@ -243,20 +243,14 @@ def run_it(self): def check_status(self, openstack_id): done = self.process.poll() if done is None: - LOG.info( - "Playbook for (openstack_id) {0} still in progress.".format( - openstack_id - ) - ) + LOG.info(f"Playbook for (openstack_id) {openstack_id} still in progress.") elif done != 0: - LOG.info("Playbook for (openstack_id) {0} has failed.".format(openstack_id)) + LOG.info(f"Playbook for (openstack_id) {openstack_id} has failed.") self.redis.hset(openstack_id, "status", self.PLAYBOOK_FAILED) self.returncode = self.process.returncode self.process.wait() else: - LOG.info( - "Playbook for (openstack_id) {0} is successful.".format(openstack_id) - ) + LOG.info(f"Playbook for (openstack_id) {openstack_id} is successful.") self.redis.hset(openstack_id, "status", self.ACTIVE) self.returncode = self.process.returncode self.process.wait() @@ -281,5 +275,5 @@ def stop(self, openstack_id): self.process.terminate() rc, stdout, stderr = self.get_logs() logs_to_save = {"returncode": rc, "stdout": stdout, "stderr": stderr} - self.redis.hmset("pb_logs_{0}".format(openstack_id), logs_to_save) + self.redis.hmset(f"pb_logs_{openstack_id}", logs_to_save) self.cleanup(openstack_id) diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/defaults/main.yml b/VirtualMachineService/ancon/playbooks/roles/guacamole/defaults/main.yml index 9f6e697f..d531a940 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/defaults/main.yml +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/defaults/main.yml @@ -1,2 +1,2 @@ --- -# defaults file for guacamolerdp-ansible \ No newline at end of file +# defaults file for guacamolerdp-ansible diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/files/guacamole.properties b/VirtualMachineService/ancon/playbooks/roles/guacamole/files/guacamole.properties index 26c90e3e..c14fbfa1 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/files/guacamole.properties +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/files/guacamole.properties @@ -1 +1 @@ -basic-user-mapping: /etc/guacamole/user-mapping.xml \ No newline at end of file +basic-user-mapping: /etc/guacamole/user-mapping.xml diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/handlers/main.yml b/VirtualMachineService/ancon/playbooks/roles/guacamole/handlers/main.yml index fcf6cc5f..7a0129eb 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/handlers/main.yml +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/handlers/main.yml @@ -18,4 +18,4 @@ - name: Reload systemd systemd: - daemon_reload: yes \ No newline at end of file + daemon_reload: yes diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/meta/main.yml b/VirtualMachineService/ancon/playbooks/roles/guacamole/meta/main.yml index d315703a..9d275b84 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/meta/main.yml +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/meta/main.yml @@ -15,4 +15,4 @@ galaxy_info: - xrdp - guacamole -dependencies: [] \ No newline at end of file +dependencies: [] diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/tasks/005-desktop.yml b/VirtualMachineService/ancon/playbooks/roles/guacamole/tasks/005-desktop.yml index b0057e97..81fe3212 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/tasks/005-desktop.yml +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/tasks/005-desktop.yml @@ -32,4 +32,4 @@ - name: Setup password for default user user: name: "{{ DEFAULT_USER }}" - password: "{{ DEFAULT_PASSWORD_HASHED }}" \ No newline at end of file + password: "{{ DEFAULT_PASSWORD_HASHED }}" diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/tasks/main.yml b/VirtualMachineService/ancon/playbooks/roles/guacamole/tasks/main.yml index 57f350a5..a234de77 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/tasks/main.yml +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/tasks/main.yml @@ -5,4 +5,4 @@ tags: ['guacamole_desktop'] - include: 010-guacamole.yml - tags: ['guacamole_guacamole'] \ No newline at end of file + tags: ['guacamole_guacamole'] diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/templates/user-mapping.xml.j2 b/VirtualMachineService/ancon/playbooks/roles/guacamole/templates/user-mapping.xml.j2 index 053864cd..db819dde 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/templates/user-mapping.xml.j2 +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/templates/user-mapping.xml.j2 @@ -15,4 +15,4 @@ - \ No newline at end of file + diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/tests/inventory b/VirtualMachineService/ancon/playbooks/roles/guacamole/tests/inventory index 878877b0..2fbb50c4 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/tests/inventory +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/tests/inventory @@ -1,2 +1 @@ localhost - diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/tests/test.yml b/VirtualMachineService/ancon/playbooks/roles/guacamole/tests/test.yml index 367e6e0f..f08718ea 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/tests/test.yml +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/tests/test.yml @@ -2,4 +2,4 @@ - hosts: localhost remote_user: root roles: - - guacamolerdp-ansible \ No newline at end of file + - guacamolerdp-ansible diff --git a/VirtualMachineService/ancon/playbooks/roles/guacamole/vars/main.yml b/VirtualMachineService/ancon/playbooks/roles/guacamole/vars/main.yml index 84d1168f..d8ce58e5 100644 --- a/VirtualMachineService/ancon/playbooks/roles/guacamole/vars/main.yml +++ b/VirtualMachineService/ancon/playbooks/roles/guacamole/vars/main.yml @@ -6,4 +6,4 @@ DEFAULT_PASSWORD: ogvkyf # you can create password hashes like here https://stackoverflow.com/questions/19292899/creating-a-new-user-and-password-with-ansible DEFAULT_PASSWORD_HASHED: $6$iRrIJogrR0N2ZVdb$oL5XzFqcTC.O3g4DS945a5K7nRvO0LqY.ugyjDINUA347qRYXe1YXag8cRlLf9PVwmNrRYU3LTNGyCIPbFvz4/ GUAC_USER: denbi -GUAC_PASSWORD: denbi \ No newline at end of file +GUAC_PASSWORD: denbi diff --git a/VirtualMachineService/ancon/playbooks/roles/theia/templates/theia-ide.service.j2 b/VirtualMachineService/ancon/playbooks/roles/theia/templates/theia-ide.service.j2 index 2381198b..6e2aba99 100644 --- a/VirtualMachineService/ancon/playbooks/roles/theia/templates/theia-ide.service.j2 +++ b/VirtualMachineService/ancon/playbooks/roles/theia/templates/theia-ide.service.j2 @@ -11,4 +11,4 @@ User={{ theia_ide_user }} ExecStart={{ theia_ide_install_dir }}/theia-ide.sh {{ theia_ide_workspace }} {{ theia_ide_bind_address }} {{ theia_ide_bind_port }} [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/VirtualMachineService/ancon/playbooks/roles/theia/templates/theia-ide.sh.j2 b/VirtualMachineService/ancon/playbooks/roles/theia/templates/theia-ide.sh.j2 index ac74caaa..b67fdec1 100644 --- a/VirtualMachineService/ancon/playbooks/roles/theia/templates/theia-ide.sh.j2 +++ b/VirtualMachineService/ancon/playbooks/roles/theia/templates/theia-ide.sh.j2 @@ -2,4 +2,4 @@ source {{ nvm_install_dir }}/nvm.sh cd $(dirname ${0}) -yarn theia start ${1} --hostname ${2} --port ${3} \ No newline at end of file +yarn theia start ${1} --hostname ${2} --port ${3} diff --git a/VirtualMachineService/constants.py b/VirtualMachineService/constants.py index 55b1d3fd..3d3d3603 100644 --- a/VirtualMachineService/constants.py +++ b/VirtualMachineService/constants.py @@ -6,17 +6,5 @@ # options string: py # -from thrift.Thrift import ( - TType, - TMessageType, - TFrozenDict, - TException, - TApplicationException, -) -from thrift.protocol.TProtocol import TProtocolException -from thrift.TRecursive import fix_spec - -import sys -from ttypes import * VERSION = "1.0.0" diff --git a/VirtualMachineService/log/.gitignore b/VirtualMachineService/log/.gitignore index 86d0cb27..5e7d2734 100644 --- a/VirtualMachineService/log/.gitignore +++ b/VirtualMachineService/log/.gitignore @@ -1,4 +1,4 @@ # Ignore everything in this directory * # Except this file -!.gitignore \ No newline at end of file +!.gitignore diff --git a/VirtualMachineService/ttypes.py b/VirtualMachineService/ttypes.py index c52cc383..d596a9d4 100644 --- a/VirtualMachineService/ttypes.py +++ b/VirtualMachineService/ttypes.py @@ -6,19 +6,12 @@ # options string: py # -from thrift.Thrift import ( - TType, - TMessageType, - TFrozenDict, - TException, - TApplicationException, -) -from thrift.protocol.TProtocol import TProtocolException -from thrift.TRecursive import fix_spec - import sys +from thrift.protocol.TProtocol import TProtocolException +from thrift.Thrift import TException, TType from thrift.transport import TTransport +from thrift.TRecursive import fix_spec all_structs = [] @@ -155,8 +148,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -377,8 +370,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -553,8 +546,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -751,8 +744,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -995,8 +988,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -1313,8 +1306,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -1417,8 +1410,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -1525,8 +1518,8 @@ def validate(self): return def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -1611,8 +1604,8 @@ def __str__(self): return repr(self) def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -1697,8 +1690,8 @@ def __str__(self): return repr(self) def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -1783,8 +1776,8 @@ def __str__(self): return repr(self) def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -1869,8 +1862,8 @@ def __str__(self): return repr(self) def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -1955,8 +1948,8 @@ def __str__(self): return repr(self) def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -2041,8 +2034,8 @@ def __str__(self): return repr(self) def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -2127,8 +2120,8 @@ def __str__(self): return repr(self) def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -2215,8 +2208,8 @@ def __str__(self): return repr(self) def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ @@ -2303,8 +2296,8 @@ def __str__(self): return repr(self) def __repr__(self): - L = ["%s=%r" % (key, value) for key, value in self.__dict__.items()] - return "%s(%s)" % (self.__class__.__name__, ", ".join(L)) + L = [f"{key}={value!r}" for key, value in self.__dict__.items()] + return f"{self.__class__.__name__}({', '.join(L)})" def __eq__(self, other): return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ diff --git a/docker-compose.bibigrid.yml b/docker-compose.bibigrid.yml index 7e89111d..90c7887e 100644 --- a/docker-compose.bibigrid.yml +++ b/docker-compose.bibigrid.yml @@ -54,10 +54,10 @@ services: networks: portal: name: portal_default - driver: bridge - driver_opts: + driver: bridge + driver_opts: com.docker.network.driver.mtu: 1440 - default: - driver: bridge - driver_opts: + default: + driver: bridge + driver_opts: com.docker.network.driver.mtu: 1440 diff --git a/docker-compose.yml b/docker-compose.yml index 450bb3a6..3e5a2f6f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,10 +40,10 @@ services: networks: portal: name: portal_default - driver: bridge - driver_opts: + driver: bridge + driver_opts: com.docker.network.driver.mtu: 1440 - default: - driver: bridge - driver_opts: + default: + driver: bridge + driver_opts: com.docker.network.driver.mtu: 1440 diff --git a/plays/setup_basics.yml b/plays/setup_basics.yml index 7ceb770f..a33436b0 100644 --- a/plays/setup_basics.yml +++ b/plays/setup_basics.yml @@ -4,7 +4,7 @@ vars_files: - general_variables.yml - + roles: - role: geerlingguy.docker tags: always diff --git a/plays/setup_client.yml b/plays/setup_client.yml index 559ade46..a306c8b8 100644 --- a/plays/setup_client.yml +++ b/plays/setup_client.yml @@ -15,7 +15,7 @@ stat: path: "{{ client.PERSISTENT_PATH }}/config.yml" register: stat_client_config - + - name: Check if server pem file exists already stat: path: "{{ client.PERSISTENT_PATH }}/server.pem" @@ -33,14 +33,14 @@ # Copy configs - name: Copy client config file from config folder - copy: - remote_src: True - src: "{{ client.CONFIG_DIR_PATH }}/config.yml" - dest: "{{ client.PERSISTENT_PATH }}/config.yml" + copy: + remote_src: True + src: "{{ client.CONFIG_DIR_PATH }}/config.yml" + dest: "{{ client.PERSISTENT_PATH }}/config.yml" when: client_config is not defined and stat_client_config.stat.exists == False tags: always - - name: Copy specified client config file to remote machine + - name: Copy specified client config file to remote machine copy: src={{ item.src }} dest={{ item.dest }} with_items: - { src: "{{client_config}}", dest: "{{ client.PERSISTENT_PATH }}/config.yml" } @@ -79,7 +79,7 @@ tags: always - name: Create variable files - copy: + copy: content: "{{ item.content | dict2items | map('to_json') | map('regex_replace', '\"key\":\\s\"(.*)\"', lookup('vars', 'regex_env')) | map('from_json') | list}}" dest: "{{ client.REPO_PATH }}/.ansible_environment_{{ item.name }}.json" backup: yes diff --git a/scripts/bibigrid/clear_keys_cron b/scripts/bibigrid/clear_keys_cron index 8ca2086b..4fc894fa 100644 --- a/scripts/bibigrid/clear_keys_cron +++ b/scripts/bibigrid/clear_keys_cron @@ -3,4 +3,4 @@ 0 * * * * run-parts /etc/periodic/hourly 0 2 * * * run-parts /etc/periodic/daily 0 3 * * 6 run-parts /etc/periodic/weekly -0 5 1 * * run-parts /etc/periodic/monthly \ No newline at end of file +0 5 1 * * run-parts /etc/periodic/monthly diff --git a/scripts/gateway/gateway-setup-variables.yml b/scripts/gateway/gateway-setup-variables.yml index ae4c779e..9900c0f1 100644 --- a/scripts/gateway/gateway-setup-variables.yml +++ b/scripts/gateway/gateway-setup-variables.yml @@ -2,4 +2,4 @@ general: REPO_PATH: /home/ubuntu/cloud-portal-client SCRIPT_PERSISTENT_PATH: /home/ubuntu/gateway_persistent TCP_SCRIPT_PERSISTENT_NAME: gateway_TCP.sh - UDP_SCRIPT_PERSISTENT_NAME: gateway_UDP.sh \ No newline at end of file + UDP_SCRIPT_PERSISTENT_NAME: gateway_UDP.sh diff --git a/scripts/gateway/gateway-setup.yml b/scripts/gateway/gateway-setup.yml index 9cea5c0a..45827cc2 100644 --- a/scripts/gateway/gateway-setup.yml +++ b/scripts/gateway/gateway-setup.yml @@ -56,7 +56,7 @@ - name: Run UDP script become: yes command: "{{ general.SCRIPT_PERSISTENT_PATH }}/{{ general.UDP_SCRIPT_PERSISTENT_NAME }}" - + - name: Install IPtables-persistent apt: name: diff --git a/scripts/gateway/gateway_TCP.sh b/scripts/gateway/gateway_TCP.sh index f1d62d64..d2b2010a 100644 --- a/scripts/gateway/gateway_TCP.sh +++ b/scripts/gateway/gateway_TCP.sh @@ -32,7 +32,7 @@ function check_service { for ((n=1; n <=254; n++)) { SSH_PORT=$((30000+$n)) - + echo $n iptables -t nat -A PREROUTING -i ens3 -p tcp -m tcp --dport ${SSH_PORT} -j DNAT --to-destination ${LOCALNET}.${n}:22 diff --git a/scripts/gateway/gateway_UDP.sh b/scripts/gateway/gateway_UDP.sh index cf8d7562..0a42ebc5 100644 --- a/scripts/gateway/gateway_UDP.sh +++ b/scripts/gateway/gateway_UDP.sh @@ -18,4 +18,3 @@ for ((n=1; n <=254; n++)) } } - diff --git a/scripts/generate_new_test_pems.sh b/scripts/generate_new_test_pems.sh index b5fe10a8..8a1140ff 100644 --- a/scripts/generate_new_test_pems.sh +++ b/scripts/generate_new_test_pems.sh @@ -2,12 +2,12 @@ echo Creating new dir "new_pem" mkdir $1 cd $1 -openssl req -new -x509 -nodes -days 3000 -out server.crt -keyout server.key -subj "/C=DE/ST=./L=./O=./CN=$1" +openssl req -new -x509 -nodes -days 3000 -out server.crt -keyout server.key -subj "/C=DE/ST=./L=./O=./CN=$1" openssl x509 -in server.crt -text > CA.pem cat server.crt server.key > server.pem openssl pkcs12 -export -clcerts -in server.crt -inkey server.key -out server.p12 -passout pass:thrift -openssl genrsa -out client.key +openssl genrsa -out client.key openssl req -new -nodes -key client.key -out client.csr -subj "/C=DE/ST=./L=./O=./CN=$1" -passin pass:thrift openssl x509 -req -days 3000 -in client.csr -CA CA.pem -CAkey server.key -set_serial 01 -out client.crt openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12 -passout pass:thrift diff --git a/setup.cfg b/setup.cfg index e634b145..ef1ca962 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,10 +1,10 @@ [flake8] max-line-length = 140 -exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,app/connector/VirtualMachineService.py +exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,VirtualMachineService/VirtualMachineService.py,VirtualMachineService/VirtualMachineService-remote [pycodestyle] max-line-length = 140 -exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv +exclude = .tox,.git,*/migrations/*,*/static/CACHE/*,docs,node_modules,venv,VirtualMachineService/VirtualMachineService.py,VirtualMachineService/VirtualMachineService-remote [isort] line_length = 88 diff --git a/setup.py b/setup.py index d5783bb7..8f5044ba 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # encoding: utf-8 import os + from setuptools import find_packages, setup with open(os.path.join(os.path.dirname(__file__), "README.md")) as readme: @@ -18,7 +19,8 @@ packages=find_packages(), include_package_data=True, license="Apache License 2.0", - description="The Cloud Portal Client is a client written in Python which provides functions to create virtual machines in an OpenStack project..", + description="The Cloud Portal Client is a client written in Python " + "which provides functions to create virtual machines in an OpenStack project..", long_description=README, author="Sören Giller, David Weinholz", install_requires=requirements, diff --git a/troubleshooting/README.md b/troubleshooting/README.md index 43892689..6d3c206a 100644 --- a/troubleshooting/README.md +++ b/troubleshooting/README.md @@ -2,15 +2,15 @@ Here we list errors, problems, troubles and their (possible) solutions. ##### Common solutions to some problems -- Ran `make thrift_py` after making changes to portal_client.thrift? +- Ran `make thrift_py` after making changes to portal_client.thrift? - Ran `make dev` or `docker-compose up -f docker-compose.dev.yml up --build` after making changes to the py files? The docker container needs to be build anew when making changes to the .py files. - Ran `docker-compose up -f docker-compose.dev.yml up` in local dev environment instead of `docker-compose up`? `docker-compose up` uses the docker-compose.yml for production environment. ##### Ran make thrift_py, now the client does not start anymore because of `ImportError: attempted relative import with no known parent package`? -In VirtualMachineService.py change `.ttypes import *` to `from ttypes import *`. +In VirtualMachineService.py change `.ttypes import *` to `from ttypes import *`. In constants.py change `from .ttypes import *` to `from ttypes import *`. -##### FORC does not load at startup? +##### FORC does not load at startup? Look at the startup messages in your terminal, FORC might be missing some configuration. Do you have: - The FORC URL set in config/config.yml? Like: ``` From 25204330bb7bf084cd832acf2fba7a39287c337c Mon Sep 17 00:00:00 2001 From: Jeenyus Date: Thu, 17 Feb 2022 17:22:47 +0100 Subject: [PATCH 3/5] fix(pre-commit): remove unused-variable arg, add unused variable x for port eval --- .pre-commit-config.yaml | 1 - VirtualMachineService/VirtualMachineHandler.py | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4a250670..914206bd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,6 @@ repos: - id: autoflake args: - --in-place - - --remove-unused-variables - --remove-all-unused-imports - repo: https://github.com/PyCQA/flake8 diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index 15e58c9c..6bff1ec2 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -1789,7 +1789,7 @@ def check_server_status(self, openstack_id): if self.USE_GATEWAY: serv_cop = self.get_server(openstack_id) server_base = serv_cop.fixed_ip.split(".")[-1] - int(server_base) + x = int(server_base) # noqa F841 host = str(self.GATEWAY_IP) port = eval(self.SSH_FORMULAR) elif self.get_server(openstack_id).floating_ip is None: @@ -1943,7 +1943,7 @@ def add_udp_security_group(self, server_id): .to_dict()["address"] .split(".")[-1] ) - int(ip_base) + x = int(ip_base) # noqa F841 udp_port_start = eval(self.UDP_FORMULAR) security_group = self.create_security_group( @@ -1994,7 +1994,7 @@ def get_vm_ports(self, openstack_id): LOG.info(f"Get IP and PORT for server {openstack_id}") server = self.get_server(openstack_id) server_base = server.fixed_ip.split(".")[-1] - int(server_base) + x = int(server_base) # noqa F841 port = eval(self.SSH_FORMULAR) udp_port_start = eval(self.UDP_FORMULAR) return {"port": str(port), "udp": str(udp_port_start)} From e2c818a76a352261408585f73214783ae5ee41df Mon Sep 17 00:00:00 2001 From: dweinholz Date: Wed, 9 Mar 2022 16:53:00 +0100 Subject: [PATCH 4/5] fix(VM):changed launched at to created at --- .../VirtualMachineHandler.py | 106 ++++-------------- 1 file changed, 20 insertions(+), 86 deletions(-) diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index 6bff1ec2..32367015 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -66,6 +66,7 @@ from keystoneclient.v3 import client from openstack import connection from openstack.exceptions import ConflictException +from openstack.compute.v2.server import Server from oslo_utils import encodeutils from requests.exceptions import Timeout @@ -645,7 +646,7 @@ def openstack_flav_to_thrift_flav(self, flavor): ) return flav - def get_server(self, openstack_id): + def get_server(self, openstack_id:str) -> VM: """ Get a server. @@ -656,79 +657,12 @@ def get_server(self, openstack_id): fixed_ip = None LOG.info(f"Get Server {openstack_id}") try: - server = self.conn.compute.get_server(openstack_id) + server:Server = self.conn.get_server_by_id(openstack_id) + return self.openstack_server_to_thrift_server(server=server) except Exception as e: LOG.exception(f"No Server found {openstack_id} | Error {e}") return VM(status=self.NOT_FOUND) - serv = server.to_dict() - - if serv["attached_volumes"]: - volume_id = serv["attached_volumes"][0]["id"] - diskspace = self.conn.block_storage.get_volume(volume_id).to_dict()["size"] - else: - - diskspace = 0 - if serv["launched_at"]: - dt = datetime.datetime.strptime( - serv["launched_at"][:-7], "%Y-%m-%dT%H:%M:%S" - ) - timestamp = time.mktime(dt.timetuple()) - else: - timestamp = None - - flav = self.openstack_flav_to_thrift_flav(serv["flavor"]) - - try: - img = self.get_Image_with_Tag(serv["image"]["id"]) - except Exception as e: - LOG.exception(e) - img = None - for values in server.addresses.values(): - for address in values: - - if address["OS-EXT-IPS:type"] == "floating": - floating_ip = address["addr"] - elif address["OS-EXT-IPS:type"] == "fixed": - fixed_ip = address["addr"] - task = serv["task_state"] - if task: - status = task.upper().replace("-", "_") - LOG.info(f"{openstack_id} Task: {task}") - - else: - status = serv["status"] - - if floating_ip: - server = VM( - flav=flav, - img=img, - status=status, - metadata=serv["metadata"], - project_id=serv["project_id"], - keyname=serv["key_name"], - openstack_id=serv["id"], - name=serv["name"], - created_at=str(timestamp), - floating_ip=floating_ip, - fixed_ip=fixed_ip, - diskspace=diskspace, - ) - else: - server = VM( - flav=flav, - img=img, - status=status, - metadata=serv["metadata"], - project_id=serv["project_id"], - keyname=serv["key_name"], - openstack_id=serv["id"], - name=serv["name"], - created_at=str(timestamp), - fixed_ip=fixed_ip, - diskspace=diskspace, - ) - return server def get_servers_by_ids(self, ids): servers = [] @@ -1756,7 +1690,7 @@ def attach_volume_to_server(self, openstack_id, volume_id): ) return {"error": e} - def check_server_status(self, openstack_id): + def check_server_status(self, openstack_id:str) ->VM: """ Check status of server. @@ -1833,7 +1767,7 @@ def check_server_status(self, openstack_id): LOG.exception(f"Check Status VM {openstack_id} error: {e}") return VM(status=self.ERROR) - def openstack_server_to_thrift_server(self, server): + def openstack_server_to_thrift_server(self, server:Server ) -> VM: LOG.info(f"Convert server {server} to thrift server") fixed_ip = None floating_ip = None @@ -1848,13 +1782,7 @@ def openstack_server_to_thrift_server(self, server): except Exception as e: LOG.exception(f"Could not found volume {volume_id}: {e}") - if server["OS-SRV-USG:launched_at"]: - dt = datetime.datetime.strptime( - server["OS-SRV-USG:launched_at"][:-7], "%Y-%m-%dT%H:%M:%S" - ) - timestamp = time.mktime(dt.timetuple()) - else: - timestamp = None + flav = self.openstack_flav_to_thrift_flav(server["flavor"]) try: @@ -1869,17 +1797,23 @@ def openstack_server_to_thrift_server(self, server): floating_ip = address["addr"] elif address["OS-EXT-IPS:type"] == "fixed": fixed_ip = address["addr"] + task = server.task_state + if task: + status = task.upper().replace("-", "_") + LOG.info(f"{server.id} Task: {task}") + else: + status = server.status server = VM( flav=flav, img=img, - status=server["status"], - metadata=server["metadata"], - project_id=server["project_id"], - keyname=server["key_name"], - openstack_id=server["id"], - name=server["name"], - created_at=str(timestamp), + status=status, + metadata=server.metadata, + project_id=server.project_id, + keyname=server.key_name, + openstack_id=server.id, + name=server.name, + created_at=server.created_at, fixed_ip=fixed_ip, floating_ip=floating_ip, diskspace=diskspace, From ac950a5601d303283470249d28839be6f7a815b3 Mon Sep 17 00:00:00 2001 From: dweinholz Date: Wed, 9 Mar 2022 15:54:09 +0000 Subject: [PATCH 5/5] fix(Linting):blacked code --- VirtualMachineService/VirtualMachineHandler.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/VirtualMachineService/VirtualMachineHandler.py b/VirtualMachineService/VirtualMachineHandler.py index 32367015..5783035e 100644 --- a/VirtualMachineService/VirtualMachineHandler.py +++ b/VirtualMachineService/VirtualMachineHandler.py @@ -646,7 +646,7 @@ def openstack_flav_to_thrift_flav(self, flavor): ) return flav - def get_server(self, openstack_id:str) -> VM: + def get_server(self, openstack_id: str) -> VM: """ Get a server. @@ -657,13 +657,12 @@ def get_server(self, openstack_id:str) -> VM: fixed_ip = None LOG.info(f"Get Server {openstack_id}") try: - server:Server = self.conn.get_server_by_id(openstack_id) + server: Server = self.conn.get_server_by_id(openstack_id) return self.openstack_server_to_thrift_server(server=server) except Exception as e: LOG.exception(f"No Server found {openstack_id} | Error {e}") return VM(status=self.NOT_FOUND) - def get_servers_by_ids(self, ids): servers = [] for id in ids: @@ -1690,7 +1689,7 @@ def attach_volume_to_server(self, openstack_id, volume_id): ) return {"error": e} - def check_server_status(self, openstack_id:str) ->VM: + def check_server_status(self, openstack_id: str) -> VM: """ Check status of server. @@ -1767,7 +1766,7 @@ def check_server_status(self, openstack_id:str) ->VM: LOG.exception(f"Check Status VM {openstack_id} error: {e}") return VM(status=self.ERROR) - def openstack_server_to_thrift_server(self, server:Server ) -> VM: + def openstack_server_to_thrift_server(self, server: Server) -> VM: LOG.info(f"Convert server {server} to thrift server") fixed_ip = None floating_ip = None @@ -1782,7 +1781,6 @@ def openstack_server_to_thrift_server(self, server:Server ) -> VM: except Exception as e: LOG.exception(f"Could not found volume {volume_id}: {e}") - flav = self.openstack_flav_to_thrift_flav(server["flavor"]) try: