Class: Fog::Network::Softlayer::Ip
- Inherits:
-
Model
- Object
- Model
- Fog::Network::Softlayer::Ip
- Defined in:
- lib/fog/softlayer/models/network/ip.rb
Instance Method Summary collapse
- #broadcast? ⇒ Boolean
- #create ⇒ Object
- #destination_ip=(ip) ⇒ Object
- #destroy ⇒ Object
- #gateway? ⇒ Boolean
- #global? ⇒ Boolean
-
#initialize(attributes) ⇒ Ip
constructor
A new instance of Ip.
- #network? ⇒ Boolean
- #reserved? ⇒ Boolean
- #route(dest_ip) ⇒ Object
- #routed? ⇒ Boolean
- #save ⇒ Object
- #unroute ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Ip
Returns a new instance of Ip.
25 26 27 28 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 25 def initialize(attributes) @connection = attributes[:connection] super end |
Instance Method Details
#broadcast? ⇒ Boolean
58 59 60 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 58 def broadcast? !!attributes[:broadcast] end |
#create ⇒ Object
35 36 37 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 35 def create end |
#destination_ip=(ip) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 43 def destination_ip=(ip) if ip.is_a?(Hash) attributes[:destination_ip] = Fog::Network::Softlayer::Ip.new(ip) elsif ip.is_a?(Fog::Network::Softlayer::Ip) or ip.nil? attributes[:destination_ip] = ip else raise ArgumentError, "Invalid argument type in #{self.class.name}##{__method__}." end end |
#destroy ⇒ Object
53 54 55 56 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 53 def destroy raise "Only Global IP Addresses can be destroyed. Regular IP Addresses are part of Fog::Softlayer::Network::Subnet" unless global? service.delete_global_ip_address(self.global_id).status == 200 end |
#gateway? ⇒ Boolean
62 63 64 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 62 def gateway? !!attributes[:gateway] end |
#global? ⇒ Boolean
66 67 68 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 66 def global? !!attributes[:global_id] end |
#network? ⇒ Boolean
70 71 72 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 70 def network? !!attributes[:network] end |
#reserved? ⇒ Boolean
74 75 76 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 74 def reserved? !!attributes[:reserved] end |
#route(dest_ip) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 78 def route(dest_ip) requires :global_id raise ArgumentError, "Invalid argument type in #{self.class.name}##{__method__}." unless dest_ip.is_a?(Fog::Network::Softlayer::Ip) raise ArgumentError, "The destination IP may not be the network address of the destination subnet" if dest_ip.network? raise ArgumentError, "The destination IP may not be the gateway address of the destination subnet" if dest_ip.gateway? raise ArgumentError, "The destination IP may not be the broadcast address of the destination subnet" if dest_ip.broadcast? raise ArgumentError, "The destination IP may not be another global IP address" if dest_ip.global? service.route_global_ip(self.global_id, dest_ip.address).status == 200 end |
#routed? ⇒ Boolean
88 89 90 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 88 def routed? !!self.assigned_to or !!self.destination_ip end |
#save ⇒ Object
30 31 32 33 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 30 def save requires :subnet_id identity ? update : create end |
#unroute ⇒ Object
92 93 94 95 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 92 def unroute requires :global_id service.unroute_global_ip(self.global_id).status == 200 end |
#update ⇒ Object
39 40 41 |
# File 'lib/fog/softlayer/models/network/ip.rb', line 39 def update self end |