Class: Glb::Lb

Inherits:
CLI::Base show all
Includes:
Util::Sure
Defined in:
lib/glb/lb.rb,
lib/glb/lb/args.rb,
lib/glb/lb/names.rb,
lib/glb/lb/url_map.rb,
lib/glb/lb/resource.rb,
lib/glb/lb/health_check.rb,
lib/glb/lb/firewall_rule.rb,
lib/glb/lb/backend_service.rb,
lib/glb/lb/forwarding_rule.rb,
lib/glb/lb/target_http_proxy.rb,
lib/glb/lb/target_https_proxy.rb,
lib/glb/lb/forwarding_rule_https.rb

Defined Under Namespace

Modules: Names Classes: Args, BackendService, FirewallRule, ForwardingRule, ForwardingRuleHttps, HealthCheck, Resource, TargetHttpProxy, TargetHttpsProxy, UrlMap

Instance Attribute Summary

Attributes inherited from CLI::Base

#options

Instance Method Summary collapse

Methods included from Util::Sure

#sure?

Methods inherited from CLI::Base

#region

Methods included from Util::Sh

#capture, #sh

Constructor Details

#initializeLb

Returns a new instance of Lb.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/glb/lb.rb', line 5

def initialize(*)
  super
  @firewall_rule = FirewallRule.new(@options)
  @health_check = HealthCheck.new(@options)
  @backend_service = BackendService.new(@options)
  @url_map = UrlMap.new(@options)
  @target_http_proxy = TargetHttpProxy.new(@options)
  @forwarding_rule = ForwardingRule.new(@options)
  @target_https_proxy = TargetHttpsProxy.new(@options) if ssl?
  @forwarding_rule_https = ForwardingRuleHttps.new(@options) if ssl?
end

Instance Method Details

#downObject



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/glb/lb.rb', line 92

def down
  down_plan unless @options[:yes]
  sure?
  @forwarding_rule_https.down if ssl?
  @target_https_proxy.down if ssl?
  @forwarding_rule.down
  @target_http_proxy.down
  @url_map.down
  @backend_service.down
  @health_check.down
  @firewall_rule.down
end

#down_planObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/glb/lb.rb', line 74

def down_plan
  commands = [
    @forwarding_rule.down_command,
    @target_http_proxy.down_command,
    @url_map.down_command,
    @backend_service.down_command,
    @health_check.down_command,
    @firewall_rule.down_command,
  ]
  if ssl?
    commands = [
      @forwarding_rule_https.down_command,
      @target_https_proxy.down_command,
    ] + commands
  end
  print_will_run(commands)
end

#planObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/glb/lb.rb', line 17

def plan
  puts "Planning..."
  commands = [
    @firewall_rule.up_command,
    @health_check.up_command,
    @backend_service.up_command,
    @backend_service.backend.add_commands,
    @url_map.up_command,
    @target_http_proxy.up_command,
    @forwarding_rule.up_command,
  ].flatten.compact
  if ssl?
    commands += [
      @target_https_proxy.up_command,
      @forwarding_rule_https.up_command,
    ]
  end
  print_will_run(commands)
end


67
68
69
70
71
72
# File 'lib/glb/lb.rb', line 67

def print_will_run(commands)
  list = commands.map { |command| "    #{command}" }.join("\n")
  puts "Will try to run:\n\n"
  puts list
  puts
end

#showObject



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/glb/lb.rb', line 54

def show
  @firewall_rule.show
  @health_check.show
  @backend_service.show
  @url_map.show
  @target_http_proxy.show
  @forwarding_rule.show
  if ssl?
    @target_https_proxy.show
    @forwarding_rule_https.show
  end
end

#upObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/glb/lb.rb', line 37

def up
  plan unless @options[:yes]
  sure?
  @firewall_rule.up
  @health_check.up
  @backend_service.up
  @url_map.up
  @target_http_proxy.up
  @forwarding_rule.up
  if ssl?
    @target_https_proxy.up
    @forwarding_rule_https.up
  end
  @forwarding_rule.show_ip
  @forwarding_rule_https.show_ip if ssl?
end