# # Copyright (c) 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 VMSnapshot ComponentState Module ## @author kathar.hidayath@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::HyperV::VMSnapshot =head1 DESCRIPTION C is a derived class of L. It represents the state of Virtual machine Snapshots on the given HyperV Server. A related class isL, access to the Virtual machine managed object reference of an HyperV Server. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the VM element are the attributes of the VM ComponentState. =over =item C<< vmName >> =item C<< backupManifest >> =item C<< createTime >> =item C<< description >> =item C<< quiesced >> =item C<< replaySupported >> =item C<< id >> =item C<< state >> =back =cut package NACL::CS::HyperV::VMSnapshot; 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 => "vmName", scalar => "name", scalar => "backupManifest", scalar => "createTime", scalar => "description", scalar => "quiesced", scalar => "replaySupported", scalar => "id", scalar => "state", ]; =head1 METHODS =head2 fetch my $vm_state = NACL::CS::HyperV::VMSnapshot->fetch(command_interface=>$ci,...); my @vm_states = NACL::CS::HyperV::VMSnapshot->fetch(command_interface=>$ci,...); see L. Supported for VMAPI and XAPI. =cut sub fetch { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => "_fetch_vm_snapshot_info_esx", interface => 'VMAPI', set => 'ESX' }, { method => "_fetch_vm_snapshot_info_xen", interface => 'XAPI', set => 'Xen' }, ], exception_text => 'No matching VM snapshots found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_vm_snapshot_info_esx { $Log->enter() if $may_enter; my ($pkg, @opts) = @_; my %opts = validate (@opts, $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 $vms; $vms = $command_interface->virtualmachines(); foreach my $vm (@{$vms}) { if ($vm->snapshot) { my $snapshot_tree = $vm->snapshot->rootSnapshotList; foreach my $snapshot (@{$snapshot_tree}) { my $obj = $pkg->new( command_interface => $opts{command_interface}, vmName => $vm->config->name, name => $snapshot->name, ); $obj->backupManifest($snapshot->backupManifest); $obj->createTime($snapshot->createTime); $obj->description($snapshot->description); $obj->quiesced($snapshot->quiesced); $obj->id($snapshot->id); $obj->replaySupported($snapshot->replaySupported); $obj->state($snapshot->state->val); push @state_objs, $obj; } } } $Log->exit() if $may_exit; return @state_objs; } sub _fetch_vm_snapshot_info_xen { $Log->enter() if $may_enter; my ($pkg, @opts) = @_; my %opts = validate (@opts, $pkg->_fetch_backend_validate_spec()); my $apiset = $opts{apiset}; my $requested_fields = $opts{requested_fields}; my $command_interface = $opts{command_interface}; my @state_objs; my $vms = $command_interface->virtualmachines(); foreach my $vm (@{$vms}) { my $vm_name = $pkg->get_name(ref => $vm, ref_of => "VM", apiset => $apiset); my $snapshots = $apiset->simple_request("VM.get_snapshots", $vm)->get_parsed_output(); foreach my $snapshot (@{$snapshots}) { my $name = $pkg->get_name(ref => $snapshot, ref_of => "VM", apiset => $apiset); my $obj = $pkg->new( command_interface => $opts{command_interface}, vmName => $vm_name, name => $name, ); $obj->createTime($apiset->simple_request("VM.get_snapshot_time", $vm)->get_parsed_output()); $obj->state($apiset->simple_request("VM.get_power_state", $vm)->get_parsed_output()); push @state_objs, $obj; } } $Log->exit() if $may_exit; return @state_objs; } 1;