diff --git a/perl-xCAT/xCAT/DSHCLI.pm b/perl-xCAT/xCAT/DSHCLI.pm index 70dc7f3f3..d101986eb 100644 --- a/perl-xCAT/xCAT/DSHCLI.pm +++ b/perl-xCAT/xCAT/DSHCLI.pm @@ -711,9 +711,6 @@ sub fork_fanout_dcp my $user_target = shift @$targets_waiting; my $target_properties = $$resolved_targets{$user_target}; - # todo remove code - #my @shorthostname = split(/\./, $user_target); - #$user_target = $shorthostname[0]; my @dcp_command; my $rsyncfile; @@ -2841,27 +2838,6 @@ sub _resolve_nodes # unresolved nodes will be determined when the remote shell runs xCAT::DSHCLI->bld_resolve_nodes_hash($options, \%resolved_nodes, @nodes); - # todo remove code - #xCAT::DSHCore->resolve_hostnames($options, \%resolved_nodes, - # \%unresolved_nodes, $context_targets, - # @nodes); - #xCAT::DSHCore->removeExclude(\%resolved_nodes, $unresolved_targets, - # $context_targets); - #xCAT::DSHCore->removeExclude($resolved_targets, \%unresolved_nodes, - # $context_targets); - - #foreach my $node (keys(%unresolved_nodes)) - #{ - # my $node_properties = $unresolved_nodes{$node}; - - # $$node_properties{'type'} = 'node'; - # $$unresolved_targets{$node} = $node_properties; - - # my $rsp = {}; - # $rsp->{data}->[0] = - # "The specified node $node address is not resolvable in the cluster."; - # xCAT::MsgUtils->message("E", $rsp, $::CALLBACK); - #} foreach my $user_node (keys(%resolved_nodes)) { @@ -2968,8 +2944,6 @@ sub verify_targets foreach my $user_target (keys(%$resolved_targets)) { - # todo remove my @shorthostname = split(/\./, $user_target); - # push @ping_list, $shorthostname[0]; my $hostname = $$resolved_targets{$user_target}{'hostname'}; push @ping_list, $hostname; } diff --git a/perl-xCAT/xCAT/DSHCore.pm b/perl-xCAT/xCAT/DSHCore.pm index 5f82822fa..7242fc18f 100644 --- a/perl-xCAT/xCAT/DSHCore.pm +++ b/perl-xCAT/xCAT/DSHCore.pm @@ -664,122 +664,6 @@ sub ping_hostnames return @no_response; } -#--------------------------------------------------------------------------- - -=head3 - resolve_hostnames - - Resolve all related information for a given target, including context - IP address information and fully qualified hostname. If the target is - unresolvable include in a list of unresolvable targets, otherwise store - all resolved properties for the target. - - Arguments: - $options - options hash table describing dsh configuration options - $resolved_targets - hash table of resolved properties, keyed by target name - $unresolved_targets - hash table of unresolved targets and relevant property information - $context_targets - hash table of targets grouped by context name - @target_list - input list of target names to resolve - - Returns: - None - - Globals: - None - - Error: - None - - Example: - - Comments: - -=cut - -#--------------------------------------------------------------------------- - -sub resolve_hostnames -{ - my ($class, $options, $resolved_targets, $unresolved_targets, - $context_targets, @target_list) - = @_; - my @local_inet; - scalar(@local_inet) || xCAT::DSHCore->ifconfig_inet; - - foreach my $context_user_target (@target_list) - { - my ($context, $user_target) = split ':', $context_user_target; - if (($context eq 'XCAT') && ($$options{'context'} eq 'DSH')) - { - - # The XCAT context may not be specified for this node since DSH is the only - # available context. - my $rsp={}; - $rsp->{data}->[0] = "DSH is the only available context.\n"; - xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); - next; - } - !$user_target - && ( ($user_target = $context) - && ($context = $$options{'context'})); - - my ($user, $target) = split '@', $user_target; - !$target && (($target = $user) && ($user = undef)); - - $$options{'context-all'} && ($context = $$options{'context-all'}); - - if (my ($hostname, $aliases, $addrtype, $length, @addrs) = - gethostbyname($target)) - { - my $ip_address = inet_ntoa($addrs[0]); - my $localhost = (grep { /^$ip_address$/ } @local_inet) || undef; - - if ($hostname eq $ip_address) - { - my $packed_ip = inet_aton($ip_address); - my $hostbyaddr = gethostbyaddr($packed_ip, AF_INET); - $hostbyaddr && ($hostname = $hostbyaddr); - } - - my %properties = ( - 'hostname' => $hostname, - 'ip-address' => $ip_address, - 'localhost' => $localhost, - 'user' => $user, - 'context' => $context, - 'unresolved' => $target - ); - - $user && ($user .= '@'); - $$resolved_targets{"$user$hostname"} = \%properties; - - if ($context_targets) - { - if (!$$context_targets{$context}) - { - my %context_target_list = (); - $$context_targets{$context} = \%context_target_list; - } - - $$context_targets{$context}{"$user$hostname"}++; - } - } - - else - { - my %properties = ( - 'hostname' => $target, - 'user' => $user, - 'context' => $context, - 'unresolved' => $target - ); - $$unresolved_targets{"$user_target"} = \%properties; - } - } - - xCAT::DSHCore->removeExclude($resolved_targets, $unresolved_targets, - $context_targets); -} #--------------------------------------------------------------------------- @@ -832,61 +716,4 @@ sub pping_hostnames return @no_response; } -#--------------------------------------------------------------------------- - -sub removeExclude -{ - shift; - my ($resolved_targets, $unresolved_targets, $context_targets) = @_; - return if (!$resolved_targets || !$unresolved_targets); - - my @invalid_resolved_targets; - my @invalid_unresolved_targets; - - %::__EXCLUDED_TARGETS; - - for my $unrsvl_tg (keys %$unresolved_targets) - { - if ($unresolved_targets->{$unrsvl_tg}->{'hostname'} =~ /^-/) - { - $::__EXCLUDED_TARGETS{$unrsvl_tg} = - $unresolved_targets->{$unrsvl_tg}; - delete $unresolved_targets->{$unrsvl_tg}; - } - } - - for my $excluded_tg (keys %::__EXCLUDED_TARGETS) - { - for my $rslv_tg (keys %$resolved_targets) - { - if ( $::__EXCLUDED_TARGETS{$excluded_tg}->{'hostname'} eq '-' - . $resolved_targets->{$rslv_tg}->{'hostname'} - || $::__EXCLUDED_TARGETS{$excluded_tg}->{'hostname'} eq '-' - . $resolved_targets->{$rslv_tg}->{'ip-address'} - || $::__EXCLUDED_TARGETS{$excluded_tg}->{'hostname'} eq '-' - . $resolved_targets->{$rslv_tg}->{'unresolved'} - || $::__EXCLUDED_TARGETS{$excluded_tg}->{'unresolved'} eq '-' - . $resolved_targets->{$rslv_tg}->{'hostname'} - || $::__EXCLUDED_TARGETS{$excluded_tg}->{'unresolved'} eq '-' - . $resolved_targets->{$rslv_tg}->{'ip-address'} - || $::__EXCLUDED_TARGETS{$excluded_tg}->{'unresolved'} eq '-' - . $resolved_targets->{$rslv_tg}->{'unresolved'}) - { - push @invalid_resolved_targets, $rslv_tg; - } - } - } - - for my $invalid_res (@invalid_resolved_targets) - { - my $context = $resolved_targets->{$invalid_res}->{'context'}; - delete $context_targets->{$context}->{$invalid_res}; - if (!scalar(keys %{$context_targets->{$context}})) - { - delete $context_targets->{$context}; - } - delete $resolved_targets->{$invalid_res}; - } - -} 1;