Class: Fog::Compute::Glesys::Ip
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Glesys::Ip
- Extended by:
- Deprecation
- Defined in:
- lib/fog/glesys/models/compute/ip.rb
Instance Method Summary collapse
-
#attach(server) ⇒ Object
Add an ip-adress to the server.
- #attached? ⇒ Boolean
-
#destroy ⇒ Object
Remove the ip from a server and release it.
-
#release ⇒ Object
Return an unused ip-address to the pool of free ips.
-
#remove(options = {}) ⇒ Object
Remove an ip from the server.
- #take ⇒ Object
Instance Method Details
#attach(server) ⇒ Object
Add an ip-adress to the server.
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 |
#destroy ⇒ Object
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 |
#release ⇒ Object
Return an unused ip-address to the pool of free ips.
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
50 51 52 53 54 55 |
# File 'lib/fog/glesys/models/compute/ip.rb', line 50 def remove( = {}) requires :ip raise Fog::Errors::Error.new('Ip is not attached to a server.') if serverid.nil? data = service.ip_remove({:ipaddress => ip}.merge!()).body["response"]["details"] merge_attributes data end |
#take ⇒ Object
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 |