From 75327536d8bffc802a72ccd748df3a871f241d89 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:33:00 +0000 Subject: [PATCH 1/5] feat(Dependencies): Update actions/setup-python action to v5 | datasource | package | from | to | | ----------- | -------------------- | ---- | -- | | github-tags | actions/setup-python | v2 | v5 | --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 949ab55..bb288ea 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python 3.11 - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: 3.11 From ac0df80c9c9788d7135e0af122e9c6f8e57cf210 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 12 Jan 2024 19:02:19 +0000 Subject: [PATCH 2/5] feat(Dependencies): Update dependency python-keystoneclient to v5.3.0 | datasource | package | from | to | | ---------- | --------------------- | ----- | ----- | | pypi | python-keystoneclient | 5.2.0 | 5.3.0 | --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 3d9116e..524be81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ setuptools==69.0.3 thrift==0.16.0 -python-keystoneclient==5.2.0 +python-keystoneclient==5.3.0 openstacksdk==2.0.0 deprecated==1.2.14 Click==8.1.7 From 47c779a1c67894b40fc2d1deeb10f17d6b89443b Mon Sep 17 00:00:00 2001 From: dweinholz Date: Mon, 15 Jan 2024 15:29:23 +0100 Subject: [PATCH 3/5] Update gateway_UDP.sh --- scripts/gateway/gateway_UDP.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/gateway/gateway_UDP.sh b/scripts/gateway/gateway_UDP.sh index 0a42ebc..11b7179 100644 --- a/scripts/gateway/gateway_UDP.sh +++ b/scripts/gateway/gateway_UDP.sh @@ -2,19 +2,21 @@ # get local ip from meta data server LOCALIP=$(curl http://169.254.169.254/latest/meta-data/local-ipv4) -LOCALNET=$( echo ${LOCALIP} | cut -f 1-3 -d".") +LOCALNET=$( echo ${LOCALIP} | cut -f 1-2 -d".") #ip forwarding rules + for ((base=0; base <=8; base++)) + { for ((n=1; n <=254; n++)) { - MOSH_BASE=$((30000+$n*10)) + MOSH_BASE=$((30000+$n + base *256)) + + + MOSH_PORT=$(($MOSH_BASE)) + echo ${MOSH_PORT} + iptables -t nat -A PREROUTING -i ens3 -p udp -m udp --dport ${MOSH_PORT} -j DNAT --to-destination ${LOCALNET}.${base}.${n}:${MOSH_PORT} + iptables -t nat -A POSTROUTING -d ${LOCALNET}.${base}.${n}/32 -p udp -m udp --dport ${MOSH_PORT} -j SNAT --to-source ${LOCALIP} - for ((m=0; m<=9; m++)) - { - MOSH_PORT=$(($MOSH_BASE+$m)) - #$echo ${MOSH_PORT} - iptables -t nat -A PREROUTING -i ens3 -p udp -m udp --dport ${MOSH_PORT} -j DNAT --to-destination ${LOCALNET}.${n}:${MOSH_PORT} - iptables -t nat -A POSTROUTING -d ${LOCALNET}.${n}/32 -p udp -m udp --dport ${MOSH_PORT} -j SNAT --to-source ${LOCALIP} - } } +} From 20d62effe5a7c444f45a37c29fabbec2f087ef13 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 08:57:08 +0000 Subject: [PATCH 4/5] feat(Dependencies): Update dependency openstacksdk to v2.1.0 | datasource | package | from | to | | ---------- | ------------ | ----- | ----- | | pypi | openstacksdk | 2.0.0 | 2.1.0 | --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 524be81..817b09a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ setuptools==69.0.3 thrift==0.16.0 python-keystoneclient==5.3.0 -openstacksdk==2.0.0 +openstacksdk==2.1.0 deprecated==1.2.14 Click==8.1.7 ansible==5.1.0 From 137987d1bc7628f98eca36b99b8ee36a5122f7e8 Mon Sep 17 00:00:00 2001 From: dweinholz Date: Wed, 17 Jan 2024 13:03:51 +0100 Subject: [PATCH 5/5] fixed tests --- .gitignore | 2 +- .../openstack_connector.py | 17 +++++++++++------ simple_vm_client/test_openstack_connector.py | 19 ++++++++----------- simple_vm_client/util/thrift_converter.py | 2 +- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index c210e3f..347834a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,7 @@ wheels/ *.egg-info/ .installed.cfg *.egg -.env.dsi +.env.* # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. diff --git a/simple_vm_client/openstack_connector/openstack_connector.py b/simple_vm_client/openstack_connector/openstack_connector.py index d73e947..13fd9d9 100644 --- a/simple_vm_client/openstack_connector/openstack_connector.py +++ b/simple_vm_client/openstack_connector/openstack_connector.py @@ -77,10 +77,10 @@ def __init__(self, config_file: str): self.APPLICATION_CREDENTIAL_ID = "" self.APPLICATION_CREDENTIAL_SECRET = "" self.USE_APPLICATION_CREDENTIALS: bool = False - self.NOVA_MICROVERSION = '2.1' + self.NOVA_MICROVERSION = "2.1" self.load_env_config() - print("loading config file") + logger.info(f"Loading config file -- {config_file}") self.load_config_yml(config_file) try: @@ -102,9 +102,11 @@ def __init__(self, config_file: str): project_name=self.PROJECT_NAME, user_domain_name=self.USER_DOMAIN_NAME, project_domain_id=self.PROJECT_DOMAIN_ID, - compute_api_version=self.NOVA_MICROVERSION + compute_api_version=self.NOVA_MICROVERSION, ) self.openstack_connection.authorize() + self.get_network() + logger.info("Connected to Openstack") self.create_or_get_default_ssh_security_group() except Exception: @@ -392,10 +394,13 @@ def create_volume( raise ResourceNotAvailableException(message=e.message) def get_network(self) -> Network: - network: Network = self.openstack_connection.network.find_network(self.NETWORK) + logger.info(f"Getting Network: {self.NETWORK}") + network: Network = self.openstack_connection.get_network( + name_or_id=self.NETWORK + ) if network is None: - logger.exception(f"Network {network} not found!") - raise Exception(f"Network {network} not found!") + logger.exception(f"Network {self.NETWORK} not found!") + raise Exception(f"Network {self.NETWORK} not found!") return network def import_keypair(self, keyname: str, public_key: str) -> dict[str, str]: diff --git a/simple_vm_client/test_openstack_connector.py b/simple_vm_client/test_openstack_connector.py index fd4edb4..f60e614 100644 --- a/simple_vm_client/test_openstack_connector.py +++ b/simple_vm_client/test_openstack_connector.py @@ -956,9 +956,7 @@ def test_create_volume(self, mock_logger_info, mock_logger_exception): ) def test_network_not_found(self): - self.openstack_connector.openstack_connection.network.find_network.return_value = ( - None - ) + self.openstack_connector.openstack_connection.get_network.return_value = None with self.assertRaises(Exception): self.openstack_connector.get_network() @@ -969,20 +967,19 @@ def test_get_network(self, mock_logger_exception): # Call the load_config_yml method with the temporary file path self.openstack_connector.load_config_yml(temp_file.name) + network = fakes.generate_fake_resource(Network) # Mock the find_network method - self.mock_openstack_connection.network.find_network.return_value = Network( - id="my_network" - ) + self.mock_openstack_connection.get_network.return_value = network # Call the get_network method result_network = self.openstack_connector.get_network() # Assertions self.assertIsInstance(result_network, Network) - self.assertEqual(result_network.id, "my_network") - self.mock_openstack_connection.network.find_network.assert_called_once_with( - self.openstack_connector.NETWORK + self.assertEqual(result_network.id, network.id) + self.mock_openstack_connection.get_network.assert_called_once_with( + name_or_id=self.openstack_connector.NETWORK ) mock_logger_exception.assert_not_called() # Ensure no exception is logged @@ -1509,7 +1506,7 @@ def test_start_server_with_playbook( self.openstack_connector.openstack_connection.get_flavor.return_value = ( fake_flavor ) - self.openstack_connector.openstack_connection.network.find_network.return_value = ( + self.openstack_connector.openstack_connection.get_network.return_value = ( fake_network ) mock_get_volumes.return_value = ["volume1", "volume2"] @@ -1787,7 +1784,7 @@ def test_start_server( self.openstack_connector.openstack_connection.get_flavor.return_value = ( fake_flavor ) - self.openstack_connector.openstack_connection.network.find_network.return_value = ( + self.openstack_connector.openstack_connection.get_network.return_value = ( fake_network ) self.openstack_connector.openstack_connection.compute.find_keypair.return_value = ( diff --git a/simple_vm_client/util/thrift_converter.py b/simple_vm_client/util/thrift_converter.py index 0cfd560..4be7d00 100644 --- a/simple_vm_client/util/thrift_converter.py +++ b/simple_vm_client/util/thrift_converter.py @@ -68,7 +68,7 @@ def os_to_thrift_volume(openstack_volume: OpenStack_Volume) -> Volume: device = openstack_volume.attachments[0]["device"] server_id = openstack_volume.attachments[0]["server_id"] except Exception as e: - logger.log(f"Exception on os_to_thrift_volume:\n{e}") + logger.error(f"Exception on os_to_thrift_volume:\n{e}") volume = Volume( status=openstack_volume.status, id=openstack_volume.id,