2013-04-10 21:44:13 -04:00
|
|
|
require 'fog/core/model'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class AWS
|
|
|
|
|
|
|
|
class RouteTable < Fog::Model
|
|
|
|
|
|
|
|
identity :id, :aliases => 'routeTableId'
|
|
|
|
|
|
|
|
attribute :state
|
|
|
|
attribute :vpc_id, :aliases => 'vpcId'
|
|
|
|
attribute :routes, :aliases => 'routeSet'
|
|
|
|
attribute :associations, :aliases => 'associationSet'
|
|
|
|
attribute :tags, :aliases => 'tagSet'
|
|
|
|
|
|
|
|
|
|
|
|
def initialize(attributes={})
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
2013-08-06 13:29:51 -04:00
|
|
|
# Remove an existing route table
|
2013-04-10 21:44:13 -04:00
|
|
|
#
|
2013-08-06 13:29:51 -04:00
|
|
|
# route_tables.destroy
|
2013-04-10 21:44:13 -04:00
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
#
|
|
|
|
# True or false depending on the result
|
|
|
|
#
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
requires :id
|
|
|
|
|
|
|
|
service.delete_route_table (id)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
2013-08-06 13:29:51 -04:00
|
|
|
# Create a route table
|
2013-04-10 21:44:13 -04:00
|
|
|
#
|
2013-08-06 13:29:51 -04:00
|
|
|
# >> routetable = connection.route_tables.new
|
|
|
|
# >> routetable.save
|
2013-04-10 21:44:13 -04:00
|
|
|
#
|
|
|
|
# == Returns:
|
|
|
|
#
|
2013-08-06 13:29:51 -04:00
|
|
|
# True or an exception depending on the result. Keep in mind that this *creates* a new route table.
|
2013-04-10 21:44:13 -04:00
|
|
|
#
|
|
|
|
|
|
|
|
def save
|
|
|
|
requires :vpc_id
|
|
|
|
|
|
|
|
data = service.create_route_table(vpc_id).body['routeTableSet'].first
|
|
|
|
new_attributes = data.reject {|key,value| key == 'requestId'}
|
|
|
|
merge_attributes(new_attributes)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def associationSet=(new_association_set)
|
|
|
|
merge_attributes(new_association_set.first || {})
|
|
|
|
end
|
|
|
|
|
|
|
|
def routeSet=(new_route_set)
|
|
|
|
merge_attributes(new_route_set || {})
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|