Skip to content

Commit

Permalink
Merge pull request #742 from ClusterLabs/webui-backend-support
Browse files Browse the repository at this point in the history
Updated anvil-configure-host to support text config.
  • Loading branch information
digimer authored Sep 28, 2024
2 parents c90cc40 + 866d2de commit b4f660e
Show file tree
Hide file tree
Showing 7 changed files with 364 additions and 120 deletions.
14 changes: 5 additions & 9 deletions Anvil/Tools/Database.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4614,7 +4614,6 @@ AND
$query = "
SELECT
ip_address_uuid,
ip_address_host_uuid,
ip_address_on_type,
ip_address_on_uuid,
ip_address_address,
Expand All @@ -4639,14 +4638,12 @@ ORDER BY
foreach my $row (@{$results})
{
my $ip_address_uuid = $row->[0];
my $ip_address_host_uuid = $row->[1];
my $ip_address_on_type = $row->[2];
my $ip_address_on_uuid = $row->[3];
my $ip_address_address = $row->[4];
my $ip_address_subnet_mask = $row->[5];
my $ip_address_on_type = $row->[1];
my $ip_address_on_uuid = $row->[2];
my $ip_address_address = $row->[3];
my $ip_address_subnet_mask = $row->[4];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
ip_address_uuid => $ip_address_uuid,
ip_address_host_uuid => $ip_address_host_uuid,
ip_address_on_type => $ip_address_on_type,
ip_address_on_uuid => $ip_address_on_uuid,
ip_address_address => $ip_address_address,
Expand All @@ -4661,7 +4658,6 @@ ORDER BY
# Duplicate, delete it.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, priority => "alert", key => "warning_0001", variables => {
ip_address_uuid => $ip_address_uuid,
host_uuid => $ip_address_host_uuid,
on_type => $ip_address_on_type,
on_uuid => $ip_address_on_uuid,
ip_address => $ip_address_address,
Expand Down Expand Up @@ -4697,7 +4693,7 @@ ORDER BY
}

# We want to be able to map IPs to hosts.
$anvil->data->{ip_addresses}{$ip_address_address}{host_uuid} = $ip_address_host_uuid;
$anvil->data->{ip_addresses}{$ip_address_address}{host_uuid} = $host_uuid;
$anvil->data->{ip_addresses}{$ip_address_address}{ip_address_uuid} = $ip_address_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"ip_addresses::${ip_address_address}::host_uuid" => $anvil->data->{ip_addresses}{$ip_address_address}{host_uuid},
Expand Down
64 changes: 50 additions & 14 deletions Anvil/Tools/Network.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3327,6 +3327,7 @@ sub load_ips

if (not $host_uuid)
{
# The host UUID should be based on the host.
$host_uuid = $anvil->Get->host_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host_uuid => $host_uuid }});
}
Expand Down Expand Up @@ -3399,34 +3400,69 @@ AND
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { network_interface_uuid => $network_interface_uuid }});
}
else
{
my $query = "";
{
my $query = "";
my $active_interface = "";
if ($ip_address_on_type eq "bridge")
{
# What's the bridge UUID?
$query = "SELECT bond_name, bond_active_interface FROM bonds WHERE bond_bridge_uuid = ".$anvil->Database->quote($ip_address_on_uuid).";";
# is this on a bond? If so, what's the bond UUID?
my $query = "SELECT bond_name, bond_active_interface FROM bonds WHERE bond_bridge_uuid = ".$anvil->Database->quote($ip_address_on_uuid).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});

# Get the bridge name, also.
if (1)
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
if ($count)
{
# This is on a bridge
$bond_name = $results->[0]->[0];
$active_interface = $results->[0]->[1];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
bond_name => $bond_name,
active_interface => $active_interface,
}});

# Get the bridge name, also.
my $query = "SELECT bridge_name FROM bridges WHERE bridge_uuid = ".$anvil->Database->quote($ip_address_on_uuid).";";
$bridge_name = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { bridge_name => $bridge_name }});
}
else
{
# It must be on an interface then.
my $query = "SELECT network_interface_uuid, network_interface_name, network_interface_device FROM network_interfaces WHERE network_interface_bridge_uuid = ".$anvil->Database->quote($ip_address_on_uuid).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});

my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$network_interface_uuid = $results->[0]->[0];
$interface_name = $results->[0]->[1];
$interface_device = $results->[0]->[2];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
network_interface_uuid => $network_interface_uuid,
interface_name => $interface_name,
interface_device => $interface_device,
}});
}
}
else
{
# This is a bond
$query = "SELECT bond_name, bond_active_interface FROM bonds WHERE bond_uuid = ".$anvil->Database->quote($ip_address_on_uuid).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$bond_name = $results->[0]->[0];
$active_interface = $results->[0]->[1];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
bond_name => $bond_name,
active_interface => $active_interface,
}});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$bond_name = $results->[0]->[0];
my $active_interface = $results->[0]->[1];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
bond_name => $bond_name,
active_interface => $active_interface,
}});

