Sha256: 3cb2bd6f4f504f5f3a557cdc7edafbbcebdb74500504dba41ae141ac7023fa2a
Contents?: true
Size: 1.76 KB
Versions: 2
Compression:
Stored size: 1.76 KB
Contents
class Lb < Thor desc "list", "list load balancer rules" option :project def list cs_cli = CloudstackCli::Helper.new(options[:config]) if options[:project] project = cs_cli.projects.select { |p| p['name'] == options[:project] }.first exit_now! "Project '#{options[:project]}' not found" unless project end rules = cs_cli.list_load_balancer_rules(project ? project['id'] : nil) if rules.size < 1 puts "No load balancer rules found" else rules.each do |rule| puts "#{rule['name']} - #{rule['publicip']}:#{rule['publicport']}" end end end desc "create NAME", "create load balancer rule" option :project option :ip, :required => true option :public_port, :required => true option :private_port def create(name) cs_cli = CloudstackCli::Helper.new(options[:config]) if options[:project] project = cs_cli.projects.select { |p| p['name'] == options[:project] }.first exit_now! "Project '#{options[:project]}' not found" unless project end options[:private_port] = options[:public_port] if options[:private_port] == nil rule = cs_cli.create_load_balancer_rule( name, options[:ip], options[:private_port], options[:public_port], ) end desc "add NAME", "assign servers to balancer rule" option :project option :servers, required: true, type: :array, description: 'server names' def add(name) cs_cli = CloudstackCli::Helper.new(options[:config]) if options[:project] project = cs_cli.projects.select { |p| p['name'] == options[:project] }.first exit_now! "Project '#{options[:project]}' not found" unless project end rule = cs_cli.assign_to_load_balancer_rule( name, options[:servers], ) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cloudstack-cli-0.0.3 | lib/cloudstack-cli/commands/load_balancer.rb |
cloudstack-cli-0.0.2 | lib/cloudstack-cli/commands/load_balancer.rb |