Class: LoadBalancer
- Inherits:
-
CloudstackCli::Base
- Object
- Thor
- CloudstackCli::Base
- LoadBalancer
- Defined in:
- lib/cloudstack-cli/commands/load_balancer.rb
Instance Attribute Summary
Attributes inherited from CloudstackCli::Base
Instance Method Summary collapse
Instance Method Details
#add(name) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cloudstack-cli/commands/load_balancer.rb', line 41 def add(name) say "Add #{names.join(', ')} to rule #{id}...", :yellow rule = client.assign_to_load_balancer_rule( name, [:servers], ) if rule['success'] say "OK!", :green else say "Failed!", :red end end |
#create(name) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/cloudstack-cli/commands/load_balancer.rb', line 26 def create(name) project = find_project [:private_port] = [:public_port] if [:private_port] == nil say "Create rule #{name}...", :yellow rule = client.create_load_balancer_rule( name, [:ip], [:private_port], [:public_port], ) say "OK!", :green end |
#list ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cloudstack-cli/commands/load_balancer.rb', line 5 def list project = find_project if [:project] rules = client.list_load_balancer_rules( { project_name: project ? project['name'] : nil } ) if rules.size < 1 puts "No load balancer rules found" else table = [["Name", "Public-IP", "Public-Port"]] rules.each do |rule| table << [rule['name'], rule['publicip'], rule['publicport']] end print_table table end end |