# # Copyright (c) 2014 NetApp, Inc., All Rights Reserved. # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @pod here package NACL::ServiceAPI::Configurator; use strict; use warnings; use parent qw(NACL::ServiceAPI); use Params::Validate qw(validate_with BOOLEAN HASHREF OBJECT ARRAYREF SCALAR UNDEF); use NATE::BaseException qw(:try); use NACL::AppBuilder::Configurator::Configurator; #for now, not global...no state #our $configurator = NACL::AppBuilder::Configurator::Configurator->new(); =head1 NAME NACL::ServiceAPI::Configurator =head1 SYNOPSIS use NACL::ServiceAPI::Configurator; =head1 DESCRIPTION A C mostly wraps the L> object and provides a service interface =head1 METHODS =head2 new This is the constructor method that finds running C services and gets prepared to talk to them. =over =item Synopsis use NACL::ServiceAPI::Configurator; my $api = NACL::ServiceAPI::Configurator->new(); =back =head2 configure_using_preset() Configure testbed using a preset This is mostly a passthru to NACL::AppBuilder::Configurator. Please see documentation for that class for more information. =over =item Options =item C<< preset => $preset >> This is the name of the preset that the configurator will use for creating the configuration requested. Internally the name is mapped to an xml file that is passed to EnGenX. For now, preset is one of: workflow, dpsas-sbot Alternately the path to an xml can be passed for a custom file. =back =cut sub configure_using_preset { my $self = shift; #move to service side when/if it works... my %opts = validate_with( params => \@_, spec => { 'preset' => { 'type' => SCALAR }, 'target' => { 'type' => HASHREF }, }, allow_extra => 1, ); #subtests don't work in a service, so just fake it and call it #in the client...for now... my $configurator = NACL::AppBuilder::Configurator::Configurator->new(); my $resources = $configurator->configure_using_preset(@_); $self->store_engenx_resourcelist( resourcelist => $resources ); return $resources; #$self->call_server_method( method => 'configure_using_preset', %opts); } =head2 store_engenx_resourcelist() Stores the NACL::AppBuilder::EnGenX::ResourceList object returned by an EnGenX->setup() call. This is done in configure_using_preset automatically. =over =item Options =item C<< resourcelist => $resource_list >> The NACL::AppBuilder::EnGenX::ResourceList object to store =back =cut sub store_engenx_resourcelist { my $self = shift; my %opts = validate_with( params => \@_, spec => { 'resourcelist' => { 'type' => HASHREF }, }, ); my $engenx = $opts{resourcelist}; return $self->store(name => '_resourcelist', value => $engenx); } =head2 retrieve_engenx_resourcelist() Retrieves the NACL::AppBuilder::EnGenX::ResourceList stored on the service when setup was called. This is a blocking call to the service. =cut sub retrieve_engenx_resourcelist { my $self = shift; my $engenx = $self->retrieve(name => '_resourcelist', request_timeout => -1); return $engenx; } 1; __END__ =head1 SEE ALSO This is a derived class of L>. Please see the documentation for more details. =head1 AUTHOR/MAINTAINER NACL Development (dl-nacl-dev@netapp.com) =cut