You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by ar...@apache.org on 2013/08/29 20:42:04 UTC

svn commit: r1518753 - /vcl/trunk/managementnode/lib/VCL/Module.pm

Author: arkurth
Date: Thu Aug 29 18:42:04 2013
New Revision: 1518753

URL: http://svn.apache.org/r1518753
Log:
VCL-720
Added create_datastructure_object subroutine to Module.pm

Modified:
    vcl/trunk/managementnode/lib/VCL/Module.pm

Modified: vcl/trunk/managementnode/lib/VCL/Module.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module.pm?rev=1518753&r1=1518752&r2=1518753&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module.pm Thu Aug 29 18:42:04 2013
@@ -213,6 +213,45 @@ sub new {
 
 #/////////////////////////////////////////////////////////////////////////////
 
+=head2 create_datastructure_object
+
+ Parameters  : $arguments
+ Returns     : VCL::DataStructure object
+ Description : Creates a DataStructure object. The arguments are the same as
+               those passed to the DataStructure constructor.
+
+=cut
+
+sub create_datastructure_object {
+	my $self = shift;
+	unless (ref($self) && $self->isa('VCL::Module')) {
+		notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a function, it must be called as a class method");
+		return;
+	}
+	
+	my $arguments = shift || {};
+	
+	my $data;
+	eval {
+		$data = new VCL::DataStructure($arguments);
+	};
+	
+	if ($EVAL_ERROR) {
+		notify($ERRORS{'WARNING'}, 0, "failed to create DataStructure object, arguments:\n" . format_data($arguments) . "\nerror:\n" . $EVAL_ERROR);
+		return;
+	}
+	elsif (!$data) {
+		notify($ERRORS{'WARNING'}, 0, "failed to create DataStructure object, arguments:\n" . format_data($arguments));
+		return;
+	}
+	else {
+		notify($ERRORS{'DEBUG'}, 0, "created DataStructure object, arguments:\n" . format_data($arguments));
+		return $data;
+	}
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
 =head2 create_os_object
 
  Parameters  : None