Class: Fog::Compute::Glesys::Ips
- Inherits:
-
Fog::Collection
- Object
- Fog::Collection
- Fog::Compute::Glesys::Ips
- Defined in:
- lib/fog/glesys/models/compute/ips.rb
Instance Method Summary collapse
- #all ⇒ Object
- #attach(ip, server_id = nil) ⇒ Object
- #attached ⇒ Object
- #available ⇒ Object
- #free(options = {}) ⇒ Object
- #get(ip) ⇒ Object
- #release(ip) ⇒ Object
- #remove(ip, options = {}) ⇒ Object
- #take(ip, options = {}) ⇒ Object
Instance Method Details
#all ⇒ Object
13 14 15 16 17 18 |
# File 'lib/fog/glesys/models/compute/ips.rb', line 13 def all attributes = {} attributes[:serverid] = serverid unless serverid.nil? ips = service.ip_list_own(attributes).body['response']['iplist'] load(ips) end |
#attach(ip, server_id = nil) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/fog/glesys/models/compute/ips.rb', line 82 def attach(ip, server_id=nil) if server_id.nil? server_id = serverid end if server_id.nil? raise Fog::Errors::Error.new("You need to specify a server id") end server_id = server_id.serverid if server_id.is_a?(Fog::Compute::Glesys::Server) service.ip_add( :ipaddress => ip_from_object(ip), :serverid => server_id ) if server.nil? true else server.reload end end |
#attached ⇒ Object
25 26 27 |
# File 'lib/fog/glesys/models/compute/ips.rb', line 25 def attached all.select { |ip| !ip.serverid.nil? } end |
#available ⇒ Object
29 30 31 |
# File 'lib/fog/glesys/models/compute/ips.rb', line 29 def available all.select { |ip| ip.serverid.nil? } end |
#free(options = {}) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/fog/glesys/models/compute/ips.rb', line 33 def free( = {}) = { :version => 4 } if !server.nil? [:datacenter] = server.datacenter [:platform] = server.platform end = .merge!() %w{platform datacenter version}.each do |attr| raise Fog::Errors::Error.new("You need to specify ':#{attr}'") if !.key?(attr.to_sym) end [:ipversion] = [:version] .delete(:version) service.ip_list_free().body["response"]["iplist"]["ipaddresses"] end |
#get(ip) ⇒ Object
20 21 22 23 |
# File 'lib/fog/glesys/models/compute/ips.rb', line 20 def get(ip) data = service.ip_details( :ipaddress => ip).body['response']['details'] new data end |
#release(ip) ⇒ Object
76 77 78 79 80 |
# File 'lib/fog/glesys/models/compute/ips.rb', line 76 def release(ip) service.ip_release( :ipaddress => ip_from_object(ip) ) end |
#remove(ip, options = {}) ⇒ Object
105 106 107 |
# File 'lib/fog/glesys/models/compute/ips.rb', line 105 def remove(ip, = {}) new service.ip_remove({:ipaddress => ip_from_object(ip)}.merge!()).data.body["response"]["details"] end |
#take(ip, options = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fog/glesys/models/compute/ips.rb', line 55 def take(ip, = {}) = { :attach => false } = .merge!() data = service.ip_take( :ipaddress => ip_from_object(ip) ).body["response"]["details"] ip = new data if [:attach] && serverid server.ips.attach ip, serverid ip.serverid = serverid end ip end |