Allow specifying static IPs instead of a file

This commit is contained in:
Joshua Boniface 2023-11-28 15:27:07 -05:00
parent 71e589e461
commit ce907ff26a
2 changed files with 11 additions and 14 deletions

View File

@ -163,7 +163,6 @@ def get_configuration_current(config_file):
try:
o_path = o_config["path"]
config_path = {
"node_ip_file": o_path["node_ip_file"],
"plugin_directory": o_path.get(
"plugin_directory", "/usr/share/pvc/plugins"
),
@ -246,17 +245,19 @@ def get_configuration_current(config_file):
if (
config_cluster_networks_specific[f"{network_type}_node_ip_selection"]
== "static"
== "by-id"
):
with open(config["node_ip_file"], "r") as ipfh:
ip_last_octet = ipfh.read().strip()
address_id = int(node_id) - 1
else:
# This roundabout solution ensures the given IP is in the subnet and is something valid
address_id = [
idx
for idx, ip in enumerate(list(network.hosts()))
if int(ip.split(".")[-1]) == ip_last_octet
if str(ip)
== config_cluster_networks_specific[
f"{network_type}_node_ip_selection"
]
][0]
else:
address_id = int(node_id) - 1
config_cluster_networks_specific[
f"{network_type}_dev_ip"

View File

@ -9,10 +9,6 @@
# Paths configuration
path:
# Node Static IP file
# Contains the last octet IP address of this node for use if node_ip_selection is "static" for any network
node_ip_file: "/etc/pvc/ipaddr"
# Plugin directory
plugin_directory: "/usr/share/pvc/plugins"
@ -96,7 +92,7 @@ cluster:
# Upstream/default gateway address
gateway_address: 10.0.0.254
# Node IP selection mechanism (either by-id or static; static requires additional configuration)
# Node IP selection mechanism (either "by-id", or a static IP, no netmask, in the above network)
node_ip_selection: by-id
# Cluster network, used for inter-node communication (VM- and Network-layer), unrouted
@ -123,7 +119,7 @@ cluster:
# Floating address
floating_address: 10.0.1.250
# Node IP selection mechanism (either by-id or static; static requires additional configuration)
# Node IP selection mechanism (either "by-id", or a static IP, no netmask, in the above network)
node_ip_selection: by-id
# Storage network, used for inter-node communication (Storage-layer), unrouted
@ -150,7 +146,7 @@ cluster:
# Floating address
floating_address: 10.0.2.250
# Node IP selection mechanism (either by-id or static; static requires additional configuration)
# Node IP selection mechanism (either "by-id", or a static IP, no netmask, in the above network)
node_ip_selection: by-id
# Database configuration