Sha256: ee1bb490c86a7cc2b8e999393e7cc884c4d4e93e0f2ee2c7ef6a8a3abe63c9c7
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
class BuildCloud::InternetGateway include ::BuildCloud::Component @@objects = [] def self.get_id_by_name( name ) internet_gateway = self.search( :name => name ).first unless internet_gateway raise "Couldn't get an InternetGateway object for #{name} - is it defined?" end internet_gateway_fog = internet_gateway.read unless internet_gateway_fog raise "Couldn't get an InternetGateway fog object for #{name} - is it created?" end internet_gateway_fog.internet_gateway_id end def initialize ( fog_interfaces, log, options = {} ) @compute = fog_interfaces[:compute] @log = log @options = options @log.debug( options.inspect ) required_options(:name) require_one_of(:vpc_id, :vpc_name) end def create return if exists? @log.info("Creating Internet Gateway #{@options[:name]}") options = @options.dup unless options[:vpc_id] options[:vpc_id] = BuildCloud::VPC.get_id_by_name( options[:vpc_name] ) options.delete(:vpc_name) end options[:tags] = { 'Name' => options.delete(:name) } ig = @compute.internet_gateways.new() ig.save @log.debug(ig.inspect) @compute.create_tags( ig.id, options[:tags] ) ig.attach(options[:vpc_id]) end def read @compute.internet_gateways.select { |r| r.tag_set['Name'] == @options[:name] }.first end alias_method :fog_object, :read def delete return unless exists? @log.info("Deleting Internet Gateway #{@options[:name]}") read.detach(read.attachment_set['vpcId']) fog_object.destroy end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
build-cloud-0.0.1 | lib/build-cloud/internetgateway.rb |