2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-22 11:42:05 +00:00

Merge pull request #6964 from gurevichmark/netstat

Use ip instead of deprecated netstat
This commit is contained in:
besawn 2021-05-04 15:30:39 -04:00 committed by GitHub
commit 9f3900e0bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 45 additions and 42 deletions

View File

@ -35,9 +35,9 @@ The \ **makenetworks**\ command can be used to gather network information from
Every network that will be used to install a cluster node must be defined in the xCAT database.
The default behavior is to gather network information from the management node, and any configured xCAT service nodes, and automatically save this information in the xCAT database.
The default behavior is to gather network information from the management node, and any configured xCAT service nodes, and automatically save that information in the xCAT database.
You can use the "-d" option to display the network information without writing it to the database.
You can use the \ **-d**\ option to display the network information without writing it to the database.
You can also redirect the output to a file that can be used with the xCAT \ **mkdef**\ command to define the networks.
@ -53,9 +53,9 @@ For example:
This features allows you to verify and modify the network information before writing it to the database.
When the network information is gathered a default value is created for the "netname" attribute. This is done to make it possible to use the mkdef, chdef, lsdef, and rmdef commands to manage this data.
When the network information is gathered a default value is created for the "netname" attribute. This is done to make it possible to use the \ **mkdef**\ , \ **chdef**\ , \ **lsdef**\ , and \ **rmdef**\ commands to manage this data.
The default naming convention is to use a hyphen separated "net" and "mask" value with the "." replace by "_". (ex. "8_124_47_64-255_255_255_0")
The default naming convention is to use a hyphen separated "net" and "mask" values with the "." replaced by "_". (ex. "8_124_47_64-255_255_255_0")
You can also modify the xCAT "networks" database table directly using the xCAT \ **tabedit**\ command.
@ -121,13 +121,19 @@ EXAMPLES
makenetworks -d
The output would be one or more stanzas of information similar to the following. The line that ends with a colon is the value of the "netname" attribute and is the name of the network object to use with the lsdef, mkdef, chdef and rmdef commands.
The output would be one or more stanzas of information similar to the following. The line that ends with a colon is the value of the "netname" attribute and is the name of the network object to use with the \ **lsdef**\ , \ **mkdef**\ , \ **chdef**\ and \ **rmdef**\ commands.
.. code-block:: perl
9_114_37_0-255_255_255_0:
objtype=network
gateway=9.114.37.254
mask=255.255.255.0
net=9.114.37.0
mgtifname=ens3
mtu=1500
9_114_37_0-255_255_255_0:
objtype=network
gateway=9.114.37.254
mask=255.255.255.0
net=9.114.37.0

View File

@ -16,9 +16,9 @@ The B<makenetworks> command can be used to gather network information from an xC
Every network that will be used to install a cluster node must be defined in the xCAT database.
The default behavior is to gather network information from the management node, and any configured xCAT service nodes, and automatically save this information in the xCAT database.
The default behavior is to gather network information from the management node, and any configured xCAT service nodes, and automatically save that information in the xCAT database.
You can use the "-d" option to display the network information without writing it to the database.
You can use the B<-d> option to display the network information without writing it to the database.
You can also redirect the output to a file that can be used with the xCAT B<mkdef> command to define the networks.
@ -30,9 +30,9 @@ For example:
This features allows you to verify and modify the network information before writing it to the database.
When the network information is gathered a default value is created for the "netname" attribute. This is done to make it possible to use the mkdef, chdef, lsdef, and rmdef commands to manage this data.
When the network information is gathered a default value is created for the "netname" attribute. This is done to make it possible to use the B<mkdef>, B<chdef>, B<lsdef>, and B<rmdef> commands to manage this data.
The default naming convention is to use a hyphen separated "net" and "mask" value with the "." replace by "_". (ex. "8_124_47_64-255_255_255_0")
The default naming convention is to use a hyphen separated "net" and "mask" values with the "." replaced by "_". (ex. "8_124_47_64-255_255_255_0")
You can also modify the xCAT "networks" database table directly using the xCAT B<tabedit> command.
@ -77,13 +77,15 @@ Display cluster network information but do not write the network definitions to
makenetworks -d
The output would be one or more stanzas of information similar to the following. The line that ends with a colon is the value of the "netname" attribute and is the name of the network object to use with the lsdef, mkdef, chdef and rmdef commands.
The output would be one or more stanzas of information similar to the following. The line that ends with a colon is the value of the "netname" attribute and is the name of the network object to use with the B<lsdef>, B<mkdef>, B<chdef> and B<rmdef> commands.
9_114_37_0-255_255_255_0:
9_114_37_0-255_255_255_0:
objtype=network
gateway=9.114.37.254
mask=255.255.255.0
net=9.114.37.0
mgtifname=ens3
mtu=1500
=back

