@ -786,8 +786,72 @@ sub load_interfces
delete $ anvil - > data - > { network } { $ host } ;
}
# Now load bond info
# Now load bridge info
my $ query = "
SELECT
bridge_uuid ,
bridge_name ,
bridge_id ,
bridge_mac_address ,
bridge_mtu ,
bridge_stp_enabled
FROM
bridges
WHERE
bridge_id != 'DELETED'
AND
bridge_host_uuid = ".$anvil->Database->quote($host_uuid)."
; " ;
$ anvil - > Log - > entry ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , key = > "log_0124" , variables = > { query = > $ query } } ) ;
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 ,
} } ) ;
foreach my $ row ( @ { $ results } )
{
my $ bridge_uuid = defined $ row - > [ 0 ] ? $ row - > [ 0 ] : "" ;
my $ bridge_name = defined $ row - > [ 1 ] ? $ row - > [ 1 ] : "" ;
my $ bridge_id = defined $ row - > [ 2 ] ? $ row - > [ 2 ] : "" ;
my $ bridge_mac_address = defined $ row - > [ 3 ] ? $ row - > [ 3 ] : "" ;
my $ bridge_mtu = defined $ row - > [ 4 ] ? $ row - > [ 4 ] : "" ;
my $ bridge_stp_enabled = defined $ row - > [ 5 ] ? $ row - > [ 5 ] : "" ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
bridge_uuid = > $ bridge_uuid ,
bridge_name = > $ bridge_name ,
bridge_id = > $ bridge_id ,
bridge_mac_address = > $ bridge_mac_address ,
bridge_mtu = > $ bridge_mtu ,
bridge_stp_enabled = > $ bridge_stp_enabled ,
} } ) ;
# Record the bridge_uuid -> name
$ anvil - > data - > { network } { $ host } { bridge_uuid } { $ bridge_uuid } { name } = $ bridge_name ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"network::${host}::bridge_uuid::${bridge_uuid}::name" = > $ anvil - > data - > { network } { $ host } { bridge_uuid } { $ bridge_uuid } { name } ,
} } ) ;
# We'll initially load empty strings for what would be the IP information. Any interface with IPs will be populated when we call
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { uuid } = $ bridge_uuid ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { id } = $ bridge_id ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { mac_address } = $ bridge_mac_address ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { mtu } = $ bridge_mtu ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { stp_enabled } = $ bridge_stp_enabled ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { type } = "bridge" ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { interfaces } = [] ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"network::${host}::interface::${bridge_name}::uuid" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { uuid } ,
"network::${host}::interface::${bridge_name}::id" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { id } ,
"network::${host}::interface::${bridge_name}::mac_address" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { mac_address } ,
"network::${host}::interface::${bridge_name}::mtu" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { mtu } ,
"network::${host}::interface::${bridge_name}::stp_enabled" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { stp_enabled } ,
"network::${host}::interface::${bridge_name}::type" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { type } ,
} } ) ;
}
# Now load bond info
$ query = "
SELECT
bond_uuid ,
bond_name ,
@ -800,15 +864,16 @@ SELECT
bond_up_delay ,
bond_down_delay ,
bond_mac_address ,
bond_operational
bond_operational ,
bond_bridge_uuid
FROM
bonds WHERE bond_mode != 'DELETED'
AND
bond_host_uuid = ".$anvil->Database->quote($host_uuid)."
; " ;
$ anvil - > Log - > entry ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , key = > "log_0124" , variables = > { query = > $ query } } ) ;
my $ results = $ anvil - > Database - > query ( { query = > $ query , source = > $ THIS_FILE , line = > __LINE__ } ) ;
my $ count = @ { $ results } ;
$ results = $ anvil - > Database - > query ( { query = > $ query , source = > $ THIS_FILE , line = > __LINE__ } ) ;
$ count = @ { $ results } ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
results = > $ results ,
count = > $ count ,
@ -827,6 +892,8 @@ AND
my $ bond_down_delay = defined $ row - > [ 9 ] ? $ row - > [ 9 ] : "" ;
my $ bond_mac_address = defined $ row - > [ 10 ] ? $ row - > [ 10 ] : "" ;
my $ bond_operational = defined $ row - > [ 11 ] ? $ row - > [ 11 ] : "" ;
my $ bond_bridge_uuid = defined $ row - > [ 12 ] ? $ row - > [ 12 ] : "" ;
my $ bridge_name = "" ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
bond_uuid = > $ bond_uuid ,
bond_name = > $ bond_name ,
@ -840,8 +907,20 @@ AND
bond_down_delay = > $ bond_down_delay ,
bond_mac_address = > $ bond_mac_address ,
bond_operational = > $ bond_operational ,
bond_bridge_uuid = > $ bond_bridge_uuid ,
} } ) ;
# If this bond is connected to a bridge, get the bridge name.
if ( ( $ bond_bridge_uuid ) && ( defined $ anvil - > data - > { network } { $ host } { bridge_uuid } { $ bond_bridge_uuid } { name } ) )
{
$ bridge_name = $ anvil - > data - > { network } { $ host } { bridge_uuid } { $ bond_bridge_uuid } { name } ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
bond_bridge_uuid = > $ bond_bridge_uuid ,
bridge_name = > $ bridge_name ,
} } ) ;
push @ { $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { interfaces } } , $ bond_name ;
}
# Record the bond_uuid -> name
$ anvil - > data - > { network } { $ host } { bond_uuid } { $ bond_uuid } { name } = $ bond_name ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
@ -860,6 +939,7 @@ AND
$ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { down_delay } = $ bond_down_delay ;
$ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { mac_address } = $ bond_mac_address ;
$ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { operational } = $ bond_operational ;
$ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { bridge_uuid } = $ bond_bridge_uuid ;
$ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { type } = "bond" ;
$ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { interfaces } = [] ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
@ -874,74 +954,11 @@ AND
"network::${host}::interface::${bond_name}::down_delay" = > $ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { down_delay } ,
"network::${host}::interface::${bond_name}::mac_address" = > $ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { mac_address } ,
"network::${host}::interface::${bond_name}::operational" = > $ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { operational } ,
"network::${host}::interface::${bond_name}::bridge_uuid" = > $ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { bridge } ,
"network::${host}::interface::${bond_name}::type" = > $ anvil - > data - > { network } { $ host } { interface } { $ bond_name } { type } ,
} } ) ;
}
# Now load bridge info
$ query = "
SELECT
bridge_uuid ,
bridge_name ,
bridge_id ,
bridge_mac_address ,
bridge_mtu ,
bridge_stp_enabled
FROM
bridges
WHERE
bridge_id != 'DELETED'
AND
bridge_host_uuid = ".$anvil->Database->quote($host_uuid)."
; " ;
$ anvil - > Log - > entry ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , key = > "log_0124" , variables = > { query = > $ query } } ) ;
$ results = $ anvil - > Database - > query ( { query = > $ query , source = > $ THIS_FILE , line = > __LINE__ } ) ;
$ count = @ { $ results } ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
results = > $ results ,
count = > $ count ,
} } ) ;
foreach my $ row ( @ { $ results } )
{
my $ bridge_uuid = defined $ row - > [ 0 ] ? $ row - > [ 0 ] : "" ;
my $ bridge_name = defined $ row - > [ 1 ] ? $ row - > [ 1 ] : "" ;
my $ bridge_id = defined $ row - > [ 2 ] ? $ row - > [ 2 ] : "" ;
my $ bridge_mac_address = defined $ row - > [ 3 ] ? $ row - > [ 3 ] : "" ;
my $ bridge_mtu = defined $ row - > [ 4 ] ? $ row - > [ 4 ] : "" ;
my $ bridge_stp_enabled = defined $ row - > [ 5 ] ? $ row - > [ 5 ] : "" ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
bridge_uuid = > $ bridge_uuid ,
bridge_name = > $ bridge_name ,
bridge_id = > $ bridge_id ,
bridge_mac_address = > $ bridge_mac_address ,
bridge_mtu = > $ bridge_mtu ,
bridge_stp_enabled = > $ bridge_stp_enabled ,
} } ) ;
# Record the bridge_uuid -> name
$ anvil - > data - > { network } { $ host } { bridge_uuid } { $ bridge_uuid } { name } = $ bridge_name ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"network::${host}::bridge_uuid::${bridge_uuid}::name" = > $ anvil - > data - > { network } { $ host } { bridge_uuid } { $ bridge_uuid } { name } ,
} } ) ;
# We'll initially load empty strings for what would be the IP information. Any interface with IPs will be populated when we call
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { uuid } = $ bridge_uuid ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { id } = $ bridge_id ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { mac_address } = $ bridge_mac_address ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { mtu } = $ bridge_mtu ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { stp_enabled } = $ bridge_stp_enabled ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { type } = "bridge" ;
$ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { interfaces } = [] ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"network::${host}::interface::${bridge_name}::uuid" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { uuid } ,
"network::${host}::interface::${bridge_name}::id" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { id } ,
"network::${host}::interface::${bridge_name}::mac_address" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { mac_address } ,
"network::${host}::interface::${bridge_name}::mtu" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { mtu } ,
"network::${host}::interface::${bridge_name}::stp_enabled" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { stp_enabled } ,
"network::${host}::interface::${bridge_name}::type" = > $ anvil - > data - > { network } { $ host } { interface } { $ bridge_name } { type } ,
} } ) ;
}
# The order will allow us to show the order in which the interfaces were changed, which the user can
# use to track interfaces as they unplug and plug cables back in.
my $ order = 1 ;