Module: FogExtensions::Openstack::Server

Defined in:
app/models/concerns/fog_extensions/openstack/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#boot_from_volumeObject

Returns the value of attribute boot_from_volume


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

def boot_from_volume
  @boot_from_volume
end

#networkObject


56
57
58
59
60
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 56

def network
  return @network if @network # in case we didnt submitting the form again after an error.
  return networks.try(:first).try(:name) if persisted?
  nil
end

#nicsObject (readonly)

Returns the value of attribute nics


4
5
6
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 4

def nics
  @nics
end

#scheduler_hint_filterObject

Returns the value of attribute scheduler_hint_filter


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

def scheduler_hint_filter
  @scheduler_hint_filter
end

#security_groupObject


62
63
64
65
66
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 62

def security_group
  return @security_group if @security_group # in case we didnt submitting the form again after an error.
  return security_groups.try(:first).try(:name) if persisted?
  nil
end

#size_gbObject

Returns the value of attribute size_gb


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

def size_gb
  @size_gb
end

Instance Method Details

#created_atObject


38
39
40
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 38

def created_at
  Time.parse(attributes['created']).utc
end

#flavor_with_objectObject


34
35
36
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 34

def flavor_with_object
  service.flavors.get attributes[:flavor]['id']
end

#pauseObject


26
27
28
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 26

def pause
  service.pause_server(id)
end

#resetObject


68
69
70
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 68

def reset
  reboot('HARD')
end

#security_groupsObject

the original method requires a server ID, however we want to be able to call this method on new instances too


43
44
45
46
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 43

def security_groups
  return [] if id.nil?
  super
end

#startObject


12
13
14
15
16
17
18
19
20
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 12

def start
  if state.downcase == 'paused'
    service.unpause_server(id)
  elsif state.downcase == 'suspended'
    service.resume_server(id)
  else
    service.start_server(id)
  end
end

#stopObject


22
23
24
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 22

def stop
  service.stop_server(id)
end

#tenantObject


30
31
32
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 30

def tenant
  service.tenants.detect { |t| t.id == tenant_id }
end

#to_sObject


8
9
10
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 8

def to_s
  name
end

#vm_descriptionObject


72
73
74
# File 'app/models/concerns/fog_extensions/openstack/server.rb', line 72

def vm_description
  service.flavors.get(flavor_ref).try(:name)
end