From ce907ff26aa77a89f9128430d91a11d2ecb22ce5 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Tue, 28 Nov 2023 15:27:07 -0500 Subject: [PATCH] Allow specifying static IPs instead of a file --- node-daemon/pvcnoded/util/config.py | 15 ++++++++------- pvc.sample.conf | 10 +++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/node-daemon/pvcnoded/util/config.py b/node-daemon/pvcnoded/util/config.py index a9d3a124..497424ac 100644 --- a/node-daemon/pvcnoded/util/config.py +++ b/node-daemon/pvcnoded/util/config.py @@ -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" diff --git a/pvc.sample.conf b/pvc.sample.conf index 9db3ead8..d0c74714 100644 --- a/pvc.sample.conf +++ b/pvc.sample.conf @@ -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