Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/openstack_workload_generator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/openstack_workload_generator/entities/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 5 additions & 1 deletion src/openstack_workload_generator/entities/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
import os
import sys
from pprint import pformat
from typing import Tuple
import coloredlogs

Expand All @@ -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',
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions src/openstack_workload_generator/entities/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ def create_and_get_network_setup(self) -> Network:
return network

def create_and_get_router(self, subnet: Subnet) -> Router | None:
public_network = self.conn.network.find_network('public')
public_network = self.conn.network.find_network(Config.get_public_network())
if not public_network:
LOGGER.error("There is no 'public' network")
LOGGER.error(f"There is no '{Config.get_public_network()}' network, not adding floating ips")
return None

if self.obj_router:
Expand Down Expand Up @@ -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=1342
mtu=Config.get_network_mtu(),
)
if not self.obj_network:
raise RuntimeError(f"Unable to create network {self.network_name}")
Expand Down
9 changes: 7 additions & 2 deletions src/openstack_workload_generator/entities/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down