Skip to content

Commit 789a4ec

Browse files
author
Marc Schöchlin
committed
Use random passwords by default and output them
Signed-off-by: Marc Schöchlin <[email protected]>
1 parent 06a7e46 commit 789a4ec

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/openstack_workload_generator/entities/helpers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import inspect
22
import logging
33
import os
4+
import secrets
5+
import string
46
import sys
57
from datetime import datetime
68
from typing import Tuple, Any
@@ -13,11 +15,15 @@
1315

1416
LOGGER = logging.getLogger()
1517

18+
def get_random_password() -> str:
19+
characters = string.ascii_letters + string.digits
20+
password = ''.join(secrets.choice(characters) for _ in range(16))
21+
return password
1622

1723
class Config:
1824
_config: dict[str, str | dict[str, str] | None] = {
19-
"admin_domain_password": "",
20-
"admin_vm_password": "",
25+
"admin_domain_password": get_random_password(),
26+
"admin_vm_password": get_random_password(),
2127
"admin_vm_ssh_key": "",
2228
"admin_vm_ssh_keypair_name": "my_ssh_public_key",
2329
"project_ipv4_subnet": "192.168.200.0/24",

src/openstack_workload_generator/entities/machine.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def create_or_get_server(self, network: Network, wait_for_machine: bool):
101101
if self.obj:
102102
LOGGER.info(
103103
f"Created server {self.obj.name}/{self.obj.id} in {ProjectCache.ident_by_id(network.project_id)}"
104+
f" with password >>>{self.root_password}<<<"
104105
)
105106
else:
106107
raise RuntimeError(

src/openstack_workload_generator/entities/user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def create_and_get_user(self) -> User:
5151
)
5252
self.assign_role_to_user("manager")
5353
LOGGER.info(
54-
f"Created user {self.obj.name} / {self.obj.id} with password {self.obj.password} in {DomainCache.ident_by_id(self.domain.id)}"
54+
f"Created user {self.obj.name} / {self.obj.id} with password >>>{self.obj.password}<<< in {DomainCache.ident_by_id(self.domain.id)}"
5555
)
5656
return self.obj
5757

0 commit comments

Comments
 (0)