# If this is a bond, or it is a bridge that is on a bond, find the
# network_interface_uuid.
if ($active_interface)
{
my $query = "
Expand Down
61 changes: 61 additions & 0 deletions man/anvil-configure-host.8
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,67 @@ When logging, record sensitive data, like passwords.
Set the log level to 1, 2 or 3 respectively. Be aware that level 3 generates a significant amount of log data.
.IP
.SS "Commands:"
\fB\-\-file\fR </path/to/file>
This provides an alternative to using the Striker UI's network configuration tool. To use this, create a file with the format;
.TP
.B Strikers
.EX
organization = <company>
prefix = <prefix>
sequence = 1+
domain = <domain name>
striker_password = <secret>
host_name = <striker full domain name>
gateway_interface = <ifnX,bcnX>
gateway = <ip, optional>
dns = <csv ips>
# If you have only one BCN but it's BCN 2 (or 3, 4...), set the BCN count to
# the number of the real BCN and the previous BCNs will be ignored.
ifn_count = 1
ifn1_ip = <ip>
ifn1_subnet_mask = <subnet>
ifn1_link1_mac_to_set = <mac>
ifn1_link2_mac_to_set = <mac, optional>
bcn_count = 1
bcn1_ip = <ip, 10.201.x.y>
bcn1_subnet_mask = <subnet>
bcn1_link1_mac_to_set = <mac>
bcn1_link2_mac_to_set = <mac, optional>
.EE
.TP
.B Nodes and DR hosts
.EX
### Nodes/DRHosts
# If you have only one BCN but it's BCN 2 (or 3, 4...), set the BCN count to
# the number of the real BCN and the previous BCNs will be ignored.
host_name = <full host name>
gateway_interface = <ifnX,bcnX>
gateway = <ip, optional>
dns = <csv ips>
bcn_count = 1
bcn1_ip = <ip, 10.201.x.y>
bcn1_subnet_mask = <subnet>
bcn1_create_bridge = [0.1]
bcn1_link1_mac_to_set = <mac>
bcn1_link2_mac_to_set = <mac, optional>
ifn_count = 1
ifn1_ip = <ip>
ifn1_subnet_mask = <subnet>
ifn1_create_bridge = [0,1]
ifn1_link1_mac_to_set = <mac>
ifn1_link2_mac_to_set = <mac, optional>
sn_count = 0+
sn1_ip = 10.101.x.y
sn1_subnet_mask = <subnet>
sn1_link1_mac_to_set = <mac, optional>
sn1_link2_mac_to_set = <mac, optional>
mn_count = 0+
mn1_ip = 10.199.x.y
mn1_subnet_mask = <subnet>
mn1_link1_mac_to_set = <mac, optional>
mn1_link2_mac_to_set = <mac, optional>
.EE
.TP
\fB\-\-job\-uuid\fR <name>
The program is normally run as a job, with data on how to configure the host defined in the job. This switch allows the running of a specific job. If this is not set, the program will search for a job that has not yet been picked up by another process. If found, that job UUID is used automatically.
.IP
Expand Down
8 changes: 4 additions & 4 deletions share/words.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ If you need any assistance, please feel free to contact #!string!brand_0001!# (h

<!-- Errors -->
<key name="error_0001">[ Error ] - Failed to find the SSH key that should have been in file: [#!variable!file!#] at line: [#!variable!line!#]!</key>
<key name="error_0002">#!free!#</key>
<key name="error_0002">[ Error ] - The config file: [#!variable!file!#] was not found.</key>
<key name="error_0003">None of the databases are accessible, unable to proceed. Please be sure that 'anvil-daemon' is enabled and running on the database machine(s).</key>
<key name="error_0004">#!free!#</key>
<key name="error_0004">Failed to find any interface to connect the bridge: [#!variable!bridge_name!#] to. This is likely a program error.</key>
<key name="error_0005">This program must run with 'root' level privileges.</key>
<key name="error_0006">No password was given, exiting.</key>
<key name="error_0007">The passwords don't match, exiting.</key>
Expand Down Expand Up @@ -1919,7 +1919,7 @@ The database connection error was:
<key name="log_0120"><![CDATA[The method 'Convert->round()' was passed the number: [#!variable!number!#] which contains an illegal value. Only digits and one decimal place are allowed.]]></key>
<key name="log_0121">[#!variable!timestamp!#] - The server: [#!variable!server_name!#] state is: [#!variable!server_state!#], not "shut off".
[ Note ] - Continuing to wait for it to shut off before proceeding with growing storage.</key>
<key name="log_0122">#!free!#</key>
<key name="log_0122">The network: [#!variable!network!#] on the host: [#!variable!host_name!#] doesn't exist, not waiting for it in '/etc/hosts'.</key>
<key name="log_0123">About to write the query: [#!variable!query!#].</key>
<key name="log_0124">About to query: [#!variable!query!#]</key>
<key name="log_0125">Entering method: [#!variable!method!#]</key>
Expand Down Expand Up @@ -2854,7 +2854,7 @@ NOTE: Please be patient!
<key name="message_0104">#!variable!timestamp!#; Updating Anvil! RPMs on: [#!variable!host_name!#].</key>
<key name="message_0105">#!variable!timestamp!#; The node's Anvil! RPMs are updated, now proceeding with main OS update.</key>
<key name="message_0106">Expired 'dnf' cache.</key>
<key name="message_0107">#!free!#</key>
<key name="message_0107">There is no bond interface, we will connect the bridge to the device: [#!variable!on_device!#] with the UUID: [#!variable!on_device_uuid!#].</key>
<key name="message_0108">#!free!#</key>
<key name="message_0109">#!free!#</key>
<key name="message_0110">#!free!#</key>
Expand Down
Loading

0 comments on commit b4f660e

Please sign in to comment.