[vhffs-dev] [2052] added Vhffs::Robots::DNS (yeah, this is all dummy methods), merged dns_create.pl and dns_delete.pl to dns.pl

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2052
Author:   gradator
Date:     2012-02-25 13:22:28 +0100 (Sat, 25 Feb 2012)
Log Message:
-----------
added Vhffs::Robots::DNS (yeah, this is all dummy methods), merged dns_create.pl and dns_delete.pl to dns.pl

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Makefile.am
    trunk/vhffs-robots/Makefile.am

Added Paths:
-----------
    trunk/vhffs-api/src/Vhffs/Robots/DNS.pm
    trunk/vhffs-robots/src/dns.pl

Removed Paths:
-------------
    trunk/vhffs-robots/src/dns_create.pl
    trunk/vhffs-robots/src/dns_delete.pl

Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am	2012-02-25 11:52:19 UTC (rev 2051)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am	2012-02-25 12:22:28 UTC (rev 2052)
@@ -51,6 +51,7 @@
 	Panel/Cron.pm \
 	Robots/Bazaar.pm \
 	Robots/Cvs.pm \
+	Robots/DNS.pm \
 	Robots/Group.pm \
 	Robots/Mail.pm \
 	Robots/Mailing.pm \

Added: trunk/vhffs-api/src/Vhffs/Robots/DNS.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/DNS.pm	                        (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Robots/DNS.pm	2012-02-25 12:22:28 UTC (rev 2052)
@@ -0,0 +1,75 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in
+#   the documentation and/or other materials provided with the
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+#   may be used to endorse or promote products derived from this
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+use Vhffs::Constants;
+use Vhffs::Functions;
+use Vhffs::Robots;
+use Vhffs::Services::DNS;
+
+package Vhffs::Robots::DNS;
+
+sub create {
+	my $dns = shift;
+	return undef unless defined $dns and $dns->get_status == Vhffs::Constants::WAITING_FOR_CREATION;
+
+	my $vhffs = $dns->get_main;
+
+	$dns->set_status( Vhffs::Constants::ACTIVATED );
+	$dns->commit;
+	Vhffs::Robots::vhffs_log( $vhffs, 'Created DNS '.$dns->get_domain );
+}
+
+sub delete {
+	my $dns = shift;
+	return undef unless defined $dns and $dns->get_status == Vhffs::Constants::WAITING_FOR_DELETION;
+
+	my $vhffs = $dns->get_main;
+
+	if( $dns->delete ) {
+		Vhffs::Robots::vhffs_log( $vhffs, 'Deleted DNS '.$dns->get_domain );
+	} else {
+		Vhffs::Robots::vhffs_log( $vhffs, 'An error occured while deleting DNS '.$dns->get_domain );
+		$dns->set_status( Vhffs::Constants::DELETION_ERROR );
+		$dns->commit();
+	}
+}
+
+sub modify {
+	my $dns = shift;
+	return undef unless defined $dns and $dns->get_status == Vhffs::Constants::WAITING_FOR_MODIFICATION;
+	$dns->set_status( Vhffs::Constants::ACTIVATED );
+	$dns->commit;
+}
+
+1;

Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am	2012-02-25 11:52:19 UTC (rev 2051)
+++ trunk/vhffs-robots/Makefile.am	2012-02-25 12:22:28 UTC (rev 2052)
@@ -21,8 +21,7 @@
 	misc/git_post-receive
 
 dist_bots_SCRIPTS = \
-	src/dns_create.pl \
-	src/dns_delete.pl \
+	src/dns.pl \
 	src/group_create.pl \
 	src/group_delete.pl \
 	src/group_quota.pl \

Copied: trunk/vhffs-robots/src/dns.pl (from rev 2043, trunk/vhffs-robots/src/dns_create.pl)
===================================================================
--- trunk/vhffs-robots/src/dns.pl	                        (rev 0)
+++ trunk/vhffs-robots/src/dns.pl	2012-02-25 12:22:28 UTC (rev 2052)
@@ -0,0 +1,60 @@
+#!%PERL%
+
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without 
+# modification, are permitted provided that the following conditions 
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright 
+#   notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in 
+#   the documentation and/or other materials provided with the 
+#   distribution.
+#3. Neither the name of vhffs nor the names of its contributors 
+#   may be used to endorse or promote products derived from this 
+#   software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+# POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+use utf8;
+
+use lib '%VHFFS_LIB_DIR%';
+use Vhffs::Robots::DNS;
+
+my $vhffs = init Vhffs::Main;
+exit 1 unless defined $vhffs;
+
+Vhffs::Robots::lock( $vhffs, 'dns' );
+
+my $dnss = Vhffs::Services::DNS::getall( $vhffs, Vhffs::Constants::WAITING_FOR_CREATION );
+foreach ( @{$dnss} ) {
+	Vhffs::Robots::DNS::create( $_ );
+}
+
+$dnss = Vhffs::Services::DNS::getall( $vhffs, Vhffs::Constants::WAITING_FOR_DELETION );
+foreach ( @{$dnss} ) {
+	Vhffs::Robots::DNS::delete( $_ );
+}
+
+$dnss = Vhffs::Services::DNS::getall( $vhffs, Vhffs::Constants::WAITING_FOR_MODIFICATION );
+foreach ( @{$dnss} ) {
+	Vhffs::Robots::DNS::modify( $_ );
+}
+
+Vhffs::Robots::unlock( $vhffs, 'dns' );
+exit 0;

Deleted: trunk/vhffs-robots/src/dns_create.pl
===================================================================
--- trunk/vhffs-robots/src/dns_create.pl	2012-02-25 11:52:19 UTC (rev 2051)
+++ trunk/vhffs-robots/src/dns_create.pl	2012-02-25 12:22:28 UTC (rev 2052)
@@ -1,71 +0,0 @@
-#!%PERL%
-
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-use lib '%VHFFS_LIB_DIR%';
-use utf8;
-use Vhffs::Services::DNS;
-use Vhffs::Robots;
-use Vhffs::Main;
-
-use strict;
-
-#Init VHFFS subsystem
-my $vhffs = init Vhffs::Main;
-
-
-#Lock if specified in the config-file
-Vhffs::Robots::lock( $vhffs , "dns" );
-
-#Get all DNS objects to create
-my $tocreate = Vhffs::Services::DNS::getall( $vhffs , Vhffs::Constants::WAITING_FOR_CREATION );
-my $dns;
-
-if( defined $tocreate )
-{
-	foreach $dns ( @{$tocreate} )
-	{
-        $dns->set_status( Vhffs::Constants::ACTIVATED );
-        if( $dns->commit > 0 )
-		{
-			Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Create domain %s" , $dns->get_domain  ) );
-		}
-		else
-		{
-			Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Cannot create domain %s" , $dns->get_domain  ) );
-		}
-
-	}
-}
-
-Vhffs::Robots::unlock( $vhffs , "dns" );
-
-exit 0;

Deleted: trunk/vhffs-robots/src/dns_delete.pl
===================================================================
--- trunk/vhffs-robots/src/dns_delete.pl	2012-02-25 11:52:19 UTC (rev 2051)
+++ trunk/vhffs-robots/src/dns_delete.pl	2012-02-25 12:22:28 UTC (rev 2052)
@@ -1,66 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without 
-# modification, are permitted provided that the following conditions 
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright 
-#   notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-#   notice, this list of conditions and the following disclaimer in 
-#   the documentation and/or other materials provided with the 
-#   distribution.
-#3. Neither the name of vhffs nor the names of its contributors 
-#   may be used to endorse or promote products derived from this 
-#   software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
-# POSSIBILITY OF SUCH DAMAGE.
-
-use lib '%VHFFS_LIB_DIR%';
-use utf8;
-use Vhffs::Robots;
-use Vhffs::Services::DNS;
-use Vhffs::Main;
-
-use strict;
-
-
-my $vhffs = init Vhffs::Main;
-
-Vhffs::Robots::lock( $vhffs , "dns" );
-
-my $dns;
-my $todelete = Vhffs::Services::DNS::getall( $vhffs , Vhffs::Constants::WAITING_FOR_DELETION );
-
-if( defined $todelete )
-{
-	foreach $dns ( @{$todelete} )
-	{
-		if( $dns->delete > 0 )
-		{
-			Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Delete %s", $dns->get_domain ));
-		}
-		else
-		{
-			Vhffs::Robots::vhffs_log( $vhffs, sprintf( "Cannot delete domain name %s", $dns->get_domain ));
-		}
-	}
-}
-
-
-Vhffs::Robots::unlock( $vhffs , "dns" );
-
-exit 0;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/