Class: Fog::Compute::Glesys::Ip

Inherits:
Model
  • Object
show all
Extended by:
Deprecation
Defined in:
lib/fog/glesys/models/compute/ip.rb

Instance Method Summary collapse

Instance Method Details

#attach(server) ⇒ Object

Add an ip-adress to the server.

Raises:

  • (Fog::Errors::Error)


38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/glesys/models/compute/ip.rb', line 38

def attach(server)
  requires :ip
  server = server.serverid if server.is_a?(Fog::Compute::Glesys::Server)
  raise Fog::Errors::Error.new("Ip is already attached to a server, #{serverid}") unless serverid.nil?
  data = service.ip_add(
    :ipaddress => identity,
    :serverid  => server
  ).body["response"]["details"]
  merge_attributes data
end

#attached?Boolean



24
25
26
# File 'lib/fog/glesys/models/compute/ip.rb', line 24

def attached?
  !serverid.nil?
end

#destroyObject

Remove the ip from a server and release it



58
59
60
61
# File 'lib/fog/glesys/models/compute/ip.rb', line 58

def destroy
  requires :ip
  remove(:release => true)
end

#releaseObject

Return an unused ip-address to the pool of free ips.

Raises:

  • (Fog::Errors::Error)


29
30
31
32
33
34
35
# File 'lib/fog/glesys/models/compute/ip.rb', line 29

def release
  requires :ip
  raise Fog::Errors::Error.new('You can\'t release a ip that is attached to a server') if attached?
  service.ip_release(
    :ipaddress => identity
  )
end

#remove(options = {}) ⇒ Object

Remove an ip from the server

Raises:

  • (Fog::Errors::Error)


50
51
52
53
54
55
# File 'lib/fog/glesys/models/compute/ip.rb', line 50

def remove(options = {})
  requires :ip
  raise Fog::Errors::Error.new('Ip is not attached to a server.') if serverid.nil?
  data = service.ip_remove({:ipaddress => ip}.merge!(options)).body["response"]["details"]
  merge_attributes data
end

#takeObject



63
64
65
66
67
68
69
# File 'lib/fog/glesys/models/compute/ip.rb', line 63

def take
  requires :ip
  data = service.ip_take(
    :ipaddress => ip
  ).body["response"]["details"]
  merge_attributes data
end