Skip to content

Commit 46740ce

Browse files
committed
Make ShiftStack UPI network resource changes
triggered by OCPBUGS-33973 Resolves OCPBUGS-37970
1 parent b2e0d60 commit 46740ce

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

modules/installation-osp-creating-network-resources.adoc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,29 @@ Create the network resources that an {product-title} on {rh-openstack-first} ins
1717

1818
. For a dual stack cluster deployment, edit the `inventory.yaml` file and uncomment the `os_subnet6` attribute.
1919

20+
. To ensure that your network resources have unique names on the {rh-openstack} deployment, create an environment variable and JSON file for use in the Ansible playbooks:
21+
+
22+
.. Create an environment variable that has a unique name value by running the following command:
23+
+
24+
[source,terminal]
25+
----
26+
$ export OS_NET_ID="openshift-$(dd if=/dev/urandom count=4 bs=1 2>/dev/null |hexdump -e '"%02x"')"
27+
----
28+
29+
.. Verify that the variable is set by running the following command on a command line:
30+
+
31+
[source,terminal]
32+
----
33+
$ echo $OS_NET_ID
34+
----
35+
36+
.. Create a JSON object that includes the variable in a file called `netid.json` by running the following command:
37+
+
38+
[source,terminal]
39+
----
40+
$ echo "{\"os_net_id\": \"$OS_NET_ID\"}" | tee netid.json
41+
----
42+
2043
. On a command line, create the network resources by running the following command:
2144
+
2245
[source,terminal]

modules/installation-osp-fixing-subnet.adoc

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,39 @@ The IP range that the installation program uses by default might not match the N
2424
+
2525
[source,terminal]
2626
----
27-
$ python -c 'import yaml
27+
$ python -c 'import os
28+
import sys
29+
import yaml
30+
import re
31+
re_os_net_id = re.compile(r"{{\s*os_net_id\s*}}")
32+
os_net_id = os.getenv("OS_NET_ID")
33+
path = "common.yaml"
34+
facts = None
35+
for _dict in yaml.safe_load(open(path))[0]["tasks"]:
36+
if "os_network" in _dict.get("set_fact", {}):
37+
facts = _dict["set_fact"]
38+
break
39+
if not facts:
40+
print("Cannot find `os_network` in common.yaml file. Make sure OpenStack resource names are defined in one of the tasks.")
41+
sys.exit(1)
42+
os_network = re_os_net_id.sub(os_net_id, facts["os_network"])
43+
os_subnet = re_os_net_id.sub(os_net_id, facts["os_subnet"])
2844
path = "install-config.yaml"
2945
data = yaml.safe_load(open(path))
3046
inventory = yaml.safe_load(open("inventory.yaml"))["all"]["hosts"]["localhost"]
3147
machine_net = [{"cidr": inventory["os_subnet_range"]}]
3248
api_vips = [inventory["os_apiVIP"]]
3349
ingress_vips = [inventory["os_ingressVIP"]]
34-
ctrl_plane_port = {"network": {"name": inventory["os_network"]}, "fixedIPs": [{"subnet": {"name": inventory["os_subnet"]}}]}
35-
if inventory.get("os_subnet6"): <1>
50+
ctrl_plane_port = {"network": {"name": os_network}, "fixedIPs": [{"subnet": {"name": os_subnet}}]}
51+
if inventory.get("os_subnet6_range"): <1>
52+
os_subnet6 = re_os_net_id.sub(os_net_id, facts["os_subnet6"])
3653
machine_net.append({"cidr": inventory["os_subnet6_range"]})
3754
api_vips.append(inventory["os_apiVIP6"])
3855
ingress_vips.append(inventory["os_ingressVIP6"])
3956
data["networking"]["networkType"] = "OVNKubernetes"
4057
data["networking"]["clusterNetwork"].append({"cidr": inventory["cluster_network6_cidr"], "hostPrefix": inventory["cluster_network6_prefix"]})
4158
data["networking"]["serviceNetwork"].append(inventory["service_subnet6_range"])
42-
ctrl_plane_port["fixedIPs"].append({"subnet": {"name": inventory["os_subnet6"]}})
59+
ctrl_plane_port["fixedIPs"].append({"subnet": {"name": os_subnet6}})
4360
data["networking"]["machineNetwork"] = machine_net
4461
data["platform"]["openstack"]["apiVIPs"] = api_vips
4562
data["platform"]["openstack"]["ingressVIPs"] = ingress_vips

0 commit comments

Comments
 (0)