monitoring/NPalert/AlertDB.pm | 19 monitoring/NPalert/ContactMethod.pm | 1 monitoring/NPalert/NotifIniInterface.pm | 12 monitoring/NPalert/NotificationDB.pm | 6 monitoring/NPalert/PhoneContactMethod.pm | 68 --- monitoring/NPalert/SNMPContactMethod.pm | 220 ---------- monitoring/NPalert/Send.pm | 1 monitoring/NPalert/test/TODO2 | 3 monitoring/NPalert/test/TestAlertDB.pm | 14 monitoring/NPalert/test/TestNotificationDB.pm | 38 - monitoring/NPalert/test/TestPhoneContactMethod.pm | 32 - rel-eng/packages/spacewalk-schema | 2 schema/spacewalk/oracle/triggers/rhn_contact_methods.sql | 11 schema/spacewalk/postgres/triggers/rhn_contact_methods.sql | 11 schema/spacewalk/spacewalk-schema.spec | 5 schema/spacewalk/upgrade/spacewalk-schema-1.6-to-spacewalk-schema-1.7/011-rhn_contact_methods.sql.oracle | 57 ++ schema/spacewalk/upgrade/spacewalk-schema-1.6-to-spacewalk-schema-1.7/011-rhn_contact_methods.sql.postgresql | 32 + 17 files changed, 95 insertions(+), 437 deletions(-)
New commits: commit 6324b86ab7760620ad5d0015932a23ec987c4828 Author: Miroslav Suchý msuchy@redhat.com Date: Wed Feb 1 15:34:40 2012 +0100
Automatic commit of package [spacewalk-schema] release [1.7.21-1].
diff --git a/rel-eng/packages/spacewalk-schema b/rel-eng/packages/spacewalk-schema index a8223ac..4f8c541 100644 --- a/rel-eng/packages/spacewalk-schema +++ b/rel-eng/packages/spacewalk-schema @@ -1 +1 @@ -1.7.20-1 schema/spacewalk/ +1.7.21-1 schema/spacewalk/ diff --git a/schema/spacewalk/spacewalk-schema.spec b/schema/spacewalk/spacewalk-schema.spec index 75110ee..3116fb0 100644 --- a/schema/spacewalk/spacewalk-schema.spec +++ b/schema/spacewalk/spacewalk-schema.spec @@ -2,7 +2,7 @@ Name: spacewalk-schema Group: Applications/Internet Summary: Oracle SQL schema for Spacewalk server
-Version: 1.7.20 +Version: 1.7.21 Release: 1%{?dist} Source0: %{name}-%{version}.tar.gz
@@ -66,6 +66,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/spacewalk-sql*
%changelog +* Wed Feb 01 2012 Miroslav Suchý 1.7.21-1 +- rip off SNMP notification method + * Wed Jan 25 2012 Michael Mraka michael.mraka@redhat.com 1.7.20-1 - 756918 - fix data for package_group
commit af12fcc73912e6642daa3335784c2f28d203de86 Author: Miroslav Suchý msuchy@redhat.com Date: Wed Feb 1 15:22:50 2012 +0100
get rid of PhoneContactMethod - is is not even in DB
diff --git a/monitoring/NPalert/NotifIniInterface.pm b/monitoring/NPalert/NotifIniInterface.pm index 7bac23d..19845b2 100644 --- a/monitoring/NPalert/NotifIniInterface.pm +++ b/monitoring/NPalert/NotifIniInterface.pm @@ -12,7 +12,6 @@ use NOCpulse::Log::Logger; use NOCpulse::Notif::PagerContactMethod; use NOCpulse::Notif::EmailContactMethod; use NOCpulse::Notif::SimpleEmailContactMethod; -use NOCpulse::Notif::PhoneContactMethod; use NOCpulse::Notif::ContactGroup; use NOCpulse::Notif::BroadcastStrategy; use NOCpulse::Notif::EscalateStrategy; @@ -95,10 +94,6 @@ sub buildContactMethods { # email $method = new NOCpulse::Notif::EmailContactMethod; $method->email($hashptr->{'email_address'}); - } elsif ($type == 3) { - $method = new NOCpulse::Notif::PhoneContactMethod; - - # phone }
if ($method) { diff --git a/monitoring/NPalert/PhoneContactMethod.pm b/monitoring/NPalert/PhoneContactMethod.pm deleted file mode 100644 index 982a28e..0000000 --- a/monitoring/NPalert/PhoneContactMethod.pm +++ /dev/null @@ -1,68 +0,0 @@ -package NOCpulse::Notif::PhoneContactMethod; - -@ISA = qw(NOCpulse::Notif::ContactMethod); - -use strict; -use NOCpulse::Notif::ContactMethod; - -############# -sub deliver { -############# - return undef -} - -1; - - -__END__ - - -=head1 NAME - -NOCpulse::Notif::Phone - OBSOLETE. A ContactMethod that delivers its alert notification via voice phone. - -=head1 DESCRIPTION - -THIS CLASS IS OBSOLETE. It serves as a placeholder for future additions to the system. - -=head1 CLASS METHODS - -=over 4 - -=item new ( [%args] ) - -OBSOLETE. Create a new object with the supplied arguments, if any. - -=back - -=head1 METHODS - -=over 4 - -=item deliver ( ) - -OBSOLETE. Return a command line string which when executed will delivery the notification to this destination. - -=back - -=head1 BUGS - -No known bugs; however, this class is deemed OBSOLETE and is void of behavior. - -=head1 AUTHOR - -Karen Jacqmin-Adams kja@redhat.com - -Last update: $Date: 2004-11-18 17:13:13 $ - -=head1 SEE ALSO - -BNOCpulse::Notif::ContactMethod -BNOCpulse::Notif::EmailContactMethod -BNOCpulse::Notif::PagerContactMethod -BNOCpulse::Notif::Alert -BNOCpulse::Notif::Schedule -BNOCpulse::Notif::MessageFormat -B<notifier> - -=cut diff --git a/monitoring/NPalert/test/TODO2 b/monitoring/NPalert/test/TODO2 index cb4618b..6b17f97 100644 --- a/monitoring/NPalert/test/TODO2 +++ b/monitoring/NPalert/test/TODO2 @@ -143,9 +143,6 @@ sub buildSchedules { PagerContactMethod.pm sub deliver {
--PhoneContactMethod.pm --sub deliver { - #Redirect.pm #sub redirect { #sub matches { diff --git a/monitoring/NPalert/test/TestPhoneContactMethod.pm b/monitoring/NPalert/test/TestPhoneContactMethod.pm deleted file mode 100644 index 21a5ab8..0000000 --- a/monitoring/NPalert/test/TestPhoneContactMethod.pm +++ /dev/null @@ -1,32 +0,0 @@ -package test::TestPhoneContactMethod; - -use strict; - -use base qw(Test::Unit::TestCase); - -use NOCpulse::Notif::EmailContactMethod; -use NOCpulse::Notif::Alert; - -my $MODULE = 'NOCpulse::Notif::EmailContactMethod'; - -my $CONFIG=NOCpulse::Config->new; -my $server = $CONFIG->get('mail', 'mx'); - - -$| = 1; - -###################### -sub test_constructor { -###################### - my $self = shift; - my $obj = $MODULE->new(); - - # Make sure creation succeeded - $self->assert(defined($obj), "Couldn't create $MODULE object: $@"); - - # Make sure we got the right type of object - $self->assert(qr/$MODULE/, "$obj"); - -} - -1;
commit f8e36feb1850efcd8dd6058306436ae5f26a5b20 Author: Miroslav Suchý msuchy@redhat.com Date: Wed Feb 1 14:58:27 2012 +0100
rip off SNMP notification method
diff --git a/monitoring/NPalert/AlertDB.pm b/monitoring/NPalert/AlertDB.pm index fadf552..4394887 100644 --- a/monitoring/NPalert/AlertDB.pm +++ b/monitoring/NPalert/AlertDB.pm @@ -208,23 +208,6 @@ sub init_statements { );
$self->dbprepare( - 'create_snmp_alert', - "INSERT INTO SNMP_ALERT ( - RECID, SENDER_CLUSTER_ID, DEST_IP, - DEST_PORT, DATE_GENERATED, DATE_SUBMITTED, - COMMAND_NAME, NOTIF_TYPE, OP_CENTER, - NOTIF_URL, OS_NAME, MESSAGE, - PROBE_ID, HOST_IP, SEVERITY, - COMMAND_ID, PROBE_CLASS, HOST_NAME) - SELECT SNMP_ALERT_RECID_SEQ.nextval, ?, ?, - ?, TO_DATE(?, 'MM-DD-YYYY HH24:MI:SS'), TO_DATE(?, 'MM-DD-YYYY HH24:MI:SS'), - ?, ?, ?, - ?, ?, ?, - ?, ?, ?, - ?, ?, ? - FROM dual" - ); - $self->dbprepare( 'select_next_redirect_recid', "select REDIRECTS_RECID_SEQ.nextval from DUAL" @@ -411,8 +394,6 @@ Create a new redirect criterion record with the specified bindvars.
Create a new email address destination for a redirect.
-- create_snmp_alert (SENDER_CLUSTER_ID, DEST_IP, DEST_PORT, DATE_GENERATED, DATE_SUBMITTED, COMMAND_NAME, NOTIF_TYPE, OP_CENTER, NOTIF_URL, OS_NAME, MESSAGE, PROBE_ID, HOST_IP, SEVERITY, COMMAND_ID, PROBE_CLASS, HOST_NAME ) - Create an snmp type alert with the specified bindvars.
- delete_redirect (RECID) diff --git a/monitoring/NPalert/ContactMethod.pm b/monitoring/NPalert/ContactMethod.pm index 6b62092..ffe4cea 100644 --- a/monitoring/NPalert/ContactMethod.pm +++ b/monitoring/NPalert/ContactMethod.pm @@ -162,7 +162,6 @@ Last update: $Date: 2005-02-10 22:45:14 $ BNOCpulse::Notif::Destination BNOCpulse::Notif::EmailContactMethod BNOCpulse::Notif::PagerContactMethod -BNOCpulse::Notif::SNMPContactMethod BNOCpulse::Notif::ContactGroup BNOCpulse::Notif::Alert BNOCpulse::Notif::Escalator diff --git a/monitoring/NPalert/NotifIniInterface.pm b/monitoring/NPalert/NotifIniInterface.pm index 85fd7e3..7bac23d 100644 --- a/monitoring/NPalert/NotifIniInterface.pm +++ b/monitoring/NPalert/NotifIniInterface.pm @@ -13,7 +13,6 @@ use NOCpulse::Notif::PagerContactMethod; use NOCpulse::Notif::EmailContactMethod; use NOCpulse::Notif::SimpleEmailContactMethod; use NOCpulse::Notif::PhoneContactMethod; -use NOCpulse::Notif::SNMPContactMethod; use NOCpulse::Notif::ContactGroup; use NOCpulse::Notif::BroadcastStrategy; use NOCpulse::Notif::EscalateStrategy; @@ -100,12 +99,6 @@ sub buildContactMethods { $method = new NOCpulse::Notif::PhoneContactMethod;
# phone - } elsif ($type == 5) { - $method = new NOCpulse::Notif::SNMPContactMethod; - $method->ip($hashptr->{'snmp_host'}); - $method->port($hashptr->{'snmp_port'}); - - # snmp }
if ($method) { diff --git a/monitoring/NPalert/NotificationDB.pm b/monitoring/NPalert/NotificationDB.pm index 633ddb1..aaa2be7 100644 --- a/monitoring/NPalert/NotificationDB.pm +++ b/monitoring/NPalert/NotificationDB.pm @@ -104,12 +104,6 @@ sub create_redirect_method_target { shift->_create('RHN_REDIRECT_METHOD_TARGETS', @_); }
-# Records requiring sequence -sub create_snmp_alert { - shift->_create_with_seq('RECID', 'RHN_SNMP_ALERT_RECID_SEQ', 'SNMP_ALERT', - @_); -} - sub create_current_alert { shift->_create_with_seq('RECID', 'RHN_CURRENT_ALERTS_RECID_SEQ', 'RHN_RHN_CURRENT_ALERTS', @_); diff --git a/monitoring/NPalert/SNMPContactMethod.pm b/monitoring/NPalert/SNMPContactMethod.pm deleted file mode 100644 index 2315c5f..0000000 --- a/monitoring/NPalert/SNMPContactMethod.pm +++ /dev/null @@ -1,220 +0,0 @@ -package NOCpulse::Notif::SNMPContactMethod; - -@ISA = qw(NOCpulse::Notif::ContactMethod); - -use strict; -use Class::MethodMaker - new_hash_init => 'new', - get_set => [ qw ( ip port) ]; - -use NOCpulse::Notif::ContactMethod; -use Date::Format; -use NOCpulse::Notif::AlertDB; - -use NOCpulse::Log::Logger; -my $Log = NOCpulse::Log::Logger->new(__PACKAGE__); - -use NOCpulse::Config; - -my $np_cfg = new NOCpulse::Config; -my $snmp_url = $np_cfg->get('notification','snmp_notif_url'); - -use constant DEF_UNIX_DATE_FMT => '%m-%d-%Y %H:%M:%S'; - - -############# -sub deliver { -############# - my ($self,$alert,$db,$smtp)=@_; - - my($string,$sat_cluster_id)=split(///,$alert->snmpPort); - my($dest_ip,$dest_port)=split(/:/,$string); - - my $record = { -# RECID (COMPLETED BY CREATE CALL) - SENDER_CLUSTER_ID => $alert->clusterId, - DEST_IP => $self->ip, - DEST_PORT => $self->port, - DATE_GENERATED => $alert->time, - DATE_SUBMITTED => $alert->current_time, - COMMAND_NAME => $alert->commandLongName, -# NOTIF_TYPE (DERIVED LATER) - OP_CENTER => $alert->physicalLocationName, -# NOTIF_URL => (DERIVED LATER) - OS_NAME => $alert->osName, - MESSAGE => $alert->message, - PROBE_ID => $alert->probeId, - HOST_IP => $alert->hostAddress, -# SEVERITY (DERIVED LATER) - COMMAND_ID => $alert->checkCommand, -# PROBE_CLASS (DERIVED LATER) - HOST_NAME => $alert->hostName, -# SUPPORT_CENTER (LEFT NULL) - SEND_ID => $alert->send_id - }; - - #The following code has been swiped from MessageQueue/dequeue and modified - #to suit the needs of notification - # BEGIN 'THEFT' - - # This should be constructed somehow -- waiting for UI guys. - $record->{'notif_url'}=sprintf("%s?function=host&id=%s", - $snmp_url,$alert->hostProbeId); - - # For OK messages, set notifType = 2 (clear alert). - # For others, set notifType = 1 (alert), and set notifSeverity - # to 1 for UNKNOWN, 3 for WARN and 5 for CRITICAL. - - if ( ( $alert->state eq 'WARN') or - ( $alert->state eq 'WARNING' ) ) { - - $record->{'NOTIF_TYPE'} = 1; - $record->{'SEVERITY'} = 3; - - } elsif ($alert->servicestate eq 'CRITICAL') { - - $record->{'NOTIF_TYPE'} = 1; - $record->{'SEVERITY'} = 5; - - } elsif ($alert->servicestate eq 'OK') { - - $record->{'NOTIF_TYPE'} = 2; - $record->{'SEVERITY'} = 0; - - } else { - - # UNKNOWN state (or unknown state :) - $record->{'NOTIF_TYPE'} = 1; - $record->{'SEVERITY'} = 1; - - } - - # Set notifProbeClass from probeGroupName. - - # For probe classification - my %class_map = ( - # 'host' class -- host monitoring - 1 => [qw(logagent satellite storage tools unix windows)], - - # 'net' class -- network monitoring - 2 => [qw(netservice networking)], - - # Everything else is application monitoring (default, so no list) - 3 => [], - ); - - my $class; - my $probegroup = $alert->probeGroupName; - - $record->{'PROBE_CLASS'} = 3; # Default to app monitoring - foreach $class (keys %class_map) { - if (grep(/$probegroup/, @{$class_map{$class}})) { - $record->{'PROBE_CLASS'} = $class; - last; - } - } - # END 'THEFT' - - - $Log->log(3,"storing SNMP record in the database\n"); - - my ($errcode,$errstring)=$db->dbexecute('create_snmp_alert', - $record->{SENDER_CLUSTER_ID}, - $record->{DEST_IP}, - $record->{DEST_PORT}, - time2str(DEF_UNIX_DATE_FMT,$record->{DATE_GENERATED}), - time2str(DEF_UNIX_DATE_FMT,$record->{DATE_SUBMITTED}), - $record->{COMMAND_NAME}, - $record->{NOTIF_TYPE}, - $record->{OP_CENTER}, - $record->{NOTIF_URL}, - $record->{OS_NAME}, - $record->{MESSAGE}, - $record->{PROBE_ID}, - $record->{HOST_IP}, - $record->{SEVERITY}, - $record->{COMMAND_ID}, - $record->{PROBE_CLASS}, - $record->{HOST_NAME}); - - if ($errcode) { - $Log->log(1,"SMTP message commit error $errcode: $errstring\n"); - } else { - ($errcode)=$db->commit; - $Log->log(1,"Unable to commit SMTP message") if $errcode; - } - return $errcode; -} - -1; - - -=head1 NAME - -NOCpulse::Notif::SNMPContactMethod - A ContactMethod that delivers its alert notification via SNMP trap. - -=head1 SYNOPSIS - -# Create a new snmp contact method -$method=NOCpulse::Notif::SNMPContactMethod->new( - 'ip' => 'nowhere.nocpulse.com', - 'port' => 5050, - 'schedule' => $schedule, - 'message_format' => $message_format ); - -# Create a new strategy for this alert -$strategy=$method->new_strategy_for_alert->($alert); - -# Create the command that will send a specified alert to this destination -$cmd=$method->send($alert); - -=head1 DESCRIPTION - -The C<SNMPContactMethod> object is a type of ContactMethod that sends notifications by sending an SNMP trap. A record is queued in the database for later delivery. - -=head1 CLASS METHODS - -=over 4 - -=item new ( [%args] ) - -Create a new object with the supplied arguments, if any. - -=back - -=head1 METHODS - -=over 4 - -=item deliver ( $alert, $db, $smtp ) - -Launch a send to this contact method. - -=item ip ( [$ip] ) - -Get or set the ip to use for the snmp trap. - -=item port ( [$port] ) - -Get or set the port to use for the snmp trap. - -=back - -=head1 BUGS - -No known bugs. - -=head1 AUTHOR - -Karen Jacqmin-Adams kja@redhat.com - -Last update: $Date: 2004-11-18 17:13:13 $ - -=head1 SEE ALSO - -BNOCpulse::Notif::ContactMethod -BNOCpulse::Notif::Alert -BNOCpulse::Notif::Schedule -B<notifier> - -=cut diff --git a/monitoring/NPalert/Send.pm b/monitoring/NPalert/Send.pm index d72209a..a2a80c5 100644 --- a/monitoring/NPalert/Send.pm +++ b/monitoring/NPalert/Send.pm @@ -10,7 +10,6 @@ use Class::MethodMaker use Date::Format; use NOCpulse::Notif::ContactMethod; use NOCpulse::Notif::PagerContactMethod; -use NOCpulse::Notif::SNMPContactMethod; use NOCpulse::Notif::SendInfo; use NOCpulse::Log::Logger; my $Log = NOCpulse::Log::Logger->new(__PACKAGE__); diff --git a/monitoring/NPalert/test/TestAlertDB.pm b/monitoring/NPalert/test/TestAlertDB.pm index 6d3e3f4..e74adbf 100644 --- a/monitoring/NPalert/test/TestAlertDB.pm +++ b/monitoring/NPalert/test/TestAlertDB.pm @@ -81,20 +81,6 @@ sub test_alert { $self->assert($err==0,$err); }
-############################ -sub test_create_snmp_alert { -############################ - my $self=shift; - my ($err)=$self->{'blah'}->dbexecute('create_snmp_alert',10068, 'dave.pc.nocpulse.net', - 5050, '10-09-2002 20:46:23', '10-09-2002 20:46:23', - 'Disk Space', 1, 'NOCpulse Lab', 'https://command.nocpulse.com/ocenter/?function=host&id=19231', - 'Spacewalk','message: Filesystem /dev/hda2: Filesystem pct used 35% (above critical threshold of 20%); Space available 1,115 MB; Space used 591 MB - Notification #1413 for Filesystem pct used', - 20080, '192.168.0.234',1, - 17, 1, 'VMWare4'); - $self->assert($err==0,$err); -} - ####################### sub test_redirect_seq { ####################### diff --git a/monitoring/NPalert/test/TestNotificationDB.pm b/monitoring/NPalert/test/TestNotificationDB.pm index bb8ee53..a4d8f8e 100644 --- a/monitoring/NPalert/test/TestNotificationDB.pm +++ b/monitoring/NPalert/test/TestNotificationDB.pm @@ -87,44 +87,6 @@ sub test__init_details { $self->assert($value eq 'EXPIRATION', 'dates details (redirects)'); } ## end sub test__init_details
-################## -sub x_test__create { -################## - my $self = shift; - my $records = - $self->{'blah'} - ->execute('select snmp_alert_recid_seq.nextval as recid from dual', - 'dual', FETCH_ARRAYREF); - my $recid = $records->[0]->{'RECID'}; - $Log->log(9, "\n\nrecid is $recid\n\n"); - my $record = { - RECID => $recid, - SENDER_CLUSTER_ID => 10068, - DEST_IP => 'davepc.nocpulse.net', - DEST_PORT => 5050, - DATE_GENERATED => time(), - DATE_SUBMITTED => 'sysdate', - COMMAND_NAME => 'Disk Space', - NOTIF_TYPE => '', - OP_CENTER => 'NOCpulse Lab', - NOTIF_URL => '', - OS_NAME => 'Spacewalk', - MESSAGE => 'blah diddy gorp', - PROBE_ID => 20080, - HOST_IP => '192.168.0.234', - SEVERITY => 5, - COMMAND_ID => 17, - PROBE_CLASS => 1, - HOST_NAME => 'VMWare4' - }; - $self->{'blah'}->create_snmp_alert(%$record); - - # Can't query an active table - # my $result=$self->{'blah'}->select_snmp_alert(RECID => $recid); - # $self->assert(defined($result),'got something back'); - # $self->assert($result->{'DEST_PORT'} == 5050,'is the correct value'); -} ## end sub x_test__create - ######################## sub test__selectphrase { ######################## diff --git a/schema/spacewalk/oracle/triggers/rhn_contact_methods.sql b/schema/spacewalk/oracle/triggers/rhn_contact_methods.sql index 7dc3869..5bf5bb8 100644 --- a/schema/spacewalk/oracle/triggers/rhn_contact_methods.sql +++ b/schema/spacewalk/oracle/triggers/rhn_contact_methods.sql @@ -47,17 +47,6 @@ begin end if; end if;
- if :new.method_type_id = 5 - then - - --- the all sntp fields be not null - if (:new.snmp_host is null or - :new.snmp_port is null) - then - raise missing_data; - end if; - end if; - exception when missing_data then raise_application_error (-20012,msg); diff --git a/schema/spacewalk/postgres/triggers/rhn_contact_methods.sql b/schema/spacewalk/postgres/triggers/rhn_contact_methods.sql index 4c52424..9e6ed46 100644 --- a/schema/spacewalk/postgres/triggers/rhn_contact_methods.sql +++ b/schema/spacewalk/postgres/triggers/rhn_contact_methods.sql @@ -1,5 +1,4 @@ --- oracle equivalent source sha1 0f23a9637e54cf0141b6629baa286d23ed79f849 --- retrieved from ./1241132947/9984c41fb98d15becf3c29432c19cd7a266dece4/schema/spacewalk/oracle/triggers/rhn_contact_methods.sql +-- oracle equivalent source sha1 e58bd36819c4101d8efbe3b8aa6b77979c277b91 create or replace function rhn_cmeth_val_trig_fun() returns trigger as $$ begin @@ -19,14 +18,6 @@ begin end if; end if;
- if new.method_type_id = 5 then - - --- the all sntp fields be not null - if (new.snmp_host is null or new.snmp_port is null) then - raise exception 'missing or invalid data for contact_methods table'; --missing_data; - end if; - end if; - return new; end; $$ language plpgsql; diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.6-to-spacewalk-schema-1.7/011-rhn_contact_methods.sql.oracle b/schema/spacewalk/upgrade/spacewalk-schema-1.6-to-spacewalk-schema-1.7/011-rhn_contact_methods.sql.oracle new file mode 100644 index 0000000..59eb704 --- /dev/null +++ b/schema/spacewalk/upgrade/spacewalk-schema-1.6-to-spacewalk-schema-1.7/011-rhn_contact_methods.sql.oracle @@ -0,0 +1,57 @@ + +-- +-- Copyright (c) 2008 Red Hat, Inc. +-- +-- This software is licensed to you under the GNU General Public License, +-- version 2 (GPLv2). There is NO WARRANTY for this software, express or +-- implied, including the implied warranties of MERCHANTABILITY or FITNESS +-- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 +-- along with this software; if not, see +-- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. +-- +-- Red Hat trademarks are not licensed under GPLv2. No permission is +-- granted to use or replicate Red Hat trademarks that are incorporated +-- in this software or its documentation. +-- + +create or replace trigger +rhn_cmeth_val_trig +before insert or update on rhn_contact_methods +referencing new as new old as old +for each row +declare + msg varchar2(200); + missing_data exception; +begin + msg :='missing or invalid data for contact_methods table'; + + if :new.method_type_id = 1 + then + + --- pager fields pager_email,pager_split_long_messages should be not null + if ( + :new.pager_email is null or + :new.pager_split_long_messages is null ) + then + raise missing_data; + end if; + end if; + + if :new.method_type_id = 2 + then + + --- the all email fields but email_reply_to should be not null + if :new.email_address is null + then + raise missing_data; + end if; + end if; + + exception + when missing_data then + raise_application_error (-20012,msg); + when others then + raise; +end; +/ +show errors diff --git a/schema/spacewalk/upgrade/spacewalk-schema-1.6-to-spacewalk-schema-1.7/011-rhn_contact_methods.sql.postgresql b/schema/spacewalk/upgrade/spacewalk-schema-1.6-to-spacewalk-schema-1.7/011-rhn_contact_methods.sql.postgresql new file mode 100644 index 0000000..e7d9712 --- /dev/null +++ b/schema/spacewalk/upgrade/spacewalk-schema-1.6-to-spacewalk-schema-1.7/011-rhn_contact_methods.sql.postgresql @@ -0,0 +1,32 @@ +-- oracle equivalent source sha1 e58bd36819c4101d8efbe3b8aa6b77979c277b91 +create or replace function rhn_cmeth_val_trig_fun() returns trigger as +$$ +begin + if new.method_type_id = 1 then + + --- pager fields pager_email,pager_split_long_messages should be not null + if (new.pager_email is null or new.pager_split_long_messages is null ) then + raise exception 'missing or invalid data for contact_methods table'; --missing_data; + end if; + end if; + + if new.method_type_id = 2 then + + --- the all email fields but email_reply_to should be not null + if new.email_address is null then + raise exception 'missing or invalid data for contact_methods table'; --missing_data; + end if; + end if; + + return new; +end; +$$ language plpgsql; + + +drop trigger if exists rhn_cmeth_val_trig on rhn_contact_methods; + +create trigger +rhn_cmeth_val_trig +before insert or update on rhn_contact_methods +for each row +execute procedure rhn_cmeth_val_trig_fun();