diff --git a/docs/source/guides/admin-guides/references/man1/getadapter.1.rst b/docs/source/guides/admin-guides/references/man1/getadapter.1.rst index 982fcd4c3..316f4bcea 100644 --- a/docs/source/guides/admin-guides/references/man1/getadapter.1.rst +++ b/docs/source/guides/admin-guides/references/man1/getadapter.1.rst @@ -31,7 +31,7 @@ DESCRIPTION Traditionally, network interfaces in Linux are enumerated as eth[0123...], but these names do not necessarily correspond to actual labels on the chassis. \ **getadapter**\ help customer to get predictable network device name and some other network adapter information before provision or network configuration. -\ **getadapter**\ use genesis to collect network adapters information, so that mean it need to restart the target node. +\ **Since getadpter uses genesis to collect network adapters information, the target node will be restarted.**\ \ **getadapter**\ For each node within the , follows below scheme: @@ -41,16 +41,42 @@ If user hopes to scan the adapter information for the node but these information \ **getadapter**\ tries to collect more information for the target network device, but doesn't guarantee collect same much information for every network device. -Below are the possible information can be collect up to now: + +****************************** +\ **Collected information:**\ +****************************** + + + \ **name**\ : the consistent name which can be used by confignic directly in operating system which follow the same naming scheme with rhels7 + + + \ **pci**\ : the pci location + + + \ **mac**\ : the MAC address + + + \ **candidatename**\ : All the names which satisfy predictable network device naming scheme. \ *(if xcat enhance confignic command later, user can use these names to configure their network adapter, even customize their name)*\ + + + \ **vender**\ : the vender of network device + + + \ **model**\ : the model of network device + + + \ **linkstate**\ : the link state of network device + + ******* OPTIONS ******* diff --git a/xCAT-client/pods/man1/getadapter.1.pod b/xCAT-client/pods/man1/getadapter.1.pod index d9e43c6e9..0bdb93c42 100644 --- a/xCAT-client/pods/man1/getadapter.1.pod +++ b/xCAT-client/pods/man1/getadapter.1.pod @@ -12,7 +12,7 @@ B [B<-h>|B<--help>|B<-v>|B<--version>|B<-V>] Traditionally, network interfaces in Linux are enumerated as eth[0123...], but these names do not necessarily correspond to actual labels on the chassis. B help customer to get predictable network device name and some other network adapter information before provision or network configuration. -B use genesis to collect network adapters information, so that mean it need to restart the target node. +B B For each node within the , follows below scheme: @@ -22,14 +22,25 @@ If user hopes to scan the adapter information for the node but these information B tries to collect more information for the target network device, but doesn't guarantee collect same much information for every network device. -Below are the possible information can be collect up to now: -B: the consistent name which can be used by confignic directly in operating system which follow the same naming scheme with rhels7 -B: the pci location -B: the MAC address -B: All the names which satisfy predictable network device naming scheme. I<(if xcat enhance confignic command later, user can use these names to configure their network adapter, even customize their name)> -B: the vender of network device -B: the model of network device -B: the link state of network device +=head1 B + +=over 2 + +=item B: the consistent name which can be used by confignic directly in operating system which follow the same naming scheme with rhels7 + +=item B: the pci location + +=item B: the MAC address + +=item B: All the names which satisfy predictable network device naming scheme. I<(if xcat enhance confignic command later, user can use these names to configure their network adapter, even customize their name)> + +=item B: the vender of network device + +=item B: the model of network device + +=item B: the link state of network device + +=back =head1 OPTIONS diff --git a/xCAT-server/lib/xcat/plugins/getadapter.pm b/xCAT-server/lib/xcat/plugins/getadapter.pm index 19edc1817..3cdbe5bff 100644 --- a/xCAT-server/lib/xcat/plugins/getadapter.pm +++ b/xCAT-server/lib/xcat/plugins/getadapter.pm @@ -122,8 +122,8 @@ sub route_request { my $command = $request->{command}->[0]; my $ret = xCAT::State->REQUEST_ERROR; - if (scalar(@{ $request->{node} }) == 0) { - return $ret; + if (!$request->{node}) { + return xCAT::State->REQUEST_WAIT; } my $build_request_message_func = sub { @@ -404,7 +404,7 @@ sub update_adapter_result { $interface_exists = 0; if (exists($msg->{nic}->[$i]->{interface})) { - $output .= $msg->{nic}->[$i]->{interface}; + $output .= $msg->{nic}->[$i]->{interface}."!"; if ($has_nic) { $data .= "," . $msg->{nic}->[$i]->{interface} . "!"; } @@ -414,38 +414,46 @@ sub update_adapter_result { $interface_exists = 1; $has_nic = 1; } + my @nic_attrs = (); + my @output_attrs = (); if (exists($msg->{nic}->[$i]->{mac})) { - $output .= "!mac=" . $msg->{nic}->[$i]->{mac}; + push(@output_attrs, "mac=" . $msg->{nic}->[$i]->{mac}); if ($interface_exists) { - $data .= " mac=" . $msg->{nic}->[$i]->{mac}; + push(@nic_attrs, "mac=" . $msg->{nic}->[$i]->{mac}); } } if (exists($msg->{nic}->[$i]->{pcilocation})) { - $output .= "|pci=" . $msg->{nic}->[$i]->{pcilocation}; + push(@output_attrs, "pci=" . $msg->{nic}->[$i]->{pcilocation}); if ($interface_exists) { - $data .= "pci=" . $msg->{nic}->[$i]->{pcilocation}; + push(@nic_attrs, "pci=" . $msg->{nic}->[$i]->{pcilocation}); } } if (exists($msg->{nic}->[$i]->{predictablename})) { - $output .= "|candidatename=" . $msg->{nic}->[$i]->{predictablename}; + push(@output_attrs, "candidatename=" . $msg->{nic}->[$i]->{predictablename}); } if (exists($msg->{nic}->[$i]->{vendor})) { - $output .= "|vendor=" . $msg->{nic}->[$i]->{vendor}; + $msg->{nic}->[$i]->{vendor} =~ s/^\s+|\s+$//g; + push(@output_attrs, "vendor=" . $msg->{nic}->[$i]->{vendor}); } if (exists($msg->{nic}->[$i]->{model})) { - $output .= "|model=" . $msg->{nic}->[$i]->{model}; + $msg->{nic}->[$i]->{model} =~ s/^\s+|\s+$//g; + push(@output_attrs, "model=" . $msg->{nic}->[$i]->{model}); } if (exists($msg->{nic}->[$i]->{linkstate})) { - $output .= "|linkstate=" . $msg->{nic}->[$i]->{linkstate}; + push(@output_attrs, "linkstate=" . (split(' ', $msg->{nic}->[$i]->{linkstate}))[0]); if ($interface_exists) { - $data .= " linkstate=" . $msg->{nic}->[$i]->{linkstate}; + push(@nic_attrs, "linkstate=". (split(' ', $msg->{nic}->[$i]->{linkstate}))[0]); } } + if (@nic_attrs) { + $data .= join(" ", @nic_attrs); + } + $output .= join("|", @output_attrs); $output .= "\n"; } $callback->({ data => "$output" }); if (!$has_nic) { - $callback->({ data => "$node: nics talbe will not be updated as not any ". + $callback->({ data => "$node: nics table will not be updated as not any ". "useful information could be found with udevadm command." }); return 0; }