Sha256: acd0c391742f73446d1a75f3b66e959edb98e8032cb839f441f4b9143b22a5d1

Contents?: true

Size: 976 Bytes

Versions: 1

Compression:

Stored size: 976 Bytes

Contents

require 'chef/knife/profitbricks_base'

class Chef
  class Knife
    class ProfitbricksLanList < Knife
      include Knife::ProfitbricksBase

      banner 'knife profitbricks lan list (options)'

      option :datacenter_id,
             short: '-D DATACENTER_ID',
             long: '--datacenter-id DATACENTER_ID',
             description: 'The ID of the data center',
             proc: proc { |datacenter_id| Chef::Config[:knife][:datacenter_id] = datacenter_id }

      def run
        $stdout.sync = true
        lan_list = [
          ui.color('ID', :bold),
          ui.color('Name', :bold),
          ui.color('Public', :bold),
        ]
        connection

        ProfitBricks::LAN.list(Chef::Config[:knife][:datacenter_id]).each do |lan|
          lan_list << lan.id
          lan_list << lan.properties['name']
          lan_list << lan.properties['public'].to_s
        end

        puts ui.list(lan_list, :uneven_columns_across, 3)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
knife-profitbricks-2.0.1 lib/chef/knife/profitbricks_lan_list.rb