Sha256: 06781c3e250d19ed04af272ffea8b5a104b8819b43fee92c3b4c949b0feef16c

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

# Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
# Copyright:: Copyright (c) 2015 Chef Software, Inc.

require 'chef/knife/openstack_helpers'
require 'chef/knife/cloud/openstack_service_options'
require 'chef/knife/cloud/command'

class Chef
  class Knife
    class Cloud
      class OpenstackFloatingIpAllocate < Command
        include OpenstackHelpers
        include OpenstackServiceOptions

        banner 'knife openstack floating_ip allocate (options)'

        option :pool,
          :short => '-p POOL',
          :long => '--pool POOL',
          :description => 'Floating IP pool to allocate from.',
          :proc => Proc.new { |key| Chef::Config[:knife][:pool] = key }

        def execute_command
          @resource = @service.allocate_address(locate_config_value(:pool))
        end

        def after_exec_command
          @columns_with_info = [{ label: 'ID', value: @resource['floating_ip']['id'].to_s },
                                { label: 'Instance ID', value: @resource['floating_ip']['instance_id'].to_s },
                                { label: 'Floating IP', value: @resource['floating_ip']['ip'].to_s },
                                { label: 'Fixed IP', value: @resource['floating_ip']['fixed_ip'].to_s },
                                { label: 'Pool', value: @resource['floating_ip']['pool'].to_s }
                               ]
          @service.server_summary(nil, @columns_with_info)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knife-openstack-1.3.2.pre lib/chef/knife/openstack_floating_ip_allocate.rb