class MiqVimHost

Attributes

invObj[R]
name[R]

Public Class Methods

new(invObj, hh) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 21
def initialize(invObj, hh)
  @invObj                 = invObj
  @sic                    = invObj.sic
  @cfManager        = nil

  @configManager      = nil
  @datastoreSystem    = nil
  @storageSystem      = nil
  @firewallSystem     = nil
  @serviceSystem      = nil
  @networkSystem      = nil
  @hostVirtualNicManager  = nil
  @advancedOptionManager  = nil
  @snmpSystem       = nil
  @dvsConfig        = nil

  @hh           = hh
  @name                   = hh['summary']['config']['name']
  @hMor         = hh['summary']['host']
end

Public Instance Methods

advancedOptionManager() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 213
def advancedOptionManager
  return @advancedOptionManager if @advancedOptionManager
  return nil unless (ao = configManager('advancedOption'))
  @advancedOptionManager = MiqHostAdvancedOptionManager.new(ao, @invObj)
  @advancedOptionManager
end
cfManager() click to toggle source

Custom field methods.

# File lib/VMwareWebService/MiqVimHost.rb, line 282
def cfManager
  @cfManager = @invObj.getMiqCustomFieldsManager unless @cfManager
  @cfManager
end
configManager(mgr_type = nil) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 160
def configManager(mgr_type = nil)
  if @configManager.nil?
    mgr = @invObj.getMoProp(@hMor, "configManager")
    @configManager = mgr['configManager'] unless mgr.nil?
  end

  return @configManager[mgr_type] if mgr_type && @configManager
  @configManager
end
datastoreSystem() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 170
def datastoreSystem
  return @datastoreSystem if @datastoreSystem
  return nil unless (dss = configManager('datastoreSystem'))
  @datastoreSystem = MiqHostDatastoreSystem.new(dss, @invObj)
  @datastoreSystem
end
dvsConfig(refresh = false) click to toggle source

Distributed virtual switch methods.

# File lib/VMwareWebService/MiqVimHost.rb, line 296
def dvsConfig(refresh = false)
  return @dvsConfig unless refresh || !@dvsConfig
  @dvsConfig = @invObj.queryDvsConfigTarget(@invObj.sic.dvSwitchManager, @hMor, nil)
end
dvsPortGroupByFilter(filter, refresh = false) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 301
def dvsPortGroupByFilter(filter, refresh = false)
  @invObj.applyFilter(dvsConfig(refresh).distributedVirtualPortgroup, filter)
end
dvsSwitchByFilter(filter, refresh = false) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 305
def dvsSwitchByFilter(filter, refresh = false)
  @invObj.applyFilter(dvsConfig(refresh).distributedVirtualSwitch, filter)
end
enterMaintenanceMode(timeout = 0, evacuatePoweredOffVms = false, wait = true) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 112
def enterMaintenanceMode(timeout = 0, evacuatePoweredOffVms = false, wait = true)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).enterMaintenanceMode: calling enterMaintenanceMode_Task"
  taskMor = @invObj.enterMaintenanceMode_Task(@hMor, timeout, evacuatePoweredOffVms)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).enterMaintenanceMode: returned from enterMaintenanceMode_Task"
  return taskMor unless wait
  waitForTask(taskMor)
end
exitMaintenanceMode(timeout = 0, wait = true) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 120
def exitMaintenanceMode(timeout = 0, wait = true)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).exitMaintenanceMode: calling exitMaintenanceMode_Task"
  taskMor = @invObj.exitMaintenanceMode_Task(@hMor, timeout)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).exitMaintenanceMode: returned from exitMaintenanceMode_Task"
  return taskMor unless wait
  waitForTask(taskMor)
