2010-11-08 07:21:31 -05:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Brightbox
|
2010-11-08 07:21:31 -05:00
|
|
|
|
|
|
|
class CloudIp < Fog::Model
|
|
|
|
|
|
|
|
identity :id
|
|
|
|
attribute :url
|
2011-08-22 12:41:18 -04:00
|
|
|
attribute :resource_type
|
|
|
|
|
2010-11-08 07:21:31 -05:00
|
|
|
attribute :name
|
|
|
|
attribute :status
|
|
|
|
attribute :description
|
|
|
|
|
|
|
|
attribute :reverse_dns
|
|
|
|
attribute :public_ip
|
|
|
|
|
2011-08-22 12:41:18 -04:00
|
|
|
# Links - to be replaced
|
2010-11-08 07:21:31 -05:00
|
|
|
attribute :account_id, :aliases => "account", :squash => "id"
|
|
|
|
attribute :interface_id, :aliases => "interface", :squash => "id"
|
|
|
|
attribute :server_id, :aliases => "server", :squash => "id"
|
2011-08-22 12:41:18 -04:00
|
|
|
attribute :load_balancer, :alias => "load_balancer", :squash => "id"
|
2012-12-06 06:07:18 -05:00
|
|
|
attribute :server_group, :alias => "server_group", :squash => "id"
|
2012-04-11 06:17:26 -04:00
|
|
|
attribute :port_translators
|
|
|
|
attribute :name
|
2010-11-08 07:21:31 -05:00
|
|
|
|
2011-09-30 11:15:23 -04:00
|
|
|
def map(destination)
|
2010-11-08 07:21:31 -05:00
|
|
|
requires :identity
|
2011-09-30 11:15:23 -04:00
|
|
|
case destination
|
|
|
|
when Fog::Compute::Brightbox::Server
|
|
|
|
final_destination = destination.interfaces.first["id"]
|
|
|
|
when Fog::Compute::Brightbox::LoadBalancer
|
|
|
|
final_destination = destination.id
|
|
|
|
else
|
|
|
|
final_destination = destination
|
|
|
|
end
|
2012-12-22 18:29:21 -05:00
|
|
|
service.map_cloud_ip(identity, :destination => final_destination)
|
2010-11-08 07:21:31 -05:00
|
|
|
end
|
|
|
|
|
2010-12-06 09:50:59 -05:00
|
|
|
def mapped?
|
|
|
|
status == "mapped"
|
|
|
|
end
|
|
|
|
|
2010-11-08 07:21:31 -05:00
|
|
|
def unmap
|
|
|
|
requires :identity
|
2012-12-22 18:29:21 -05:00
|
|
|
service.unmap_cloud_ip(identity)
|
2010-11-08 07:21:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :identity
|
2012-12-22 18:29:21 -05:00
|
|
|
service.destroy_cloud_ip(identity)
|
2010-11-08 07:21:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|