Class: KumoDockerCloud::HaproxyService

Inherits:
Service
  • Object
show all
Defined in:
lib/kumo_dockercloud/haproxy_service.rb

Instance Attribute Summary

Attributes inherited from Service

#name

Instance Method Summary collapse

Methods inherited from Service

#containers, #deploy, #linked_services, #links, #resource_uri, service_by_resource_uri, #set_link, #state, #stop, #uuid

Constructor Details

#initialize(stack_name, docker_cloud_api = DockerCloudApi.new) ⇒ HaproxyService

Returns a new instance of HaproxyService.



3
4
5
6
7
# File 'lib/kumo_dockercloud/haproxy_service.rb', line 3

def initialize(stack_name, docker_cloud_api = DockerCloudApi.new)
  super(stack_name, 'haproxy', docker_cloud_api)

  @client = docker_cloud_api.client
end

Instance Method Details

#disable_service(service) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/kumo_dockercloud/haproxy_service.rb', line 9

def disable_service(service)
  service_to_disable = service.name
  haproxy_containers = containers.map { |container| HaproxyContainer.new(container.uuid, @client) }

  raise KumoDockerCloud::HAProxyStateError.new('Could not get instances of the haproxy container for this environment') if haproxy_containers.empty?

  haproxy_containers.each do |haproxy_container|
    haproxy_container.disable_server(service_to_disable)
  end
end

#enable_service(service) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/kumo_dockercloud/haproxy_service.rb', line 20

def enable_service(service)
  service_to_enable = service.name
  haproxy_containers = containers.map { |container| HaproxyContainer.new(container.uuid, @client) }

  raise KumoDockerCloud::HAProxyStateError.new('Could not get instances of the haproxy container for this environment') if haproxy_containers.empty?

  haproxy_containers.each do |haproxy_container|
    haproxy_container.enable_server(service_to_enable)
  end
end