Sha256: b1d74dc13e21ee053e5726a2be21e3eb7dccabee13c20b2bf90432428cf7bd28

Contents?: true

Size: 1 KB

Versions: 9

Compression:

Stored size: 1 KB

Contents

# encoding: UTF-8
require 'chef/knife/joyent_base'

class Chef
  class Knife
    class JoyentFwList < Knife

      include Knife::JoyentBase

      banner "knife joyent fw list"

      def run
        if name_args.size > 0
          id = name_args.first
          res = self.connection.request(
            :method => "GET",
            :path => "/my/machines/#{id}/fwrules"
          )
        else
          res = self.connection.request(
            :method => "GET",
            :path => "/my/fwrules"
          )
        end

        if res.status == 200
          rules = [
            ui.color('ID', :bold),
            ui.color('Enabled', :bold),
            ui.color('Rule', :bold),
          ]

          res[:body].each do |r|
            rules << r["id"]
            rules << (r["enabled"] ? ui.color("✓", :cyan) : "✗")
            rules << r["rule"]
          end
          ui.output ui.list(rules, :uneven_columns_across, 3)
        else
          output_error(res)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
knife-joyent-0.4.14 lib/chef/knife/joyent_fw_list.rb
knife-joyent-0.4.12 lib/chef/knife/joyent_fw_list.rb
knife-joyent-0.4.11 lib/chef/knife/joyent_fw_list.rb
knife-joyent-0.4.10 lib/chef/knife/joyent_fw_list.rb
knife-joyent-0.4.9 lib/chef/knife/joyent_fw_list.rb
knife-joyent-0.4.8 lib/chef/knife/joyent_fw_list.rb
knife-joyent-0.4.5 lib/chef/knife/joyent_fw_list.rb
knife-joyent-0.4.4 lib/chef/knife/joyent_fw_list.rb
knife-joyent-0.4.3 lib/chef/knife/joyent_fw_list.rb