Class: Fog::Compute::Gridscale::Server

Inherits:
Server
  • Object
show all
Defined in:
lib/fog/compute/gridscale/models/server.rb

Instance Method Summary collapse

Instance Method Details

#cpuObject



53
54
55
# File 'lib/fog/compute/gridscale/models/server.rb', line 53

def cpu
  cores
end

#deleteObject



130
131
132
133
134
# File 'lib/fog/compute/gridscale/models/server.rb', line 130

def delete
  requires :object_uuid
  response = service.server_delete(object_uuid)
  response.body
end

#destroyObject



136
137
138
139
140
# File 'lib/fog/compute/gridscale/models/server.rb', line 136

def destroy
  requires :object_uuid
  response = service.server_delete(object_uuid)
  response
end

#ipv4_addressObject



61
62
63
64
65
# File 'lib/fog/compute/gridscale/models/server.rb', line 61

def ipv4_address
  if (net = relations['public_ips'].find {|n|n['family']==4})
    net['ip']
  end
end

#ipv6_addressObject



79
80
81
82
83
# File 'lib/fog/compute/gridscale/models/server.rb', line 79

def ipv6_address
  if (net = relations['public_ips'].find {|n|n['family']==6})
    net['ip']
  end
end

#macObject



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fog/compute/gridscale/models/server.rb', line 67

def mac
  if relations['networks'] and relations['networks'] != []
    if relations['networks'].first
      if relations['networks'].first['mac'] != nil
        relations['networks'].first['mac'].to_s
      else
        nil
      end
    end
  end
end

#public_ip_addressObject



57
58
59
# File 'lib/fog/compute/gridscale/models/server.rb', line 57

def public_ip_address
  ipv4_address
end

#ready?Boolean

Returns:

  • (Boolean)


159
160
161
162
163
# File 'lib/fog/compute/gridscale/models/server.rb', line 159

def ready?
  requires :object_uuid
  response = service.server_power_get(object_uuid)
  response.body['power']
end

#saveObject

Raises:

  • (Fog::Errors::Error)


85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/fog/compute/gridscale/models/server.rb', line 85

def save
  raise Fog::Errors::Error.new('Re-saving an existing object may create a duplicate') if persisted?
  requires :name, :cores, :memory

  options = {}
  if attributes[:interfaces_attributes]
    options[:interfaces_attributes] = attributes[:interfaces_attributes]
  end

  if attributes[:storage]
    options[:storage] = attributes[:storage]
  end

  if attributes[:labels]
    options[:labels] = attributes[:labels]
  end

  if attributes[:auto_recovery]
    options[:auto_recovery] = auto_recovery
  end

  if attributes[:hardware_profile]
    options[:hardware_profile] = hardware_profile
  end

  if attributes[:availability_zone]
    options[:availability_zone] = availability_zone
  end

  if attributes[:location_uuid]
    options[:location_uuid] = location_uuid
  end

  if attributes[:template_uuid]
    options[:template_uuid] = template_uuid
  end

  if attributes[:sshkey_uuid]
    options[:sshkey_uuid] = sshkey_uuid
  end

  data = service.server_create(name, cores, memory, options)
  merge_attributes(data.body['server'])
end

#shutdownObject



147
148
149
150
151
# File 'lib/fog/compute/gridscale/models/server.rb', line 147

def shutdown
  requires :object_uuid
  response = service.server_shutdown(object_uuid)
  response
end

#startObject



142
143
144
145
# File 'lib/fog/compute/gridscale/models/server.rb', line 142

def start
  response = service.server_power_on(object_uuid)
  response.body
end

#stopObject



153
154
155
156
157
# File 'lib/fog/compute/gridscale/models/server.rb', line 153

def stop
  requires :object_uuid
  response = service.server_power_off(object_uuid)
  response
end