end
fileSystemVolume(selSpec = nil) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 258
def fileSystemVolume(selSpec = nil)
  if selSpec.nil?
    return @invObj.getMoProp(@hMor, "config.fileSystemVolume")
  else
    propPath = @invObj.selSpecToPropPath(selSpec)
    sd = @invObj.getMoProp(@hMor, propPath)
    return @invObj.applySelector(sd, selSpec)
  end
end
firewallSystem() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 184
def firewallSystem
  return @firewallSystem if @firewallSystem
  return nil unless (fws = configManager('firewallSystem'))
  @firewallSystem = MiqHostFirewallSystem.new(fws, @invObj)
  @firewallSystem
end
hMor() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 46
def hMor
  (@hMor)
end
hh() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 50
def hh
  (@hh)
end
hostConfigSpec() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 227
def hostConfigSpec
  VimHash.new('HostConfigSpec') do |hcs|
    hcs.datastorePrincipal = @hh.config.datastorePrincipal if @hh.config.datastorePrincipal

    hcs.firewall = VimHash.new('HostFirewallConfig') do |hfc|
      fi = firewallSystem.firewallInfo
      hfc.defaultBlockingPolicy = fi.defaultPolicy
      hfc.rule = VimArray.new('ArrayOfHostFirewallConfigRuleSetConfig') do |hfcrca|
        fi.ruleset.each do |rs|
          hfcrca << VimHash.new('HostFirewallConfigRuleSetConfig') do |hfcrc|
            hfcrc.enabled = rs.enabled
            hfcrc.rulesetId = rs.key
          end
        end
      end
    end

    hcs.service = VimArray.new('ArrayOfHostServiceConfig') do |hsca|
      serviceSystem.serviceInfo.service.each do |svc|
        hsca << VimHash.new('HostServiceConfig') do |hsc|
          hsc.serviceId   = svc.key
          hsc.startupPolicy = svc.policy
        end
      end
    end

    hcs.nicTypeSelection = VimArray.new('ArrayOfHostVirtualNicManagerNicTypeSelection') do |_hvnmntsa|
    end
  end
end
hostVirtualNicManager() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 205
def hostVirtualNicManager
  raise "hostVirtualNicManager not supported in VIM #{@invObj.apiVersion}" if @invObj.v2
  return @hostVirtualNicManager if @hostVirtualNicManager
  return nil unless (vns = configManager('virtualNicManager'))
  @hostVirtualNicManager = MiqHostVirtualNicManager.new(vns, @invObj)
  @hostVirtualNicManager
end
inMaintenanceMode?() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 104
def inMaintenanceMode?
  @invObj.getMoProp(@hMor, "runtime.inMaintenanceMode")['runtime']['inMaintenanceMode'] == "true"
end
maintenanceModeSupported?() click to toggle source

HostCapability

# File lib/VMwareWebService/MiqVimHost.rb, line 58
def maintenanceModeSupported?
  capabilityBool("maintenanceModeSupported")
end
networkSystem() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 198
def networkSystem
  return @networkSystem if @networkSystem
  return nil unless (ns = configManager('networkSystem'))
  @networkSystem = MiqHostNetworkSystem.new(ns, @invObj)
  @networkSystem
end
nfsSupported?() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 62
def nfsSupported?
  capabilityBool("nfsSupported")
end
powerDownHostToStandBy(timeout = 0, evacuatePoweredOffVms = false, wait = true) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 128
def powerDownHostToStandBy(timeout = 0, evacuatePoweredOffVms = false, wait = true)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).powerDownHostToStandBy: calling powerDownHostToStandBy_Task"
  taskMor = @invObj.powerDownHostToStandBy_Task(@hMor, timeout, evacuatePoweredOffVms)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).powerDownHostToStandBy: returned from powerDownHostToStandBy_Task"
  return taskMor unless wait
  waitForTask(taskMor)
end
powerState() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 108
def powerState
  @invObj.getMoProp(@hMor, "runtime.powerState")['runtime']['powerState']
