From 5c1978d5a06f0fc3ecc3b8c88cf3ad103cf49d6e Mon Sep 17 00:00:00 2001 From: Digimer Date: Mon, 25 Oct 2021 19:16:01 -0400 Subject: [PATCH 1/3] Updated D-Link switch config notes. Signed-off-by: Digimer --- notes | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/notes b/notes index 7fa37928..c9234d5e 100644 --- a/notes +++ b/notes @@ -960,19 +960,24 @@ OS10(config)# write memory OS10(config)# hostname zo-switch01 zo-switch01(config)# interface vlan 100 zo-switch01(conf-if-vl-100)# description BCN1 +zo-switch01(config)# exit zo-switch01(conf-if-vl-100)# interface range ethernet 1/1/1-1/1/14 zo-switch01(conf-range-eth1/1/1-1/1/10)# switchport access vlan 100 zo-switch01(conf-range-eth1/1/1-1/1/10)# no shutdown zo-switch01(conf-range-eth1/1/1-1/1/10)# exit + zo-switch01(config)# interface vlan 200 zo-switch01(conf-if-vl-200)# description SN1 -zo-switch01(conf-if-vl-200)# interface range ethernet 1/1/11-1/1/14 +zo-switch01(conf-if-vl-200)# exit +zo-switch01(config)# interface range ethernet 1/1/11-1/1/14 zo-switch01(conf-range-eth1/1/11-1/1/14)# switchport access vlan 200 zo-switch01(conf-range-eth1/1/11-1/1/14)# no shutdown zo-switch01(conf-range-eth1/1/11-1/1/14)# exit + zo-switch01(config)# interface vlan 300 zo-switch01(conf-if-vl-300)# description IFN1 -zo-switch01(conf-if-vl-300)# interface range ethernet 1/1/15-1/1/24 +zo-switch01(conf-if-vl-300)# exit +zo-switch01(config)# interface range ethernet 1/1/15-1/1/24 zo-switch01(conf-range-eth1/1/15-1/1/24)# switchport access vlan 300 zo-switch01(conf-range-eth1/1/15-1/1/24)# no shutdown zo-switch01(conf-range-eth1/1/15-1/1/24)# exit @@ -1223,13 +1228,6 @@ rs-striker03(config-if)#switchport access vlan 100 rs-striker03(config-if)#no shutdown rs-striker03(config-if)#exit -rs-striker03(config)#interface vlan 300 -rs-striker03(config)#name IFN -rs-striker03(config-if-vlan300)#interface range gigabitethernet1/0/15-24,gigabitethernet2/0/15-24 -rs-striker03(config-if)#switchport access vlan 300 -rs-striker03(config-if)#no shutdown -rs-striker03(config-if)#exit -rs-striker03(config)#exit rs-striker03#show vlan @@ -1412,3 +1410,33 @@ totem.transport (str) = knet Gi1/0/24 + Gi2/0/24 +Dell LACP Config (OS10 - https://www.dell.com/support/kbdoc/en-us/000102901/dell-emc-networking-os10-how-to-set-up-virtual-link-trunking-vlt) + +* On both switches; +zo-switch02# configure terminal + +* IFN Port channel is 3 +zo-switch02(config)# interface port-channel 3 +zo-switch02(conf-if-po-3)# <165>1 2021-10-19T04:58:56.022086+00:00 zo-switch02 dn_alm 920 - - Node.1-Unit.1:PRI [event], Dell EMC (OS10) %IFM_ASTATE_UP: Interface admin state up :port-channel3 +<165>1 2021-10-19T04:58:56.022722+00:00 zo-switch02 dn_alm 920 - - Node.1-Unit.1:PRI [event], Dell EMC (OS10) %IFM_OSTATE_DN: Interface operational state is down :port-channel3 +zo-switch02(conf-if-po-3)# lacp fallback enable +zo-switch02(conf-if-po-3)# description IFN1 +zo-switch02(conf-if-po-3)# exit +zo-switch02(config)# exit +zo-switch02# show port-channel summary + +Flags: D - Down I - member up but inactive P - member up and active + U - Up (port-channel) F - Fallback Activated +-------------------------------------------------------------------------------- +Group Port-Channel Type Protocol Member Ports +-------------------------------------------------------------------------------- +3 port-channel3 (D) Eth STATIC +1000 port-channel1000 (U) Eth STATIC 1/1/25(P) 1/1/26(P) + +zo-switch02# configure terminal +zo-switch02(config)# interface ethernet 1/1/24 +zo-switch02(conf-if-eth1/1/24)# channel-group 3 +zo-switch02(conf-if-eth1/1/24)# <165>1 2021-10-19T05:09:41.237808+00:00 zo-switch02 dn_alm 920 - - Node.1-Unit.1:PRI [event], Dell EMC (OS10) %IFM_OSTATE_UP: Interface operational state is up :port-channel3 +exit +exit + From 257a9987436ba2f672ec34c948d4c81b0f4fd624 Mon Sep 17 00:00:00 2001 From: Digimer Date: Thu, 28 Oct 2021 12:07:36 -0400 Subject: [PATCH 2/3] * Updated Database->configure_pgsql() to use 'postgresql-setup --initdb --unit postgresql' instead of the deprecaded 'initdb' switch. * Updated Database->insert_or_update_states() to switch to an active UUID if the passed in UUID is not an active handle. * Updated Database->query() to swutch to 'sys::database::read_uuid' if the passed in 'uuid' is not an active handle. * Updated Database->_test_access() to return immediately if the passed in uuid is not an active handle. * Started working on a Storage->get_storage_group_from_path() bug where the storage group isn't being returned. Signed-off-by: Digimer --- Anvil/Tools/Database.pm | 53 ++++++++++++++++++++--- Anvil/Tools/Storage.pm | 17 +++++--- scancore-agents/scan-apc-ups/scan-apc-ups | 4 +- share/words.xml | 1 + tools/anvil-manage-server | 8 +++- tools/striker-get-peer-data | 2 +- 6 files changed, 69 insertions(+), 16 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 7e84ee06..bb75e94a 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -806,7 +806,7 @@ sub configure_pgsql if (not -e $anvil->data->{path}{configs}{'pg_hba.conf'}) { # Initialize. Record that we did so, so that we know to start the daemon. - my ($output, $return_code) = $anvil->System->call({debug => 1, shell_call => $anvil->data->{path}{exe}{'postgresql-setup'}." initdb", source => $THIS_FILE, line => __LINE__}); + my ($output, $return_code) = $anvil->System->call({debug => 1, shell_call => $anvil->data->{path}{exe}{'postgresql-setup'}." --initdb --unit postgresql", source => $THIS_FILE, line => __LINE__}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { output => $output, return_code => $return_code }}); # Did it succeed? @@ -12031,7 +12031,20 @@ sub insert_or_update_states # If we were passed a database UUID, check for the open handle. if ($uuid) { - $anvil->data->{cache}{database_handle}{$uuid} = "" if not defined $anvil->data->{cache}{database_handle}{$uuid}; + if ((not defined $anvil->data->{cache}{database_handle}{$uuid}) or (not $anvil->data->{cache}{database_handle}{$uuid})) + { + # Switch to another UUID + foreach my $this_uuid (keys %{$anvil->data->{cache}{database_handle}}) + { + if ($anvil->data->{cache}{database_handle}{$this_uuid}) + { + # Switch to this UUID + $uuid = $this_uuid; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { uuid => $uuid }}); + } + } + } + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "cache::database_handle::${uuid}" => $anvil->data->{cache}{database_handle}{$uuid}, }}); @@ -15300,9 +15313,26 @@ sub query } elsif (not defined $anvil->data->{cache}{database_handle}{$uuid}) { - # Database handle is gone. - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0073", variables => { uuid => $uuid }}); - return("!!error!!"); + # Database handle is gone. Switch to the read_uuid + my $old_uuid = $uuid; + $uuid = $anvil->data->{sys}{database}{read_uuid}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + old_uuid => $old_uuid, + uuid => $uuid, + }}); + if (not defined $anvil->data->{cache}{database_handle}{$uuid}) + { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0073", variables => { uuid => $uuid }}); + return("!!error!!"); + } + else + { + # Warn that we switched. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "log_0073", variables => { + old_uuid => $old_uuid, + new_uuid => $uuid, + }}); + } } if (not $query) { @@ -17391,6 +17421,8 @@ This method takes a database UUID and tests the connection to it using the DBD ' This exists to handle the loss of a database mid-run where a normal query, which isn't wrapped in a query, could hang indefinately. +B<< Note >>: If there is no active handle, this returns 0 immediately. + =cut sub _test_access { @@ -17401,7 +17433,16 @@ sub _test_access $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->_test_access()" }}); my $uuid = $parameter->{uuid} ? $parameter->{uuid} : ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { uuid => $uuid }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + uuid => $uuid, + "cache::database_handle::${uuid}" => $anvil->data->{cache}{database_handle}{$uuid}, + }}); + + # If the handle is down, return 0. + if ((not exists $anvil->data->{cache}{database_handle}{$uuid}) or (not $anvil->data->{cache}{database_handle}{$uuid})) + { + return(0); + } # Make logging code a little cleaner my $database_name = defined $anvil->data->{database}{$uuid}{name} ? $anvil->data->{database}{$uuid}{name} : $anvil->data->{sys}{database}{name}; diff --git a/Anvil/Tools/Storage.pm b/Anvil/Tools/Storage.pm index d29a7fca..7afbc752 100644 --- a/Anvil/Tools/Storage.pm +++ b/Anvil/Tools/Storage.pm @@ -2177,6 +2177,7 @@ sub get_storage_group_from_path } # Is this a DRBD path? + my $gathered_data = 0; my $logical_volume = ""; if ($path !~ /drbd/) { @@ -2188,8 +2189,9 @@ sub get_storage_group_from_path # Looks like it. If the device path is '/dev/drbd/by-res/...' we'll need to pull out the # resource name (server name) and volume number as the path only actually exists when DRBD is # up and isn't referenced in the config file. - my $resource = ""; - my $volume = ""; + my $resource = ""; + my $volume = ""; + $gathered_data = 1; $anvil->DRBD->gather_data({debug => $debug}); if ($path =~ /\/dev\/drbd\/by-res\/(.*)\/(\d+)$/) { @@ -2342,10 +2344,13 @@ LIMIT 1 scan_drbd_resource_xml => $scan_drbd_resource_xml, }}); - $anvil->DRBD->gather_data({ - debug => 3, - xml => $scan_drbd_resource_xml, - }); + if (not $gathered_data) + { + $anvil->DRBD->gather_data({ + debug => 3, + xml => $scan_drbd_resource_xml, + }); + } # Dig out the LV behind the volume. foreach my $this_host_name (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{host}}) diff --git a/scancore-agents/scan-apc-ups/scan-apc-ups b/scancore-agents/scan-apc-ups/scan-apc-ups index 3c5b2b15..94c5c2fe 100755 --- a/scancore-agents/scan-apc-ups/scan-apc-ups +++ b/scancore-agents/scan-apc-ups/scan-apc-ups @@ -1480,8 +1480,8 @@ WHERE my $alert_sent = 0; my $variables = { ups_name => $scan_apc_ups_name, - new_value => $scan_apc_ups_battery_model, - old_value => $old_scan_apc_ups_battery_model, + new_value => $scan_apc_ups_battery_percentage_charge, + old_value => $old_scan_apc_ups_battery_percentage_charge, battery_number => $battery_number, low_charge_clear => $anvil->data->{'scan-apc-ups'}{low_charge_percentage_ok}, low_charge_alert => $anvil->data->{'scan-apc-ups'}{low_charge_percentage_warning}, diff --git a/share/words.xml b/share/words.xml index 8b6c8946..43ba5578 100644 --- a/share/words.xml +++ b/share/words.xml @@ -2056,6 +2056,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is: The target can be reached on the dedicated migration network: [#!variable!target!#] via the IP address: [#!variable!ip!#], switching to use that for the RAM copy. [ Note ] - The IP address: [#!variable!ip!#] with 'ip_address_uuid': [#!variable!uuid!#] is a duplicate, removing it from the database(s). The database dump file: [#!variable!file!#] exists, skipping database setup. + query() was asked to query the database with UUID: [#!variable!old_uuid!#] but there is no file handle open to the database. Switched the read to: [#!variable!new_uuid!#].]]> The host name: [#!variable!target!#] does not resolve to an IP address. diff --git a/tools/anvil-manage-server b/tools/anvil-manage-server index 07c37325..975a8cdf 100755 --- a/tools/anvil-manage-server +++ b/tools/anvil-manage-server @@ -661,6 +661,7 @@ sub interactive_configure_main print "[ 3 ] - Storage\n"; print "[ 4 ] - Network\n"; print "[ 5 ] - Boot Order\n"; + print "[ 6 ] - Cluster Management\n"; print "\n"; print "[ B ] - Back\n"; print "[ Q ] - Quit\n"; @@ -696,6 +697,11 @@ sub interactive_configure_main print "Going to Boot order menu\n"; sleep 1; } + elsif ($answer eq "6") + { + print "Going to cluster manager menu\n"; + sleep 1; + } elsif (lc($answer) eq "b") { $anvil->data->{target_server}{server_name} = ""; @@ -815,7 +821,7 @@ sub interactive_configure_storage }}); my $this_storage_group_uuid = $anvil->Storage->get_storage_group_from_path({ - debug => 3, + debug => 2, anvil_uuid => $anvil_uuid, path => $this_path, }); diff --git a/tools/striker-get-peer-data b/tools/striker-get-peer-data index 52ed6b97..cb6119d2 100755 --- a/tools/striker-get-peer-data +++ b/tools/striker-get-peer-data @@ -340,7 +340,7 @@ sub get_password } my $query = "SELECT state_note FROM states WHERE state_uuid = ".$anvil->Database->quote($anvil->data->{switches}{'state-uuid'}).";"; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); my $password = $anvil->Database->query({uuid => $anvil->data->{sys}{host_uuid}, debug => 3, query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0]; $password = "" if not defined $password; From 32f29861a4c8b228235841361572fd5f97240fdb Mon Sep 17 00:00:00 2001 From: Digimer Date: Mon, 15 Nov 2021 01:01:23 -0500 Subject: [PATCH 3/3] * Fixed a bug (maybe) that was causing users to get immediately logged out of the WebUI * Fixed a bug (maybe) that was breaking initial DB setup on Strikers. Signed-off-by: Digimer --- Anvil/Tools/Account.pm | 10 ++++++---- Anvil/Tools/Database.pm | 4 +++- cgi-bin/striker | 10 +++++----- notes | 2 ++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Anvil/Tools/Account.pm b/Anvil/Tools/Account.pm index 030c9846..68fbaf2d 100644 --- a/Anvil/Tools/Account.pm +++ b/Anvil/Tools/Account.pm @@ -451,7 +451,8 @@ AND $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); $anvil->Database->write({debug => $debug, query => $query, source => $THIS_FILE, line => __LINE__}); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0198", variables => { user => $anvil->data->{cgi}{username}{value} }}); + my $user = $anvil->data->{cgi}{username}{value} ? $anvil->data->{cgi}{username}{value} : "--"; + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0198", variables => { user => $user }}); # Log that they're out $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0179"}); @@ -573,7 +574,7 @@ AND $anvil->data->{sys}{users}{user_name} = $results->[0]->[0]; $anvil->data->{sessions}{session_salt} = $results->[0]->[1]; $anvil->data->{sessions}{session_salt} = "" if not defined $anvil->data->{sessions}{session_salt}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "sys::users::user_name" => $anvil->data->{sys}{users}{user_name}, "sessions::session_salt" => $anvil->data->{sessions}{session_salt}, }}); @@ -592,8 +593,9 @@ AND offset => -86400, }); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - today_hash => $today_hash, - yesterday_hash => $yesterday_hash, + "s1:cookie::anvil_user_hash" => $anvil->data->{cookie}{anvil_user_hash}, + "s2:today_hash" => $today_hash, + "s3:yesterday_hash" => $yesterday_hash, }}); # See if either hash matches what the user has stored. diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index bb75e94a..fdfee948 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -1321,12 +1321,14 @@ sub connect # If we're a Striker, see if we're configured. my $local_host_type = $anvil->Get->host_type(); my $local_host_uuid = $anvil->Get->host_uuid(); + my $db_count = keys %{$anvil->data->{database}}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { local_host_type => $local_host_type, local_host_uuid => $local_host_uuid, check_if_configured => $check_if_configured, real_uid => $<, effective_uid => $>, + db_count => $db_count, }}); # If requested, and if running with root access, set it up (or update it) if needed. # This method just returns if nothing is needed. @@ -1708,7 +1710,7 @@ sub connect } # If we're a striker and no connections were found, start our database. - if (($local_host_type eq "striker") && (not $anvil->data->{sys}{database}{connections})) + if (($local_host_type eq "striker") && (not $anvil->data->{sys}{database}{connections}) && ($db_count > 1)) { # Tell the user we're going to try to load and start. $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0650"}); diff --git a/cgi-bin/striker b/cgi-bin/striker index 85bc0858..d7f32cb5 100755 --- a/cgi-bin/striker +++ b/cgi-bin/striker @@ -265,7 +265,7 @@ sub process_task $anvil->data->{cgi}{login}{value} = "" if not defined $anvil->data->{cgi}{login}{value}; $anvil->data->{cgi}{logout}{value} = "" if not defined $anvil->data->{cgi}{logout}{value}; $anvil->data->{cgi}{save}{value} = "" if not defined $anvil->data->{cgi}{save}{value}; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "cgi::login::value" => $anvil->data->{cgi}{login}{value}, "cgi::logout::value" => $anvil->data->{cgi}{logout}{value}, "cgi::save::value" => $anvil->data->{cgi}{save}{value}, @@ -297,14 +297,14 @@ sub process_task # 1 - No cookie was found or read. The user needs to log in # 2 - There was a problem reading the user's UUID (it wasn't found in the database), so the # cookies were deleted (via C<< Account->logout() >>. The user needs to log back in. - # 3 - There user's hash is invalid, it is probably expired. The user has been logged out and + # 3 - Their user's hash is invalid, it is probably expired. The user has been logged out and # needs to log back in. - my $cookie_problem = $anvil->Account->read_cookies(); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { cookie_problem => $cookie_problem }}); + my $cookie_problem = $anvil->Account->read_cookies({debug => 2}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { cookie_problem => $cookie_problem }}); if (not $cookie_problem) { $logged_in = 1; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { logged_in => $logged_in }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { logged_in => $logged_in }}); } } diff --git a/notes b/notes index c9234d5e..81134638 100644 --- a/notes +++ b/notes @@ -18,6 +18,8 @@ SELECT a.scan_apc_ups_name AS name, a.scan_apc_ups_serial_number AS sn, a.scan_a ============ +dnf -y install augeas + Jenkins;