6
6
import random
7
7
import typing as t
8
8
9
-
10
9
@dataclass
11
10
class OSRelease :
12
11
distribution : str
13
12
release : str
14
13
ssh_username : str
15
14
16
-
17
15
@dataclass
18
16
class OpenStackRelease :
19
17
version : str
20
- previous_version : str
21
18
os_releases : t .List [OSRelease ]
22
19
23
-
24
20
@dataclass
25
21
class Scenario :
26
22
openstack_release : OpenStackRelease
27
23
os_release : OSRelease
28
24
neutron_plugin : str
29
25
upgrade : str
30
26
31
-
32
27
ROCKY_9 = OSRelease ("rocky" , "9" , "cloud-user" )
33
28
UBUNTU_JAMMY = OSRelease ("ubuntu" , "jammy" , "ubuntu" )
34
29
UBUNTU_NOBLE = OSRelease ("ubuntu" , "noble" , "ubuntu" )
35
30
# NOTE(upgrade): Add supported releases here.
36
31
OPENSTACK_RELEASES = [
37
- OpenStackRelease ("2023.1" , "zed" , [ROCKY_9 , UBUNTU_JAMMY ]),
38
- OpenStackRelease ("2024.1" , "2023.1" , [ROCKY_9 , UBUNTU_JAMMY ]),
39
- OpenStackRelease ("2025.1" , "2024.1" , [ROCKY_9 , UBUNTU_NOBLE ]),
32
+ OpenStackRelease ("2023.1" , [ROCKY_9 , UBUNTU_JAMMY ]),
33
+ OpenStackRelease ("2024.1" , [ROCKY_9 , UBUNTU_JAMMY ]),
34
+ OpenStackRelease ("2025.1" , [ROCKY_9 , UBUNTU_NOBLE ]),
40
35
]
41
36
NEUTRON_PLUGINS = ["ovs" , "ovn" ]
42
-
37
+ VERSION_HIERARCHY = [ "zed" , "2023.1" , "2024.1" , "2025.1" ]
43
38
44
39
def main () -> None :
45
40
scenario = random_scenario ()
46
41
inputs = generate_inputs (scenario )
47
42
for name , value in inputs .items ():
48
43
write_output (name , value )
49
44
50
-
51
45
def random_scenario () -> Scenario :
52
46
openstack_release = random .choice (OPENSTACK_RELEASES )
53
47
os_release = random .choice (openstack_release .os_releases )
54
48
neutron_plugin = random .choice (NEUTRON_PLUGINS )
55
49
upgrade = 'major' if random .random () > 0.6 else 'none'
56
50
return Scenario (openstack_release , os_release , neutron_plugin , upgrade )
57
51
58
-
59
52
def generate_inputs (scenario : Scenario ) -> t .Dict [str , str ]:
60
53
branch = get_branch (scenario .openstack_release .version )
61
- previous_branch = get_branch (scenario .openstack_release .previous_version )
54
+ previous_branch = get_branch (VERSION_HIERARCHY [ VERSION_HIERARCHY . index ( scenario .openstack_release .version ) - 1 ] )
62
55
inputs = {
63
56
"os_distribution" : scenario .os_release .distribution ,
64
57
"os_release" : scenario .os_release .release ,
@@ -70,14 +63,12 @@ def generate_inputs(scenario: Scenario) -> t.Dict[str, str]:
70
63
}
71
64
return inputs
72
65
73
-
74
66
def get_branch (version : str ) -> str :
75
67
return f"stackhpc/{ version } "
76
68
77
69
78
70
def write_output (name : str , value : str ) -> None :
79
71
print (f"{ name } ={ value } " )
80
72
81
-
82
73
if __name__ == "__main__" :
83
74
main ()
0 commit comments