summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f705ecd)
raw | patch | inline | side by side (parent: f705ecd)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 5 Mar 2008 16:30:56 +0000 (16:30 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 5 Mar 2008 16:30:56 +0000 (16:30 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9369 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/server/events/gosaTriggered.pm | patch | blob | history |
index 81137df2dcc5fec9c7b042f205e1d016e8c34020..eb081e0995f01be0316cfad538d9b6ea8c166ce1 100644 (file)
$search.= ")";
# If there's any host inside of the search string, procress them
- if ($search =~ /macAddress/){
- # Perform search for Unit Tag
- my $mesg = $main::ldap_handle->search(
- base => $main::ldap_base,
- scope => 'sub',
- attrs => ['dn', 'FAIstate', 'objectClass'],
- filter => "$search"
- );
-
- if ($mesg->count) {
- my @entries = $mesg->entries;
- foreach my $entry (@entries) {
-
- # Only modify entry if it is not set to 'localboot'
- if ($entry->get_value("FAIstate") ne 'localboot'){
-
- &main::daemon_log("INFO: Setting FAIstate to 'localboot' for ".$entry->dn, 5);
- my $result;
- my %tmp = map { $_ => 1 } $entry->get_value("objectClass");
- if (exists $tmp{'FAIobject'}){
- if ($state eq ''){
- $result= $main::ldap_handle->modify($entry->dn, changes => [
- delete => [ FAIstate => [] ] ]);
- } else {
- $result= $main::ldap_handle->modify($entry->dn, changes => [
- replace => [ FAIstate => $state ] ]);
- }
- } elsif ($state ne ''){
- $result= $main::ldap_handle->modify($entry->dn, changes => [
- add => [ objectClass => 'FAIobject' ],
- add => [ FAIstate => $state ] ]);
- }
+ if (!($search =~ /macAddress/)){
+ return;
+ }
- # Errors?
- if ($result->code){
- &main::daemon_log("Error: Setting FAIstate to 'localboot' for ".$entry->dn. "failed: ".$result->error, 1);
+ # Perform search for Unit Tag
+ my $mesg = $main::ldap_handle->search(
+ base => $main::ldap_base,
+ scope => 'sub',
+ attrs => ['dn', 'FAIstate', 'objectClass'],
+ filter => "$search"
+ );
+
+ if ($mesg->count) {
+ my @entries = $mesg->entries;
+ foreach my $entry (@entries) {
+
+ # Only modify entry if it is not set to '$state'
+ if ($entry->get_value("FAIstate") ne "$state"){
+
+ &main::daemon_log("INFO: Setting FAIstate to '$state' for ".$entry->dn, 5);
+ my $result;
+ my %tmp = map { $_ => 1 } $entry->get_value("objectClass");
+ if (exists $tmp{'FAIobject'}){
+ if ($state eq ''){
+ $result= $main::ldap_handle->modify($entry->dn, changes => [
+ delete => [ FAIstate => [] ] ]);
+ } else {
+ $result= $main::ldap_handle->modify($entry->dn, changes => [
+ replace => [ FAIstate => $state ] ]);
}
+ } elsif ($state ne ''){
+ $result= $main::ldap_handle->modify($entry->dn, changes => [
+ add => [ objectClass => 'FAIobject' ],
+ add => [ FAIstate => $state ] ]);
+ }
+ # Errors?
+ if ($result->code){
+ &main::daemon_log("Error: Setting FAIstate to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
}
+
}
}
+ }
+ }
+}
+
+
+sub change_goto_state {
+ my ($st, $targets) = @_;
+
+ # Switch on or off?
+ my $state= $st eq 'active' ? 'active': 'locked';
+ &main::refresh_ldap_handle();
+ if( defined($main::ldap_handle) ) {
+
+ # Build search filter for hosts
+ my $search= "(&(objectClass=GOhard)";
+ foreach (@{$targets}){
+ $search.= "(macAddress=$_)";
+ }
+ $search.= ")";
+
+ # If there's any host inside of the search string, procress them
+ if ($search !=~ /macAddress/){
+ return;
+ }
+
+ # Perform search for Unit Tag
+ my $mesg = $main::ldap_handle->search(
+ base => $main::ldap_base,
+ scope => 'sub',
+ attrs => ['dn', 'gotoMode'],
+ filter => "$search"
+ );
+
+ if ($mesg->count) {
+ my @entries = $mesg->entries;
+ foreach my $entry (@entries) {
+
+ # Only modify entry if it is not set to '$state'
+ if ($entry->get_value("gotoMode") ne $state){
+
+ &main::daemon_log("INFO: Setting gotoMode to '$state' for ".$entry->dn, 5);
+ my $result;
+ $result= $main::ldap_handle->modify($entry->dn, changes => [
+ replace => [ gotoMode => $state ] ]);
+
+ # Errors?
+ if ($result->code){
+ &main::daemon_log("Error: Setting gotoMode to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
+ }
+
+ }
+ }
}
}
}
-
1;