Changeset 2024 for trunk/LATMOS-Accounts/lib
- Timestamp:
- 05/05/17 16:12:29 (7 years ago)
- Location:
- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Iprecover.pm
r2020 r2024 61 61 62 62 if (my @cfilters = $self->{syncm}->ini->val($self->{name}, 'filter')) { 63 $filteredHosts = {}; 63 64 foreach ($self->{_base}->search_objects('nethost', @cfilters)) { 64 65 $filteredHosts->{$_} = 1; … … 66 67 } 67 68 68 my %hosts;69 my $hosts; 69 70 70 71 if (my @zones = $self->{syncm}->ini->val($self->{name}, 'netzone')) { 72 73 $hosts = {}; 71 74 72 75 my @filters; … … 79 82 }; 80 83 81 my @ hosts = $oZone->get_attributes('hosts');84 my @zonehosts = $oZone->get_attributes('hosts'); 82 85 83 push(@filters, [ 'name=' . join('||', @ hosts) ]);86 push(@filters, [ 'name=' . join('||', @zonehosts) ]); 84 87 85 88 if ($oZone->get_attributes('allow_dyn')) { … … 92 95 foreach ($self->{_base}->search_objects('nethost', @$filter)) { 93 96 $filteredHosts && !$filteredHosts->{$_} and next; 94 $hosts {$_} = 1;97 $hosts->{$_} = 1; 95 98 } 96 99 } 100 } else { 101 $hosts = $filteredHosts; 97 102 } 98 103 99 return %hosts;104 return $hosts; 100 105 } 101 106 102 107 sub run { 103 108 my ($self) = @_; 109 110 $self->{_base}->temp_switch_unexported(sub { 104 111 105 112 my $test = $self->{syncm}->ini->val($self->{name}, 'test'); … … 108 115 my $waitAfterModif = DateTime->now->subtract( days => $modifDelay )->iso8601; 109 116 110 my %hosts = $self->_filters; 111 117 my $hosts = $self->_filters; 112 118 113 119 my @HostToDisable = $self->{_base}->search_objects('nethost', 'exported=0', 'ip=*', 'date<' . $waitAfterModif); 114 120 115 foreach my $hostname (sort @HostToDisable) { 116 $hosts{$hostname} or next; 121 foreach my $hostname (@HostToDisable) { 122 if ($hosts) { 123 $hosts->{$hostname} or next; 124 } 117 125 my $Host = $self->{_base}->get_object('nethost', $hostname) or next; 118 126 $self->{_base}->log( 119 LA_ INFO,120 '%s Host %s disable because owner or user is inactive',127 LA_NOTICE, 128 '%sRecovering IP for host %s because is disable from a long time', 121 129 ($test ? '(Test) ' : ''), 122 130 $hostname, … … 128 136 $self->{_base}->commit() 129 137 unless($test); 138 139 }, 1); 130 140 } 131 132 141 133 142 1; -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Unusedhosts.pm
r2015 r2024 81 81 82 82 if (my @cfilters = $self->{syncm}->ini->val($self->{name}, 'filter')) { 83 $filteredHosts = {}; 83 84 foreach ($self->{_base}->search_objects('nethost', @cfilters)) { 84 85 $filteredHosts->{$_} = 1; … … 86 87 } 87 88 88 my %hosts;89 my $hosts; 89 90 90 91 if (my @zones = $self->{syncm}->ini->val($self->{name}, 'netzone')) { 92 93 $hosts = {}; 91 94 92 95 my @filters; … … 99 102 }; 100 103 101 my @ hosts = $oZone->get_attributes('hosts');102 103 push(@filters, [ 'name=' . join('||', @ hosts) ]);104 my @zonehosts = $oZone->get_attributes('hosts'); 105 106 push(@filters, [ 'name=' . join('||', @zonehosts) ]); 104 107 105 108 if ($oZone->get_attributes('allow_dyn')) { … … 112 115 foreach ($self->{_base}->search_objects('nethost', @$filter)) { 113 116 $filteredHosts && !$filteredHosts->{$_} and next; 114 $hosts{$_} = 1; 115 } 116 } 117 } 118 119 return %hosts; 117 $hosts->{$_} = 1; 118 } 119 } 120 } else { 121 $hosts = $filteredHosts; 122 } 123 124 return $hosts; 120 125 } 121 126 … … 128 133 la_log(LA_DEBUG, "Checking for host to disable using %s method", $mode); 129 134 130 my %hosts = $self->_filters;135 my $hosts = $self->_filters; 131 136 132 137 my @HostToDisable; … … 171 176 172 177 foreach my $hostname (sort @HostToDisable) { 173 $hosts{$hostname} or next; 178 if ($hosts) { 179 $hosts->{$hostname} or next; 180 } 174 181 my $Host = $self->{_base}->get_object('nethost', $hostname) or next; 175 182 $self->{_base}->log( 176 LA_ INFO,183 LA_NOTICE, 177 184 '%sHost %s disable because owner or user is inactive', 178 185 ($test ? '(Test) ' : ''), … … 195 202 la_log(LA_DEBUG, "Checking for host to disable using %s method", $mode); 196 203 197 my %hosts = $self->_filters;204 my $hosts = $self->_filters; 198 205 199 206 my @HostToEnable; … … 238 245 239 246 foreach my $hostname (sort @HostToEnable) { 240 $hosts{$hostname} or next; 247 if ($hosts) { 248 $hosts->{$hostname} or next; 249 } 241 250 my $Host = $self->{_base}->get_object('nethost', $hostname) or next; 242 251 $self->{_base}->log(
Note: See TracChangeset
for help on using the changeset viewer.