# # Copyright (c) 2011 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Network ComponentState Module ## @author rawat@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::HyperV::Network =head1 DESCRIPTION C is a derived class of L. It represents the state of Network on the given HyperV Server. A related class isL, access to the Network managed object reference of an HyperV Server. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Network(Virtual Switch) element are the attributes of the Network ComponentState. =over =item C<< other_config >> =item C<< blobs >> =item C<< uuid >> =item C<< bridge >> =item C<< tags >> =item C<< MTU >> =item C<< VIFs >> =item C<< PIFs >> =item C<< name >> =item C<< name_description >> =item C<< allowed_operations >> =item C<< current_operations >> =back =cut package NACL::CS::HyperV::Network; use strict; use warnings; use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Data::Dumper; use Params::Validate qw (validate); use NACL::ComponentUtils qw (_dump_one); use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::HyperV'; use Class::MethodMaker [ scalar => "uuid", scalar => "name", scalar => "bridge", scalar => "MTU", scalar => "name_description", array => "VIFs", array => "tags", array => "PIFs", array => "allowed_operations", hash => "current_operations", hash => "other_config", hash => "blobs", ]; =head1 METHODS =head2 fetch my $state = NACL::CS::HyperV::Network->fetch(command_interface=>$ci,...); my @states = NACL::CS::HyperV::Network->fetch(command_interface=>$ci,...); see L. =cut sub fetch { $Log->enter(); my ($pkg,@args) = @_; my @state_objs = $pkg->SUPER::fetch( @args, choices => [ { method => "_fetch_network_info_xen", interface => 'XAPI', set => 'Xen' }, ], exception_text => 'No matching Network(Virtual Switch) found' ); $Log->exit(); return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_network_info_xen { $Log->enter(); my ($pkg, @args) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $filter = $opts{filter}; my $requested_fields = $opts{requested_fields}; my $command_interface = $opts{command_interface}; my $deleted_filter = $pkg->_remove_relational_regex_filters( filter => $filter, requested_fields => $requested_fields ); my @state_objs; my @networks; if ($filter->{name}) { my $network_ref = $command_interface->_get_network_ref( name => $filter->{name}, apiset => $apiset, ); push(@networks, $network_ref); } else { @networks = @{$apiset->simple_request("network.get_all")->get_parsed_output()}; } foreach my $network ( @networks ) { my $network_record; $pkg->get_ref(ref => $network, ref_of => "network", apiset => $apiset, record => \$network_record); if (! defined($network_record)){ $Log->exit(); return; } my $obj = $pkg->new( command_interface => $opts{command_interface}, name => $network_record->{name_label}, ); $obj->_set_fields( row => $network_record ); push @state_objs, $obj; } $Log->exit(); return @state_objs; } ## end sub _fetch_vm_info 1;