# # Copyright (c) 2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary HostSystem ComponentState Module ## @author kathar.hidayath@netapp.com, dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::HyperV =head1 DESCRIPTION C is a derived class of L. It represents the state of the given HyperV 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 >> =item C<< hypervhost >> =back =cut package NACL::CS::HyperV; 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::HyperV' }, '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 => "hypervhost", scalar => "overallStatus", ]; =head1 METHODS =head2 fetch my $vm_state = NACL::CS::HyperV::HostSystem->fetch(command_interface=>$ci,...); my @vm_states = NACL::CS::HyperV::HostSystem->fetch(command_interface=>$ci,...); see L. =cut sub fetch { $Log->enter(); my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => "_fetch_host_info", }, ], exception_text => 'No matching host found' ); $Log->exit(); return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_host_info { $Log->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(); return @state_objs; } ## end sub _fetch_host_info 1;