Module: FogExtensions::Vsphere::Server

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/fog_extensions/vsphere/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#add_cdromObject

Returns the value of attribute add_cdrom


7
8
9
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 7

def add_cdrom
  @add_cdrom
end

#image_idObject

Returns the value of attribute image_id


6
7
8
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 6

def image_id
  @image_id
end

Instance Method Details

#interfaces_attributes=(attrs) ⇒ Object


17
18
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 17

def interfaces_attributes=(attrs)
end

#poweroffObject


23
24
25
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 23

def poweroff
  stop(:force => true)
end

#resetObject


27
28
29
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 27

def reset
  reboot(:force => true)
end

#scsi_controller_typeObject


35
36
37
38
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 35

def scsi_controller_type
  return scsi_controller[:type] if scsi_controller.is_a?(Hash)
  scsi_controller.type
end

#select_nic(fog_nics, nic) ⇒ Object


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 40

def select_nic(fog_nics, nic)
  nic_attrs = nic.compute_attributes
  all_networks = service.list_networks(datacenter: datacenter)
  vm_network = all_networks.detect { |network| nic_attrs['network'] && [network[:name], network[:id]].compact.include?(nic_attrs['network']) }
  vm_network ||= all_networks.detect { |network| network[:_ref] == nic_attrs['network'] }
  unless vm_network
    Rails.logger.info "Could not find Vsphere network for #{nic_attrs.inspect}"
    return
  end
  selected_nic = fog_nics.detect { |fn| fn.network == vm_network[:name] } # grab any nic on the same network
  if selected_nic.nil? && vm_network[:id].present?
    selected_nic = fog_nics.detect { |fn| fn.network == vm_network[:id] } # try to match on portgroup
  end
  selected_nic
end

#stateObject


13
14
15
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 13

def state
  power_state
end

#to_sObject


9
10
11
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 9

def to_s
  name
end

#vm_descriptionObject


31
32
33
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 31

def vm_description
  _("%{cpus} CPUs and %{memory} MB memory") % {:cpus => cpus, :memory => memory_mb.to_i}
end

#volumes_attributes=(attrs) ⇒ Object


20
21
# File 'app/models/concerns/fog_extensions/vsphere/server.rb', line 20

def volumes_attributes=(attrs)
end