diff --git a/src/openstack_workload_generator/__main__.py b/src/openstack_workload_generator/__main__.py index 7d50d26..81b97c6 100644 --- a/src/openstack_workload_generator/__main__.py +++ b/src/openstack_workload_generator/__main__.py @@ -45,9 +45,8 @@ "adds a ssh proxy jump for the hosts without a floating ip") parser.add_argument('--wait_for_machines', action="store_true", - help="Wait for every machine to be created " - "(normally the provisioning only waits for machines which use floating ips)") - + help="Wait for every machine to be created " + "(normally the provisioning only waits for machines which use floating ips)") parser.add_argument('--config', type=str, default="default.yaml", diff --git a/src/openstack_workload_generator/entities/domain.py b/src/openstack_workload_generator/entities/domain.py index addb4a2..641e1ef 100644 --- a/src/openstack_workload_generator/entities/domain.py +++ b/src/openstack_workload_generator/entities/domain.py @@ -98,6 +98,6 @@ def create_and_get_projects(self, create_projects: list[str]): self.workload_projects[project_name] = project project.close_connection() - def create_and_get_machines(self, machines: list[str]): + def create_and_get_machines(self, machines: list[str], wait_for_machines: bool): for project in self.workload_projects.values(): - project.get_and_create_machines(machines) + project.get_and_create_machines(machines, wait_for_machines) diff --git a/src/openstack_workload_generator/entities/helpers.py b/src/openstack_workload_generator/entities/helpers.py index e373a15..05f690a 100644 --- a/src/openstack_workload_generator/entities/helpers.py +++ b/src/openstack_workload_generator/entities/helpers.py @@ -2,7 +2,6 @@ import logging import os import sys -from pprint import pformat from typing import Tuple import coloredlogs @@ -23,6 +22,7 @@ class Config: 'admin_vm_ssh_keypair_name': 'my_ssh_public_key', 'project_ipv4_subnet': '192.168.200.0/24', 'public_network': "public", + 'network_mtu': '1500', 'number_of_floating_ips_per_project': "1", 'vm_flavor': 'SCS-1L-1', 'vm_image': 'Ubuntu 24.04', @@ -171,6 +171,10 @@ def quota(quota_name: str, quota_category: str, default_value: int) -> int: else: return default_value + @staticmethod + def get_network_mtu(): + return int(Config.get("network_mtu", regex=r"\d+")) + class DomainCache: _domains: dict[str, str] = dict() diff --git a/src/openstack_workload_generator/entities/network.py b/src/openstack_workload_generator/entities/network.py index 75e2470..5dabc34 100644 --- a/src/openstack_workload_generator/entities/network.py +++ b/src/openstack_workload_generator/entities/network.py @@ -115,7 +115,7 @@ def create_and_get_network(self) -> Network: self.obj_network = self.conn.network.create_network( name=self.network_name, project_id=self.project.id, - mtu=1500, + mtu=Config.get_network_mtu(), ) if not self.obj_network: raise RuntimeError(f"Unable to create network {self.network_name}") diff --git a/src/openstack_workload_generator/entities/project.py b/src/openstack_workload_generator/entities/project.py index 73b7da5..84165ba 100644 --- a/src/openstack_workload_generator/entities/project.py +++ b/src/openstack_workload_generator/entities/project.py @@ -251,7 +251,11 @@ def dump_inventory_hosts(self, directory_location: str): raise RuntimeError(f"Invalid reference to server for {workload_machine.machine_name}") workload_machine.update_assigned_ips() - data = { + + if not workload_machine.internal_ip: + raise RuntimeError(f"Unable to get associated ip address for {workload_machine.machine_name}") + + data: dict[str, str | dict[str, str]] = { "openstack": { "machine_id": workload_machine.obj.id, "machine_status": workload_machine.obj.status, @@ -267,7 +271,8 @@ def dump_inventory_hosts(self, directory_location: str): if self.ssh_proxy_jump and not workload_machine.floating_ip: data["ansible_ssh_common_args"] = f"-o ProxyJump={self.ssh_proxy_jump} " - base_dir = f"{directory_location}/{data['openstack']['domain']}-{data['openstack']['project']}-{data['hostname']}" + base_dir = f"{directory_location}/{self.domain.name}-{workload_machine.project.name}-{workload_machine.machine_name}" + filename = f'{base_dir}/data.yml' os.makedirs(base_dir, exist_ok=True) with open(filename, 'w') as file: