# # Copyright (c) 2011 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VIF ComponentState Module ## @author rawat@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::HyperV::VIF =head1 DESCRIPTION C is a derived class of L. It represents the state of VIF on the given HyperV Server. A related class isL, access to the VIF managed object reference of an HyperV Server. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VIF(Virtual Switch) element are the attributes of the VIF ComponentState. =over =item C<< other_config >> =item C<< network >> =item C<< uuid >> =item C<< MAC_autogenerated >> =item C<< VM >> =item C<< qos_algorithm_params >> =item C<< qos_algorithm_type >> =item C<< metrics >> =item C<< qos_supported_algorithms >> =item C<< status_code >> =item C<< runtime_properties >> =item C<< MAC >> =item C<< device >> =item C<< currently_attached >> =item C<< status_detail >> =item C<< MTU >> =item C<< allowed_operations >> =item C<< current_operations >> =item C<< name >> =back =cut package NACL::CS::HyperV::VIF; 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 => "network", scalar => "MAC_autogenerated", scalar => "MTU", scalar => "VM", scalar => "qos_algorithm_type", scalar => "metrics", scalar => "status_code", scalar => "MAC", scalar => "device", scalar => "currently_attached", scalar => "status_detail", array => "qos_supported_algorithms", array => "allowed_operations", hash => "current_operations", hash => "other_config", hash => "qos_algorithm_params", hash => "runtime_properties", ]; =head1 METHODS =head2 fetch my $state = NACL::CS::HyperV::VIF->fetch(command_interface=>$ci,...); my @states = NACL::CS::HyperV::VIF->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 VIF 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 @vifs; if ($filter->{name}) { push(@vifs, $filter->{name}); } else { @vifs = @{$apiset->simple_request("VIF.get_all")->get_parsed_output()}; } foreach my $vif ( @vifs ) { my $vif_record; $pkg->get_ref(ref => $vif, ref_of => "VIF", apiset => $apiset, record => \$vif_record); if (! defined($vif_record)){ $Log->exit(); return; } my $obj = $pkg->new( command_interface => $opts{command_interface}, name => $vif, ); $obj->_set_fields( row => $vif_record ); push @state_objs, $obj; } $Log->exit(); return @state_objs; } ## end sub _fetch_vm_info 1;