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

View File

@ -9,10 +9,6 @@
# Paths configuration # Paths configuration
path: 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
plugin_directory: "/usr/share/pvc/plugins" plugin_directory: "/usr/share/pvc/plugins"
@ -96,7 +92,7 @@ cluster:
# Upstream/default gateway address # Upstream/default gateway address
gateway_address: 10.0.0.254 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 node_ip_selection: by-id
# Cluster network, used for inter-node communication (VM- and Network-layer), unrouted # Cluster network, used for inter-node communication (VM- and Network-layer), unrouted
@ -123,7 +119,7 @@ cluster:
# Floating address # Floating address
floating_address: 10.0.1.250 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 node_ip_selection: by-id
# Storage network, used for inter-node communication (Storage-layer), unrouted # Storage network, used for inter-node communication (Storage-layer), unrouted
@ -150,7 +146,7 @@ cluster:
# Floating address # Floating address
floating_address: 10.0.2.250 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 node_ip_selection: by-id
# Database configuration # Database configuration