Sha256: 5c3c8572c8c009135e4901f6d495a53f247b2c2c3100e25cc6ad91502923c4fe

Contents?: true

Size: 1.04 KB

Versions: 43

Compression:

Stored size: 1.04 KB

Contents

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

    cmd.desc I18n.t("firewall.policies.create.desc")
    cmd.arg_name "[server-group-id...]"
    cmd.command [:create] do |c|

      c.desc I18n.t("options.name.desc")
      c.flag [:n, :name]

      c.desc I18n.t("options.description.desc")
      c.flag [:d, :description]

      c.action do |global_options, options, args|
        server_group_id = nil
        server_group = nil

        unless args.empty?
          server_group_id = args.shift
        end

        if server_group_id && !server_group_id.empty?
          server_group = ServerGroup.find(server_group_id)
        end

        name = options[:n]
        description = options[:d]

        firewall_options = {
          :name => name, :description => description
        }

        if server_group
          firewall_options.update(:server_group_id => server_group.id)
        end

        firewall_policy = FirewallPolicy.create(firewall_options)
        render_table([firewall_policy], 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/policies-create.rb
brightbox-cli-3.2.0 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-3.1.0 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-3.0.1 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-3.0.0 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.12.0 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.11.2 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.11.1 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.11.0 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.10.0 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.9.3 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.9.2 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.9.1 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.9.0 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.8.2 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.8.1 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.8.0 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.7.1 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.7.0 lib/brightbox-cli/commands/firewall/policies-create.rb
brightbox-cli-2.6.0 lib/brightbox-cli/commands/firewall/policies-create.rb