# # Copyright (c) 2001-2011 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # # VMware® End User License Agreement # VMware, Inc. (“VMware”) provides the vSphere Command-Line Interface (vSphere CLI) # and/or vSphere Software Development Kit for Perl (vSphere SDK for Perl) (collectively # the “Software”) to you subject to the following terms and conditions. If you # disagree with any of the following terms, then do not use the Software. # 1. The Software contains a variety of materials, interface definitions, documentation, # sample utility applications and sample code regarding programming interfaces to one or # more VMware products as referenced in such materials (“VMware Products”). This Software # is intended to be used to execute supplied commands and utility applications and to # create scripts that interact with the VMware Products. # 2. Use Rights: Subject to the restrictions below, you may download and make a # reasonable number of copies of the Software contents for your use solely for the purpose # of creating software that communicates with VMware Products (“Developer Software”). For # vSphere SDK for Perl, some code may be designated as “distributable code” and/or # “modifiable code” at http://www.vmware.com/go/vsdkperl-redistribution-info. For vSphere # CLI, some code may be designated as “distributable code” and/ or “modifiable code” at # http://www.vmware.com/go/vcli-redistribution-info. You may use and merge all or portions # of the “distributable code” with your Developer Software. Any merged portion of any # “distributable code” is subject to this Agreement. Additionally, you may modify or create # derivative works of all or portions of the “modifiable code.” You are permitted to # re-distribute the “distributable code” and the modified or derivative works of the # “modifiable code” only as part of your Developer Software for non-commercial or commercial # use. Open source software components provided with the Software are licensed to you under # the terms of the applicable license agreements included with such open source software # components. The open source software licenses can be found in the open_source_licenses.txt # file, other materials accompanying the Software, the documentation or corresponding source # files available at http://www.vmware.com/download/vi/open_source.html. # 3. Restrictions: You agree that you will not (1) use the Software to create, design or # develop anything other than Developer Software; (2) make any more copies of the Software # than are reasonably necessary for the authorized use and backup and archival purposes; # (3) modify, create derivative works of, reverse engineer, reverse compile, or disassemble # the Software, except as expressly permitted in Section 2; (4) distribute, sell, lease, rent, # lend, or sublicense any part of the Software to any third party except as expressly permitted # in Section 2 or; (5) use the Software to (a) create, design or develop software or service to # circumvent, enable, modify or provide access, permissions or rights which would violate the # technical restrictions of VMware Products, any additional licensing terms provided by VMware # via product documentation, email notification and/or policy change on VMware website, and/or # the terms of the End User License Agreements of VMware products; (b) disable, remove, over-ride # or modify the display of any VMware product End User License Agreements to the end customers; # and (c) upload or otherwise transmit any material containing software viruses or other computer # code, files or programs designed to interrupt, destroy, or limit the functionality of any # software or hardware. # The restrictions in this Section 3 shall not apply if and to the extent they contradict # mandatory local law (including, but not limited to, law implementing the EC Software Directive) # provided that, before you exercise any rights that you believe to be entitled to based on # mandatory law, you provide VMware with 30 days prior written notice at SDK_Legal@vmware.com and # provide all reasonably requested information to allow VMware to assess your claim and, at # VMware’s sole discretion, to provide alternatives that reduce any adverse impact on VMware’s # intellectual property or other rights. # 4. VMware retains ownership of the Software, including without limitation all copyrights and # other intellectual property rights therein. You may not remove, delete or modify any of VMware # copyright statements in the Software. # 5. You may not use VMware’s name, trademarks or service marks in your Developer Software’s # names or in a way that suggests your Developer Software is certified or endorsed by VMware. Your # use of VMware product names and trademarks shall comply with the Branding Guidelines posted at # www.vmware.com. # 6. If you are currently entitled to support from VMware, you may submit a support request # for installation assistance of this Software and assistance in executing unmodified utility # applications or vSphere CLI commands provided with this Software. Except as provided herein, # you are not entitled to any VMware support for this Software or any other services from VMware # in connection with this Software or your Developer Software. # 7. Term, Termination and Changes: This Agreement shall continue as long as you are in compliance # with the terms specified herein or until otherwise terminated. You and or VMware each may # terminate this Agreement for any reason at any time. You agree, upon termination, to destroy # all copies of the Software within your possession or control. The Confidential Information, # Limitations of Warranties, Liability and Indemnification sections set out in this Agreement # shall survive any termination or expiration of this Agreement. # 8. Limitations of Warranties and Liability: THE SOFTWARE IS PROVIDED “AS IS” WITHOUT ANY # WARRANTIES OF ANY KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, VMWARE DISCLAIMS # ANY IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS. # TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL VMWARE BE LIABLE FOR ANY # LOST PROFITS OR BUSINESS OPPORTUNITIES, LOSS OF USE, BUSINESS INTERRUPTION, LOSS OF DATA, OR ANY # OTHER INDIRECT, SPECIAL, INCIDENTAL, OR CONSE¬QUEN¬TIAL DAMAGES ARISING OUT OF THE SOFTWARE OR # YOUR USE OF THE SOFTWARE, UNDER ANY THEORY OF LIABILITY, WHETHER BASED IN CONTRACT, TORT, # NEGLIGENCE, PRODUCT LIABILITY, OR OTHERWISE. BECAUSE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION # OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE PRECEDING LIMITATION MAY # NOT APPLY TO YOU. # VMWARE’S LIABILITY ARISING OUT OF THE SOFTWARE PROVIDED HEREUNDER WILL NOT, IN ANY EVENT, # EXCEED US$5.00. # THE FOREGOING LIMITATIONS SHALL APPLY TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, REGARDLESS # OF WHETHER VMWARE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF WHETHER # ANY REMEDY FAILS OF ITS ESSENTIAL PURPOSE. # 9. Indemnification: You agree to defend, indemnify and hold harmless VMware, and any of its # directors, officers, employees, affiliates or agents, from and against any and all claims, losses, # damages, liabilities and other expenses (including reasonable attorneys’ fees), arising from your # modification or derivative works of the “modifiable code”, distribution or use of your Developer # Software or breach of this Agreement. # 10. These terms are governed by the laws of the State of California and the United States of # America without regard to conflict of laws principles. You may not assign any part of this Agreement # without the prior written consent of VMware. Any attempted assignment without consent shall be void. # These terms constitute the entire agreement between you and VMware with respect to the Software, and # supersede all prior written or oral communications, understandings and agreements. Any waiver of these # terms must be in writing to be effective. If any provision of these terms is found to be invalid or # unenforceable, the remaining terms will continue to be valid and enforceable to the fullest extent # permitted by law. ## @summary MountNFS ComponentState Module ## @author bkprasha@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::ESX::VmkNIC =head1 DESCRIPTION C is a derived class of L. It represents the state of VmkNIC on the given ESX Server. A related class isL, access to the VMKernel NIC on a NetworkSystem managed object reference of an ESX Server. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VM Kernel NIC element and the attributes of the VmkNIC ComponentState. =over =item C<< interface >> =item C<< portgroup >> =item C<< ip_family >> =item C<< ip_address >> =item C<< netmask >> =item C<< mac_address >> =item C<< mtu >> =item C<< tso >> =item C<< type >> =item C<< vmotion >> =back =cut package NACL::CS::ESX::VmkNIC; use strict; use warnings; use Params::Validate qw (validate); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::ComponentUtils qw (_dump_one); use NACL::Exceptions::NoElementsFound qw(:try); use NACL::APISet::Exceptions::InvalidParamValueException; use base 'NACL::CS::ComponentState'; use Data::Dumper; use Class::MethodMaker [ new => [ '-hash', 'new' ], # Primary Key scalar => 'interface', scalar => 'portgroup', scalar => 'ip_family', scalar => 'ip_address', scalar => 'netmask', scalar => 'mac_address', scalar => 'mtu', scalar => 'type', scalar => 'vmotion', scalar => 'ft_logging', scalar => 'management', ]; =head1 METHODS =head2 fetch my $nas_list = NACL::CS::ESX::VmkNIC->fetch(command_interface=>$ci,...); my @nas_lists = NACL::CS::ESX::VmkNIC->fetch(command_interface=>$ci,...); see L. =cut sub fetch { my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => "_fetch_vmknic_info", }, ], exception_text => 'No matching VMKernel NICs found' ); return wantarray ? @state_objs : $state_objs[0]; } sub _fetch_vmknic_info { my $pkg = shift; $Log->enter() if $may_enter; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $filter = $opts{filter}; my $command_interface = $opts{command_interface}; my $networksystem = $command_interface->networksystem(); my ( @state_objs, $obj ); my $vnics = $networksystem->networkInfo->vnic; my $response_for_hostview = $apiset->find_entity_view( view_type => 'HostSystem', properties => ['config.virtualNicManagerInfo.netConfig'] ); my $hostview = $response_for_hostview->get_raw_output(); my $net_configs = $hostview->{'config.virtualNicManagerInfo.netConfig'}; my %pg_management_status = (); foreach my $net_configs_item (@$net_configs) { if ($net_configs_item->selectedVnic){ foreach my $vnic (@$vnics) { my $vnic_device = $vnic->device; if (grep /$vnic_device/, @{$net_configs_item->selectedVnic}) { $pg_management_status{$vnic->device}{$net_configs_item->nicType} = 'enabled'; } else { $pg_management_status{$vnic->device}{$net_configs_item->nicType} = 'disabled'; } } } else { foreach my $vnic_t (@$vnics) { $pg_management_status{$vnic_t->device}{$net_configs_item->nicType} = 'disabled'; } } } foreach my $vnic (@$vnics) { my %vmnic_info_href = (); my $mtu = ""; my $family = "IPv4"; my $portName = $vnic->portgroup; if ( defined( $vnic->spec->mtu ) ) { $mtu = $vnic->spec->mtu; } if ( defined( $vnic->spec->distributedVirtualPort ) ) { $portName = $vnic->spec->distributedVirtualPort->portKey; } $vmnic_info_href{interface} = $vnic->device; $vmnic_info_href{portgroup} = $portName; $vmnic_info_href{ip_family} = $family; $vmnic_info_href{ip_address} = $vnic->spec->ip->ipAddress; $vmnic_info_href{netmask} = $vnic->spec->ip->subnetMask; $vmnic_info_href{mac_address} = $vnic->spec->mac; $vmnic_info_href{mtu} = $mtu; $vmnic_info_href{type} = $vnic->spec->ip->dhcp ? "DHCP" : "STATIC"; $vmnic_info_href{vmotion} = $pg_management_status{$vnic->device}{vmotion}; $vmnic_info_href{ft_logging} = $pg_management_status{$vnic->device}{faultToleranceLogging}; $vmnic_info_href{management} = $pg_management_status{$vnic->device}{management}; $obj = $pkg->new( command_interface => $opts{command_interface} ); $obj->_set_fields( row => \%vmnic_info_href ); push @state_objs, $obj; } $Log->exit() if $may_exit; return @state_objs; } 1;