diff --git a/docs/source/guides/admin-guides/references/man8/makenetworks.8.rst b/docs/source/guides/admin-guides/references/man8/makenetworks.8.rst index 6cead8f4d..0ee0733c3 100644 --- a/docs/source/guides/admin-guides/references/man8/makenetworks.8.rst +++ b/docs/source/guides/admin-guides/references/man8/makenetworks.8.rst @@ -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 diff --git a/xCAT-client/pods/man8/makenetworks.8.pod b/xCAT-client/pods/man8/makenetworks.8.pod index 402873c43..f7c4f3173 100644 --- a/xCAT-client/pods/man8/makenetworks.8.pod +++ b/xCAT-client/pods/man8/makenetworks.8.pod @@ -16,9 +16,9 @@ The B 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 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, B, B, and B 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 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, B, B and B 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 diff --git a/xCAT-server/lib/xcat/plugins/networks.pm b/xCAT-server/lib/xcat/plugins/networks.pm index 5bd4141c8..e56b4dd60 100644 --- a/xCAT-server/lib/xcat/plugins/networks.pm +++ b/xCAT-server/lib/xcat/plugins/networks.pm @@ -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) { diff --git a/xCAT-test/autotest/bundle/rhels_ppc_daily.bundle b/xCAT-test/autotest/bundle/rhels_ppc_daily.bundle index 92129c212..50a0de914 100644 --- a/xCAT-test/autotest/bundle/rhels_ppc_daily.bundle +++ b/xCAT-test/autotest/bundle/rhels_ppc_daily.bundle @@ -141,6 +141,7 @@ makeknownhosts_node_d tabdump_servicenode makentp_h makentp_v +makenetworks_d_V mkdef_null mkdef_regex_bmc mkdef_regex_ip diff --git a/xCAT-test/autotest/bundle/rhels_ppcle_daily.bundle b/xCAT-test/autotest/bundle/rhels_ppcle_daily.bundle index f8b4cb4ad..a39991440 100644 --- a/xCAT-test/autotest/bundle/rhels_ppcle_daily.bundle +++ b/xCAT-test/autotest/bundle/rhels_ppcle_daily.bundle @@ -142,6 +142,7 @@ makehosts_null makeknownhosts_node_d makentp_h makentp_v +makenetworks_d_V mkdef_null mkdef_regex_bmc mkdef_regex_ip diff --git a/xCAT-test/autotest/bundle/rhels_x86_daily.bundle b/xCAT-test/autotest/bundle/rhels_x86_daily.bundle index b5f2fadc0..608e862ee 100644 --- a/xCAT-test/autotest/bundle/rhels_x86_daily.bundle +++ b/xCAT-test/autotest/bundle/rhels_x86_daily.bundle @@ -142,6 +142,7 @@ makehosts_null makeknownhosts_node_d makentp_h makentp_v +makenetworks_d_V mkdef_null mkdef_regex_bmc mkdef_regex_ip diff --git a/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle b/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle index 3a0443bda..db5fb3832 100644 --- a/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle +++ b/xCAT-test/autotest/bundle/sles_ppcle_daily.bundle @@ -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 diff --git a/xCAT-test/autotest/bundle/sles_x86_daily.bundle b/xCAT-test/autotest/bundle/sles_x86_daily.bundle index 0b1d3e307..33c28f32a 100644 --- a/xCAT-test/autotest/bundle/sles_x86_daily.bundle +++ b/xCAT-test/autotest/bundle/sles_x86_daily.bundle @@ -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 diff --git a/xCAT-test/autotest/bundle/ubuntu_ppcle_daily.bundle b/xCAT-test/autotest/bundle/ubuntu_ppcle_daily.bundle index 753958701..92a9daad8 100644 --- a/xCAT-test/autotest/bundle/ubuntu_ppcle_daily.bundle +++ b/xCAT-test/autotest/bundle/ubuntu_ppcle_daily.bundle @@ -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 diff --git a/xCAT-test/autotest/bundle/ubuntu_x86_daily.bundle b/xCAT-test/autotest/bundle/ubuntu_x86_daily.bundle index 83ba17e6a..712a82052 100644 --- a/xCAT-test/autotest/bundle/ubuntu_x86_daily.bundle +++ b/xCAT-test/autotest/bundle/ubuntu_x86_daily.bundle @@ -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