Sha256: df90ca6b25611c495d7e37ed62f28218aa2937faa56ea21ac789bede47a9a109

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

require 'chef/knife/profitbricks_base'

class Chef
  class Knife
    class ProfitbricksIpblockCreate < Knife
      include Knife::ProfitbricksBase

      banner 'knife profitbricks ipblock create (options)'

      option :location,
             short: '-l LOCATION',
             long: '--location LOCATION',
             description: 'Location of the IP block (us/las, de/fra, de/fkb)',
             required: true

      option :size,
             short: '-S INT',
             long: '--size INT',
             description: 'The number of IP addresses to reserve',
             required: true

      def run
        $stdout.sync = true

        print "#{ui.color('Allocating IP block...', :magenta)}"

        connection
        ipblock = ProfitBricks::IPBlock.create(
          location: config[:location],
          size: config[:size]
        )

        dot = ui.color('.', :magenta)
        ipblock.wait_for { print dot; ready? }

        puts "\n"
        puts "#{ui.color('ID', :cyan)}: #{ipblock.id}"
        puts "#{ui.color('Location', :cyan)}: #{ipblock.properties['location']}"
        puts "#{ui.color('IP Addresses', :cyan)}: #{ipblock.properties['ips']}"

        puts 'done'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
knife-profitbricks-1.2.1 lib/chef/knife/profitbricks_ipblock_create.rb
knife-profitbricks-1.2.0 lib/chef/knife/profitbricks_ipblock_create.rb
knife-profitbricks-1.1.2 lib/chef/knife/profitbricks_ipblock_create.rb
knife-profitbricks-1.1.1 lib/chef/knife/profitbricks_ipblock_create.rb