View File

@ -370,19 +370,16 @@ sub donets
# For Linux systems
my @ip6table = split /\n/, `/sbin/ip -6 route`;
my @rtable = split /\n/, `/bin/netstat -rn`;
my @mtable = split /\n/, `/bin/netstat -i`;
splice @rtable, 0, 2;
splice @mtable, 0, 2;
my @rtable = split /\n/, `/sbin/ip -4 route`;
my @mtable = split /\n/, `/sbin/ip link|grep BROADCAST`;
my %netgw = ();
foreach my $rtent (@rtable)
{
my @entarr = split /\s+/, $rtent;
if ($entarr[3] eq 'UG')
if ($entarr[1] eq 'via' )
{
$netgw{ $entarr[0] }{ $entarr[2] } = $entarr[1];
$netgw{$entarr[0]} = $entarr[2];
}
}
@ -466,16 +463,17 @@ sub donets
next;
}
if ($ent[3] eq 'U')
if ($ent[1] eq 'dev')
{
$net = $ent[0];
$mask = $ent[2];
$mgtifname = $ent[7];
if (defined($netgw{'0.0.0.0'}{'0.0.0.0'}))
$netandmask = $ent[0];
$mgtifname = $ent[2];
($net, $mask) = split('/', $netandmask);
$mask = xCAT::NetworkUtils::formatNetmask($mask, 1, 0);
if (defined($netgw{'default'}))
{
if (xCAT::NetworkUtils->ishostinsubnet($netgw{'0.0.0.0'}{'0.0.0.0'}, $mask, $net))
if (xCAT::NetworkUtils->ishostinsubnet($netgw{'default'}, $mask, $net))
{
$gw = $netgw{'0.0.0.0'}{'0.0.0.0'}; #default gatetway
$gw = $netgw{'default'}; #default gatetway
}
}
@ -531,7 +529,7 @@ sub donets
foreach (grep /\s*$mgtifname\b/, @mtable)
{
@rowm = split(/\s+/, $_);
$mtu = $rowm[1];
$mtu = $rowm[4];
}
if ($::DISPLAY) {
@ -563,7 +561,7 @@ sub donets
my $tent=$nethash{$netname};
unless ($tent and $tent->{tftpserver})
{
my $netdev = $ent[7];
my $netdev = $ent[2];
my @netlines = split /\n/, `/sbin/ip addr show dev $netdev`;
foreach (grep /\s*inet\b/, @netlines)
{
@ -599,16 +597,6 @@ sub donets
#Nothing much sane to do for the other fields at the moment?
}
elsif ($ent[3] eq 'UG')
{
#TODO: networks through gateway. and how we might care..
}
else
{
#TODO: anything to do with such entries?
}
if ($::DISPLAY) {

View File

@ -141,6 +141,7 @@ makeknownhosts_node_d
tabdump_servicenode
makentp_h
makentp_v
makenetworks_d_V
mkdef_null
mkdef_regex_bmc
mkdef_regex_ip

View File

@ -142,6 +142,7 @@ makehosts_null
makeknownhosts_node_d
makentp_h
makentp_v
makenetworks_d_V
mkdef_null
mkdef_regex_bmc
mkdef_regex_ip

View File

@ -142,6 +142,7 @@ makehosts_null
makeknownhosts_node_d
makentp_h
makentp_v
makenetworks_d_V
mkdef_null
mkdef_regex_bmc
mkdef_regex_ip

View File

@ -102,6 +102,7 @@ makehosts_help
makehosts_n
makehosts_n_noderange
makeknownhosts_node_d
makenetworks_d_V
mkdef_null
mkdef_regex_bmc
mkdef_regex_ip

View File

@ -102,6 +102,7 @@ makehosts_help
makehosts_n
makehosts_n_noderange
makeknownhosts_node_d
makenetworks_d_V
mkdef_null
mkdef_regex_bmc
mkdef_regex_ip

View File

@ -71,6 +71,7 @@ makehosts_help
makehosts_n
makehosts_n_noderange
makeknownhosts_node_d
makenetworks_d_V
mkdef_null
mkdef_regex_bmc
mkdef_regex_ip

View File

@ -71,6 +71,7 @@ makehosts_help
makehosts_n
makehosts_n_noderange
makeknownhosts_node_d
makenetworks_d_V
mkdef_null
mkdef_regex_bmc
mkdef_regex_ip