Sha256: a362134795a2ade59d9ee06b84c44e42d375d458b5200d5744b303c61551d442

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true
# 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-2.1.0 lib/chef/knife/openstack_floating_ip_allocate.rb
knife-openstack-2.0.1 lib/chef/knife/openstack_floating_ip_allocate.rb
knife-openstack-2.0.0 lib/chef/knife/openstack_floating_ip_allocate.rb