Skip to content

Commit 56580af

Browse files
committed
feat(nova-understack): move storage prefixes to config
Moved the storage prefix information to the configuration file instead of being hardcoded in the code.
1 parent 71649de commit 56580af

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

python/nova-understack/ironic_understack/conf.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,26 @@ def setup_conf():
2727
help="Controls if Nova should inject storage IPs to config drive.",
2828
default=True,
2929
),
30+
cfg.StrOpt(
31+
"storage_target_a_prefix",
32+
help="Storage Networking Target Prefix A-side",
33+
default="100.127.0.0/17",
34+
),
35+
cfg.StrOpt(
36+
"storage_target_b_prefix",
37+
help="Storage Networking Target Prefix B-side",
38+
default="100.127.128.0/17",
39+
),
40+
cfg.StrOpt(
41+
"storage_client_a_prefix",
42+
help="Storage Networking Client Prefix A-side",
43+
default="100.126.0.0/17",
44+
),
45+
cfg.StrOpt(
46+
"storage_client_b_prefix",
47+
help="Storage Networking Client Prefix B-side",
48+
default="100.126.128.0/17",
49+
),
3050
]
3151
cfg.CONF.register_group(grp)
3252
cfg.CONF.register_opts(opts, group=grp)

python/nova-understack/ironic_understack/nautobot_client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from uuid import UUID
55

66
import requests
7+
from oslo_config import cfg
78

89

910
@dataclass
@@ -30,10 +31,11 @@ def address(self) -> str:
3031
@property
3132
def target_network(self) -> ipaddress.IPv4Network:
3233
"""Returns the respective target-side network."""
33-
target_a_prefix = ipaddress.IPv4Network("100.127.0.0/17")
34-
target_b_prefix = ipaddress.IPv4Network("100.127.128.0/17")
35-
client_a_prefix = ipaddress.IPv4Network("100.126.0.0/17")
36-
client_b_prefix = ipaddress.IPv4Network("100.126.128.0/17")
34+
nova_us_cfg = cfg.CONF.nova_understack
35+
target_a_prefix = ipaddress.IPv4Network(nova_us_cfg.storage_target_a_prefix)
36+
target_b_prefix = ipaddress.IPv4Network(nova_us_cfg.storage_target_b_prefix)
37+
client_a_prefix = ipaddress.IPv4Network(nova_us_cfg.storage_client_a_prefix)
38+
client_b_prefix = ipaddress.IPv4Network(nova_us_cfg.storage_client_b_prefix)
3739

3840
if self.interface.ip in client_a_prefix:
3941
return target_a_prefix

0 commit comments

Comments
 (0)