Class: Fog::Compute::Glesys::Ip
- Extended by:
- Deprecation
- Defined in:
- lib/fog/glesys/models/compute/ip.rb
Instance Attribute Summary
Attributes inherited from Model
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
Methods included from Deprecation
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#attach(server) ⇒ Object
Add an ip-adress to the server.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fog/glesys/models/compute/ip.rb', line 40 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
26 27 28 |
# File 'lib/fog/glesys/models/compute/ip.rb', line 26 def attached? !serverid.nil? end |
#destroy ⇒ Object
Remove the ip from a server and release it
60 61 62 63 |
# File 'lib/fog/glesys/models/compute/ip.rb', line 60 def destroy requires :ip remove(:release => true) end |
#release ⇒ Object
Return an unused ip-address to the pool of free ips.
31 32 33 34 35 36 37 |
# File 'lib/fog/glesys/models/compute/ip.rb', line 31 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
52 53 54 55 56 57 |
# File 'lib/fog/glesys/models/compute/ip.rb', line 52 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
65 66 67 68 69 70 71 |
# File 'lib/fog/glesys/models/compute/ip.rb', line 65 def take requires :ip data = service.ip_take( :ipaddress => ip ).body["response"]["details"] merge_attributes data end |