Author: arkurth
Date: Thu Mar 30 22:06:59 2017
New Revision: 1789593
URL: http://svn.apache.org/viewvc?rev=1789593&view=rev
Log:
Trivial
Added optional $force argument to VMware.pm::initialize. It normally skips
initialization if the request state is 'test'. (This state is probably only
used by me for development.) I was often changing the line in initialize that
checks if the state is 'test' back and forth when working on VMare and
non-VMware code.
Added check to VMware.pm::api. If the data is undefined, try to call
initialize with the force argument set to one. Now, the VMware module gets
fully initialized from test.pm as long as $self->provisioner->api() is called
once.
Modified:
vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm?rev=1789593&r1=1789592&r2=1789593&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
(original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm Thu
Mar 30 22:06:59 2017
@@ -289,7 +289,9 @@ sub initialize {
return;
}
- return 1 if ($self->data->get_request_state_name() =~ /test/i);
+ my $force = shift;
+
+ return 1 if (!$force && $self->data->get_request_state_name() =~
/test/i);
notify($ERRORS{'DEBUG'}, 0, "initializing " . ref($self) . " object");
# Get a DataStructure object containing data for the VM host computer
@@ -1353,8 +1355,15 @@ sub api {
}
if (!$self->{api}) {
- notify($ERRORS{'WARNING'}, 0, "api object is not defined");
- return;
+ notify($ERRORS{'DEBUG'}, 0, "attempting to initialize");
+ if (!$self->initialize()) {
+ notify($ERRORS{'WARNING'}, 0, "failed to initialize");
+ return;
+ }
+ elsif (!$self->{api}) {
+ notify($ERRORS{'WARNING'}, 0, "api object is not
defined");
+ return;
+ }
}
return $self->{api};