# # Copyright (c) 2012 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 HostSystem ComponentState Module ## @author kathar.hidayath@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::ESX::HostSystem =head1 DESCRIPTION C is a derived class of L. It represents the state of the given ESX Server. A related class isL, access to the host system managed object reference of an ESX Server. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the host element are the attributes of the host ComponentState. =over =item C<< iscsiSupported >> =item C<< maintenanceModeSupported >> =item C<< maxRunningVMs >> =item C<< maxSupportedVcpus >> =item C<< maxSupportedVMs >> =item C<< nfsSupported >> =item C<< rebootSupported >> =item C<< sanSupported >> =item C<< shutdownSupported >> =item C<< standbySupported >> =item C<< storageVMotionSupported >> =item C<< vmotionSupported >> =item C<< vStorageCapable >> =item C<< canSetPhysicalNicLinkSpeed >> =item C<< dhcpOnVnicSupported >> =item C<< dnsConfigSupported >> =item C<< ipRouteConfigSupported >> =item C<< ipV6Supported >> =item C<< maxPortGroupsPerVswitch >> =item C<< supportsVlan >> =item C<< vnicConfigSupported >> =item C<< vswitchConfigSupported >> =item C<< atBootIpV6Enabled >> =item C<< ipV6Enabled >> =item C<< defaultGateway >> =item C<< gatewayDevice >> =item C<< ipV6DefaultGateway >> =item C<< ipV6GatewayDevice >> =item C<< address >> =item C<< dhcp >> =item C<< domainName >> =item C<< hostName >> =item C<< searchDomain >> =item C<< virtualNicDevice >> =item C<< bootTime >> =item C<< inMaintenanceMode >> =item C<< powerState >> =item C<< standbyMode >> =item C<< name >> =item C<< port >> =item C<< vmotionEnabled >> =back =cut package NACL::CS::ESX::HostSystem; 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'; use Class::MethodMaker [ new => [ '-hash', 'new' ], scalar => [ { -type => 'NACL::C::ESX::ESXHost' }, 'command_interface', ], scalar => "iscsiSupported", scalar => "maintenanceModeSupported", scalar => "maxRunningVMs", scalar => "maxSupportedVcpus", scalar => "maxSupportedVMs", scalar => "nfsSupported", scalar => "rebootSupported", scalar => "sanSupported", scalar => "shutdownSupported", scalar => "standbySupported", scalar => "storageVMotionSupported", scalar => "vmotionSupported", scalar => "vStorageCapable", scalar => "canSetPhysicalNicLinkSpeed", scalar => "dhcpOnVnicSupported", scalar => "dnsConfigSupported", scalar => "ipRouteConfigSupported", scalar => "ipV6Supported", scalar => "maxPortGroupsPerVswitch", scalar => "supportsVlan", scalar => "vnicConfigSupported", scalar => "vswitchConfigSupported", scalar => "atBootIpV6Enabled", scalar => "ipV6Enabled", scalar => "localDatastoreSupported", scalar => "nfsMountCreationRequired", scalar => "nfsMountCreationSupported", scalar => "vmfsExtentExpansionSupported", scalar => "defaultGateway", scalar => "gatewayDevice", scalar => "ipV6DefaultGateway", scalar => "ipV6GatewayDevice", scalar => "address", scalar => "dhcp", scalar => "domainName", scalar => "hostName", scalar => "searchDomain", scalar => "virtualNicDevice", scalar => "bootTime", scalar => "inMaintenanceMode", scalar => "powerState", scalar => "standbyMode", scalar => "name", scalar => "port", scalar => "vmotionEnabled", scalar => "overallStatus", ]; =head1 METHODS =head2 fetch my $vm_state = NACL::CS::ESX::HostSystem->fetch(command_interface=>$ci,...); my @vm_states = NACL::CS::ESX::HostSystem->fetch(command_interface=>$ci,...); see L. =cut sub fetch { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => "_fetch_host_info", }, ], exception_text => 'No matching host found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_host_info { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $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 $host = $command_interface->hostsystem(); my $capability = $host->capability; my $config = $host->config; my $runtime = $host->runtime; my $summary = $host->summary->config; my $obj = $pkg->new( command_interface => $opts{command_interface}, name => $summary->name, ); $obj->iscsiSupported( $capability->iscsiSupported ); $obj->maintenanceModeSupported( $capability->maintenanceModeSupported ); $obj->maxRunningVMs( $capability->maxRunningVMs ); $obj->maxSupportedVcpus( $capability->maxSupportedVcpus ); $obj->maxSupportedVMs( $capability->maxSupportedVMs ); $obj->nfsSupported( $capability->nfsSupported ); $obj->rebootSupported( $capability->rebootSupported ); $obj->sanSupported( $capability->sanSupported ); $obj->shutdownSupported( $capability->shutdownSupported ); $obj->standbySupported( $capability->standbySupported ); $obj->storageVMotionSupported( $capability->storageVMotionSupported ); $obj->vmotionSupported( $capability->vmotionSupported ); $obj->vStorageCapable( $capability->vStorageCapable ); $obj->canSetPhysicalNicLinkSpeed( $config->capabilities->canSetPhysicalNicLinkSpeed ); $obj->dhcpOnVnicSupported( $config->capabilities->dhcpOnVnicSupported ); $obj->dnsConfigSupported( $config->capabilities->dnsConfigSupported ); $obj->ipRouteConfigSupported( $config->capabilities->ipRouteConfigSupported ); $obj->ipV6Supported( $config->capabilities->ipV6Supported ); $obj->maxPortGroupsPerVswitch( $config->capabilities->maxPortGroupsPerVswitch ); $obj->supportsVlan( $config->capabilities->supportsVlan ); $obj->vnicConfigSupported( $config->capabilities->vnicConfigSupported ); $obj->vswitchConfigSupported( $config->capabilities->vswitchConfigSupported ); $obj->atBootIpV6Enabled( $config->network->atBootIpV6Enabled ); $obj->ipV6Enabled( $config->network->ipV6Enabled ); $obj->localDatastoreSupported( $config->datastoreCapabilities->localDatastoreSupported ); $obj->nfsMountCreationRequired( $config->datastoreCapabilities->nfsMountCreationRequired ); $obj->nfsMountCreationSupported( $config->datastoreCapabilities->nfsMountCreationSupported ); $obj->vmfsExtentExpansionSupported( $config->datastoreCapabilities->vmfsExtentExpansionSupported ); $obj->defaultGateway( $config->network->ipRouteConfig->defaultGateway ); $obj->gatewayDevice( $config->network->ipRouteConfig->gatewayDevice ); $obj->ipV6DefaultGateway( $config->network->ipRouteConfig->ipV6DefaultGateway ); $obj->ipV6GatewayDevice( $config->network->ipRouteConfig->ipV6GatewayDevice ); $obj->address( $config->network->dnsConfig->address ); $obj->dhcp( $config->network->dnsConfig->dhcp ); $obj->domainName( $config->network->dnsConfig->domainName ); $obj->hostName( $config->network->dnsConfig->hostName ); $obj->searchDomain( $config->network->dnsConfig->searchDomain ); $obj->virtualNicDevice( $config->network->dnsConfig->virtualNicDevice ); $obj->bootTime( $runtime->bootTime ); $obj->inMaintenanceMode( $runtime->inMaintenanceMode ); $obj->powerState( $runtime->powerState->val ); $obj->standbyMode( $runtime->standbyMode ); $obj->port( $summary->port ); $obj->vmotionEnabled( $summary->vmotionEnabled ); $obj->overallStatus( $host->summary->overallStatus->val ); push @state_objs, $obj; $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_host_info 1;