# # Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary NetworkIpspace Component Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com, benjaram@netapp.com ## @status shared ## @pod here =head1 NAME NACL::C::NetworkIpspace =head1 DESCRIPTION C is a derived class of L. It represents access to an ONTAP NetworkIpspace. A related class is L, which represents the past state of an ONTAP NetworkIpspace. =head1 ATTRIBUTES =head2 command_interface See L =head2 ipspace =cut package NACL::C::NetworkIpspace; use strict; use warnings; use NACL::CS::NetworkIpspace; use NACL::ComponentUtils qw (_optional_scalars Dumper); use base 'NACL::C::Component::ONTAP'; use Params::Validate qw(validate validate_with SCALAR ARRAYREF); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::C::Exceptions::NetworkIpspace::BroadcastDomainExists qw(:try); use NACL::C::Exceptions::NetworkIpspace::VserverExists; use NACL::C::Exceptions::NetworkIpspace::NetworkPortsAssigned; use NACL::C::Exceptions::NetworkIpspace::AlreadyExists; use NACL::C::Exceptions::NetworkIpspace::DoesNotExist; use NACL::C::Exceptions::NetworkIpspace::InvalidIPspace; =head1 METHODS =head2 new my $NetworkIpspace = NACL::C::NetworkIpspace->new( command_interface => $ci, 'ipspace' => $ipspace, ); Return a new NetworkIpspace component object with the given attributes. =cut use Class::MethodMaker [scalar => 'ipspace',]; =head2 find my $NetworkIpspace_obj = NACL::C::NetworkIpspace->find(command_interface => $ci, ...); my @NetworkIpspace_objs = NACL::C::NetworkIpspace->find(command_interface => $ci, ...); (Class method) A constructor of sorts, which discovers which elements are present (by interacting with the given command interface). In an array context it creates a component object for each present element and returns them. In a scalar context it creates a component object for just one element. This method is generally not implemented in individual components. The base class (L provides an implementation. See for a more detailed description along with explanation of all the options accepted. Uses a CMode CLI/ZAPI APISet. Uses net_ipspaces_get_iter method for CMode ZAPI. =head2 state my NetworkIpspace_state = $NetworkIpspace_obj->state(); (Instance method) Fetch the current state of the element associated with this component, and return a Component State object corresponding to this component (calling this on NACL::C::NetworkIpspace would return a NACL::CS::NetworkIpspace object) This method is generally not implemented in individual components. The base class (L provides an implementation. See for a more detailed description along with explanation of all the options accepted. Uses a CMode CLI/ZAPI APISet. =cut =head2 delete NACL::C::NetworkIpspace->delete( command_interface => $ci, 'ipspace' => $ipspace, ...); or $NetworkIpspace_obj->delete(...); (Class or instance method) This method is used to delete an IPspace. Uses a CMode CLI/ZAPI APISet. Invokes "net-ipspaces-destroy" API for CMode ZAPI. =over =item Options =over =item C<< command_interface => $command_interface >> (Required for class method, Not Applicable for instance method) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< 'ipspace' => $ipspace >> (Required for class method, Not Applicable for instance method) Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : ipspace =item C<< 'method-timeout' => $time_in_seconds >> (Optional) The default NATE timeout is 60 seconds. If the command might take more time to complete, this option can be used to specify a larger timeout value. The value should be provided in seconds. =item C<< "extended_query" => $string >> (Optional) Applicable for CMode CLI. =item C<< '*' >> This method takes all other options supported by "network ipspace delete" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C This type of exception gets thrown if an attempt is made to delete a ipspace which has a vserver on it. =item C This type of exception gets thrown if an attempt is made to delete a ipspace which has ports assigned to it. =item C This type of exception gets thrown if an attempt is made to delete a ipspace which has a broadcast domain on it. =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub delete { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; $pkg_or_obj->_frontend_log_debug_opts(@args); my %opts = $pkg_or_obj->_common_validate_with( params => \@args, cli_cmd => 'network ipspace delete', ); try { $pkg_or_obj->call_on_apiset( %opts, choices => [ { method => '_delete_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_delete_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], frontend => 'NACL::C::NetworkIpspace::delete', ); } catch NACL::APISet::Exceptions::ResponseException with { my $exception = $_[0]; NACL::C::Exceptions::NetworkIpspace::DoesNotExist ->detect_convert_and_throw(exception => $exception); NACL::C::Exceptions::NetworkIpspace::BroadcastDomainExists ->detect_convert_and_throw(exception => $exception); NACL::C::Exceptions::NetworkIpspace::VserverExists ->detect_convert_and_throw(exception => $exception); NACL::C::Exceptions::NetworkIpspace::NetworkPortsAssigned ->detect_convert_and_throw(exception => $exception); $Log->exit() if $may_exit; $exception->throw(); }; $Log->exit() if $may_exit; } ## end sub delete sub _delete_cmode_cli { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; $pkg_or_obj->_base_backend_cmode_cli(@args, api => 'network_ipspace_delete'); $Log->exit() if $may_exit; } ## end sub _delete_cmode_cli sub _delete_cmode_zapi { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; my $allowed_cmode_options = [ qw( ipspace ) ]; $pkg_or_obj->_base_backend_cmode_zapi(@args, api => 'net_ipspaces_destroy', copy => $allowed_cmode_options, ); $Log->exit() if $may_exit; } ## end sub _delete_cmode_zapi =head2 rename NACL::C::NetworkIpspace->rename( command_interface => $ci, 'ipspace' => $ipspace, ...); or $NetworkIpspace_obj->rename(...); (Class or instance method) This method is used to rename an IPspace. Uses a CMode CLI/ZAPI APISet. Invokes "net-ipspaces-rename" API for CMode ZAPI. =over =item Options =over =item C<< command_interface => $command_interface >> (Required for class method, Not Applicable for instance method) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< 'ipspace' => $ipspace >> (Required for class method, Not Applicable for instance method) Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : ipspace =item C<< 'new-name' => $string >> Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : new-name =item C<< 'method-timeout' => $time_in_seconds >> (Optional) The default NATE timeout is 60 seconds. If the command might take more time to complete, this option can be used to specify a larger timeout value. The value should be provided in seconds. =item C<< "extended_query" => $string >> (Optional) Applicable for CMode CLI. =item C<< '*' >> This method takes all other options supported by "network ipspace rename" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub rename { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; $pkg_or_obj->_frontend_log_debug_opts(@args); my %opts = $pkg_or_obj->_common_validate_with( params => \@args, additional_spec => { _optional_scalars( qw( new-name ) ), }, cli_cmd => 'network ipspace rename', ); $pkg_or_obj->call_on_apiset( %opts, choices => [ { method => '_rename_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_rename_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], frontend => 'NACL::C::NetworkIpspace::rename', ); $pkg_or_obj->ipspace($opts{'new-name'}) if ref($pkg_or_obj); $Log->exit() if $may_exit; } ## end sub rename sub _rename_cmode_cli { $Log->enter() if $may_enter; my ($pkg_or_obj, %opts) = @_; $pkg_or_obj->_base_backend_cmode_cli(%opts, api => 'network_ipspace_rename'); $Log->exit() if $may_exit; } ## end sub _rename_cmode_cli sub _rename_cmode_zapi { $Log->enter() if $may_enter; my ($pkg_or_obj, %opts) = @_; my $allowed_cmode_options = [ qw( new-name ipspace ) ]; $pkg_or_obj->_base_backend_cmode_zapi(%opts, api => 'net_ipspaces_rename', copy => $allowed_cmode_options, ); $Log->exit() if $may_exit; } ## end sub _rename_cmode_zapi =head2 create my $NetworkIpspace_obj = NACL::C::NetworkIpspace->create( command_interface => $ci, 'ipspace' => $ipspace, ...); (Class method) This method is used to create a new IPspace. Uses a CMode CLI/ZAPI APISet. Invokes "net-ipspaces-create" API for CMode ZAPI. =over =item Options =over =item C<< command_interface => $command_interface >> (Required) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< 'ipspace' => $ipspace >> (Required) Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : ipspace =item C<< 'is-private' => $string >> Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : is-private =item C<< 'is-hidden' => $string >> Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : is-hidden =item C<< 'id' => $string >> Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : id =item C<< 'uuid' => $string >> Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : uuid =item C<< 'ports' => [ $port1, $port2, ... ] >> (Arrayref, even if only a single value is to be sent it should specified as an arrayref containing that single value) Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : ports =item C<< 'method-timeout' => $time_in_seconds >> (Optional) The default NATE timeout is 60 seconds. If the command might take more time to complete, this option can be used to specify a larger timeout value. The value should be provided in seconds. =item C<< "extended_query" => $string >> (Optional) Applicable for CMode CLI. =item C<< '*' >> This method takes all other options supported by "network ipspace create" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C This exception is thrown when we attempt to create a Ipspace which already exists. =item C This exception is thrown when we attempt to create a Ipspace with invalid IPspace name. InvalidIPspace could be either IPspace name is already in use by a cluster node, Vserver, or is the name of the local cluster. =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub create { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->_frontend_log_debug_opts(@args); my %opts = $pkg->_common_validate_with( params => \@args, additional_spec => { 'ports' => {type => ARRAYREF, optional => 1}, _optional_scalars( qw( is-private is-hidden id uuid ) ), }, cli_cmd => 'network ipspace create', ); try { $pkg->call_on_apiset( %opts, choices => [ { method => '_create_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_create_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], frontend => 'NACL::C::NetworkIpspace::create', ); } catch NACL::APISet::Exceptions::ResponseException with { my $exception = $_[0]; NACL::C::Exceptions::NetworkIpspace::AlreadyExists ->detect_convert_and_throw(exception => $exception); NACL::C::Exceptions::NetworkIpspace::InvalidIPspace ->detect_convert_and_throw(exception => $exception); $Log->exit() if $may_exit; $exception->throw(); }; $Log->exit() if $may_exit; my $obj = $pkg->new( command_interface => $opts{command_interface}, ipspace => $opts{'ipspace'}, ); return $obj; } ## end sub create sub _create_cmode_cli { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->_base_backend_cmode_cli(@args, api => 'network_ipspace_create'); $Log->exit() if $may_exit; } ## end sub _create_cmode_cli sub _create_cmode_zapi { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; my $allowed_cmode_options = [ qw( ports is-private ipspace is-hidden id uuid ) ]; $pkg_or_obj->_base_backend_cmode_zapi(@args, api => 'net_ipspaces_create', copy => $allowed_cmode_options, ); $Log->exit() if $may_exit; } ## end sub _create_cmode_zapi __PACKAGE__->_load_event_class(); sub _primary_keys_validate_spec { return ('ipspace' => {type => SCALAR},); } 1;