Class: MiqVimCluster

Inherits:
Object
  • Object
show all
Includes:
VMwareWebService::Logging
Defined in:
lib/VMwareWebService/MiqVimCluster.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from VMwareWebService::Logging

#logger

Constructor Details

#initialize(invObj, ch) ⇒ MiqVimCluster

Returns a new instance of MiqVimCluster.



8
9
10
11
12
13
14
15
# File 'lib/VMwareWebService/MiqVimCluster.rb', line 8

def initialize(invObj, ch)
  @invObj   = invObj
  @sic    = invObj.sic

  @ch     = ch
  @name   = @ch["name"]
  @cMor   = @ch["MOR"]
end

Instance Attribute Details

#invObjObject (readonly)

Returns the value of attribute invObj.



6
7
8
# File 'lib/VMwareWebService/MiqVimCluster.rb', line 6

def invObj
  @invObj
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/VMwareWebService/MiqVimCluster.rb', line 6

def name
  @name
end

Instance Method Details

#addHost(hostName, userName, password, *args) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/VMwareWebService/MiqVimCluster.rb', line 29

def addHost(hostName, userName, password, *args)
  ah = {:force => false, :wait => true, :asConnected => true}

  if args.length == 1 && args.first.kind_of?(Hash)
    ah.merge!(args.first)
  elsif args.length > 1
    ah.merge!(Hash[*args])
  end

  cspec = VimHash.new('HostConnectSpec') do |cs|
    cs.force        = ah[:force].to_s
    cs.hostName       = hostName
    cs.userName       = userName
    cs.password       = password
    cs.managementIp     = ah[:managementIp]     unless ah[:managementIp].nil?
    cs.port         = ah[:port]         unless ah[:port].nil?
    cs.sslThumbprint    = ah[:sslThumbprint]    unless ah[:sslThumbprint].nil?
    cs.vimAccountName   = ah[:vimAccountName]   unless ah[:vimAccountName].nil?
    cs.vimAccountPassword = ah[:vimAccountPassword] unless ah[:vimAccountPassword].nil?
    cs.vmFolder       = ah[:vmFolder]       unless ah[:vmFolder].nil?
  end

  logger.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addHost: calling addHost_Task"
  taskMor = @invObj.addHost_Task(@cMor, cspec, ah[:asConnected].to_s, ah[:resourcePool], ah[:license])
  logger.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addHost: returned from addHost_Task"
  return taskMor unless ah[:wait]
  waitForTask(taskMor)
end

#chObject



25
26
27
# File 'lib/VMwareWebService/MiqVimCluster.rb', line 25

def ch
  (@ch)
end

#cMorObject



21
22
23
# File 'lib/VMwareWebService/MiqVimCluster.rb', line 21

def cMor
  (@cMor)
end

#releaseObject



17
18
19
# File 'lib/VMwareWebService/MiqVimCluster.rb', line 17

def release
  # @invObj.releaseObj(self)
end

#waitForTask(tmor) ⇒ Object

def addHost



58
59
60
# File 'lib/VMwareWebService/MiqVimCluster.rb', line 58

def waitForTask(tmor)
  @invObj.waitForTask(tmor, self.class.to_s)
end