end
powerUpHostFromStandBy(timeout = 0, wait = true) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 136
def powerUpHostFromStandBy(timeout = 0, wait = true)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).powerUpHostFromStandBy: calling powerUpHostFromStandBy_Task"
  taskMor = @invObj.powerUpHostFromStandBy_Task(@hMor, timeout)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).powerUpHostFromStandBy: returned from powerUpHostFromStandBy_Task"
  return taskMor unless wait
  waitForTask(taskMor)
end
quickStats() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 100
def quickStats
  @invObj.getMoProp(@hMor, "summary.quickStats")['summary']['quickStats']
end
rebootHost(force = false, wait = true) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 144
def rebootHost(force = false, wait = true)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).rebootHost: calling rebootHost_Task"
  taskMor = @invObj.rebootHost_Task(@hMor, force)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).rebootHost: returned from rebootHost_Task"
  return taskMor unless wait
  waitForTask(taskMor)
end
rebootSupported?() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 66
def rebootSupported?
  capabilityBool("rebootSupported")
end
release() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 42
def release
  # @invObj.releaseObj(self)
end
sanSupported?() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 70
def sanSupported?
  capabilityBool("sanSupported")
end
serviceSystem() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 191
def serviceSystem
  return @serviceSystem if @serviceSystem
  return nil unless (ss = configManager('serviceSystem'))
  @serviceSystem = MiqHostServiceSystem.new(ss, @invObj)
  @serviceSystem
end
setCustomField(name, value) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 287
def setCustomField(name, value)
  fk = cfManager.getFieldKey(name, @hMor.vimType)
  cfManager.setField(@hMor, fk, value)
end
shutdownHost(force = false, wait = true) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 152
def shutdownHost(force = false, wait = true)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).shutdownHost: calling shutdownHost_Task"
  taskMor = @invObj.shutdownHost_Task(@hMor, force)
  logger.info "MiqVimHost(#{@invObj.server}, #{@invObj.username}).shutdownHost: returned from shutdownHost_Task"
  return taskMor unless wait
  waitForTask(taskMor)
end
shutdownSupported?() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 74
def shutdownSupported?
  capabilityBool("shutdownSupported")
end
snmpSystem() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 220
def snmpSystem
  return @snmpSystem if @snmpSystem
  return nil unless (ss = configManager('snmpSystem'))
  @snmpSystem = MiqHostSnmpSystem.new(ss, @invObj)
  @snmpSystem
end
standbySupported?() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 78
def standbySupported?
  capabilityBool("standbySupported")
end
storageDevice(selSpec = nil) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 268
def storageDevice(selSpec = nil)
  if selSpec.nil?
    return @invObj.getMoProp(@hMor, "config.storageDevice")
  else
    propPath = @invObj.selSpecToPropPath(selSpec)
    sd = @invObj.getMoProp(@hMor, propPath)
    return @invObj.applySelector(sd, selSpec)
  end
end
storageSystem() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 177
def storageSystem
  return @storageSystem if @storageSystem
  return nil unless (hss = configManager('storageSystem'))
  @storageSystem = MiqHostStorageSystem.new(hss, @invObj)
  @storageSystem
end
storageVMotionSupported?() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 82
def storageVMotionSupported?
  capabilityBool("storageVMotionSupported")
end
vmotionSupported?() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 86
def vmotionSupported?
  capabilityBool("vmotionSupported")
end
vmotionWithStorageVMotionSupported?() click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 90
def vmotionWithStorageVMotionSupported?
  capabilityBool("vmotionWithStorageVMotionSupported")
end
waitForTask(tmor) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 309
def waitForTask(tmor)
  @invObj.waitForTask(tmor, self.class.to_s)
end

Private Instance Methods

capabilityBool(cn) click to toggle source
# File lib/VMwareWebService/MiqVimHost.rb, line 94
def capabilityBool(cn)
  return nil unless (cap = @hh['capability'])
  cap[cn] == "true"
end