Sha256: bc8e3f03ab5350fbf41cfab1efa70fc0045f612414d86580ee942ee6667a965a

Contents?: true

Size: 1.88 KB

Versions: 6

Compression:

Stored size: 1.88 KB

Contents

#!/usr/bin/env ruby
$LOAD_PATH << 'lib'
require 'clusterlb'
require 'colorize'
require 'getoptlong'


include Clusterlb

def display_help
	puts
  puts "Lists/Enables/Disables Sites on specific load balancers"
	puts "VERSION:        #{Clusterlb::VERSION}".colorize(:light_blue)
	puts "CONFIG:         #{Clusterlb.config_file}".colorize(:light_blue)
	puts "CLUSTERLB_HOME: #{ENV['CLUSTERLB_HOME']}".colorize(:light_blue)
	puts
	puts "Options:"
	puts "-h or --help ".ljust(30) 		  	+ "-> Display this help message"
	puts "-l or --list".ljust(30)         + "-> List LB Nodes"
	puts "-m or --matrix".ljust(30)       + "-> Show Matrix of Enabled Sites and Nodes"
	puts "-e or --enable".ljust(30)       + "-> Enable Site (used with -n for node)"
	puts "-d or --disable".ljust(30)      + "-> Disable Site  (used with -n for node)"
	puts "-n or --node".ljust(30)      		+ "-> node to enable or disable site on"
	puts
	exit 1
end


def parse_cli
  opts = GetoptLong.new(
    ["-h", "--help", GetoptLong::NO_ARGUMENT],
    ["-e", "--enable", GetoptLong::REQUIRED_ARGUMENT],
		["-n", "--node", GetoptLong::REQUIRED_ARGUMENT],
		["-d", "--disable", GetoptLong::REQUIRED_ARGUMENT],
    ["-m", "--matrix", GetoptLong::NO_ARGUMENT],
    ["-l", "--list", GetoptLong::NO_ARGUMENT]
  )

  opts.each do |opt, arg|
    case opt
    when  "-h" || "--help"
      display_help; exit
		when "-m" || "--matrix"
			Clusterlb.matrix_list; exit 1
    when "-e" || "--enable"
      @site = arg.strip().downcase(); @mode='enable'
    when "-d" || "--disable"
			@site = arg.strip().downcase(); @mode='disable'
		when "-n" || "--node"
			@node = arg.strip().downcase();
    when "-l" || "--list"
      puts Clusterlb.list_lbs; exit
    end
  end

end



parse_cli
if @site.nil? || @mode.nil? || @node.nil?
  display_help
  exit 1
end

case @mode
when "enable"
	Clusterlb.enable_site(@site,@node)
when "disable"
	Clusterlb.disable_site(@site,@node)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
clusterlb-0.1.32 exe/clusterlb-stectrl
clusterlb-0.1.31 exe/clusterlb-stectrl
clusterlb-0.1.30 exe/clusterlb-stectrl
clusterlb-0.1.29 exe/clusterlb-stectrl
clusterlb-0.1.28 exe/clusterlb-stectrl
clusterlb-0.1.27 exe/clusterlb-stectrl