Class: SwarmClusterCliOpe::Models::Service

Inherits:
Base
  • Object
show all
Defined in:
lib/swarm_cluster_cli_ope/models/service.rb

Constant Summary

Constants inherited from Base

Base::IDNotFoundOnObject

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#docker_command, #docker_inspect, #initialize, #mapped_uri_connection

Methods included from LoggerConcern

#logger

Constructor Details

This class inherits a constructor from SwarmClusterCliOpe::Models::Base

Instance Attribute Details

#idString

Returns:

  • (String)


8
9
10
# File 'lib/swarm_cluster_cli_ope/models/service.rb', line 8

def id
  @id
end

#nameString

Returns:

  • (String)


6
7
8
# File 'lib/swarm_cluster_cli_ope/models/service.rb', line 6

def name
  @name
end

Class Method Details

.all(stack_name: nil) ⇒ Array<SwarmClusterCliOpe::Service>

Returns:

  • (Array<SwarmClusterCliOpe::Service>)


11
12
13
# File 'lib/swarm_cluster_cli_ope/models/service.rb', line 11

def self.all(stack_name: nil)
  Commands::Service.new.ls(stack_name: stack_name).result(object_class: Service)
end

.find(service_name, stack_name: nil) ⇒ SwarmClusterCliOpe::Service

Returns:

  • (SwarmClusterCliOpe::Service)


16
17
18
# File 'lib/swarm_cluster_cli_ope/models/service.rb', line 16

def self.find(service_name, stack_name: nil)
  Commands::Service.new.find(service_name, stack_name: stack_name).result(object_class: Service).first
end

Instance Method Details

#containersArray<SwarmClusterCliOpe::Container>

Containers del servizio

Returns:

  • (Array<SwarmClusterCliOpe::Container>)


23
24
25
# File 'lib/swarm_cluster_cli_ope/models/service.rb', line 23

def containers
  tasks.collect { |t| t.container }
end

#tasksArray<Task>

Elenco dei task del servizio docker service ps SERVICE_NAME –format=“.}” -f “desired-state=running”

Returns:



31
32
33
# File 'lib/swarm_cluster_cli_ope/models/service.rb', line 31

def tasks
  docker_command.ps(name).result(object_class: Task)
end