Sha256: 15a76fe721bd68e3634246352dcd33b691fe8ea97f79ce1e1071c9547321027f

Contents?: true

Size: 1.86 KB

Versions: 43

Compression:

Stored size: 1.86 KB

Contents

module Brightbox
  command [:"firewall-rules"] do |cmd|

    cmd.desc I18n.t("firewall.rules.update.desc")
    cmd.arg_name "[firewall-rule-id...]"
    cmd.command [:update] do |c|

      c.desc "Protocol - [tcp/udp/icmp/Protocol numbers]"
      c.flag [:p, :protocol]

      c.desc "Source - IPv4/IPv6 address or range (CIDR notation), 'any' for combined IPv4/IPv6 wildcard, server group identifer, server identifier."
      c.flag [:s, :source]

      c.desc "Source Port"
      c.flag [:t, :sport]

      c.desc "Destination. IPv4/IPv6 address or range (CIDR notation), 'any' for combined IPv4/IPv6 wildcard, server group identifer, server identifier."
      c.flag [:d, :destination]

      c.desc "Destination Port"
      c.flag [:e, :dport]

      c.desc "Icmp Type name"
      c.flag [:i, :icmptype]

      c.desc I18n.t("options.description.desc")
      c.flag :description

      c.action do |global_options, options, args|
        fwr_id = args.shift
        raise "You must specify a valid firewall rule id as the first argument" unless fwr_id =~ /^fwr-/
        firewall_rule = FirewallRule.find fwr_id
        raise "Could not find firewall rule with #{firewall_rule_id}" unless firewall_rule

        params = NilableHash.new
        params[:source_port]      = options[:t] if options[:t]
        params[:source]           = options[:s] if options[:s]
        params[:destination]      = options[:d] if options[:d]
        params[:destination_port] = options[:e] if options[:e]
        params[:icmp_type_name]   = options[:i] if options[:i]
        params[:protocol]         = options[:p] if options[:p]
        params[:description]      = options[:description] if options[:description]
        params.nilify_blanks

        info "Updating firewall rule #{firewall_rule}"
        firewall_rule.update(params)

        render_table([firewall_rule], global_options)
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
brightbox-cli-3.3.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-3.2.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-3.1.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-3.0.1 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-3.0.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.12.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.11.2 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.11.1 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.11.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.10.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.9.3 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.9.2 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.9.1 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.9.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.8.2 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.8.1 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.8.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.7.1 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.7.0 lib/brightbox-cli/commands/firewall/rules-update.rb
brightbox-cli-2.6.0 lib/brightbox-cli/commands/firewall/rules-update.rb