Sha256: 41ae4438b1d2a8ea1ef2dccb7470f272419b9d3d9bbae8f23d13d70911461e30

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 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 { |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

3 entries across 3 versions & 1 rubygems

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