Class: SwarmClusterCliOpe::Models::Container
- Defined in:
- lib/swarm_cluster_cli_ope/models/container.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#id ⇒ String
Id del container.
-
#image ⇒ String
Nome dell’immagine.
-
#labels ⇒ Hash
Labels del container.
- #name ⇒ String
Class Method Summary collapse
- .all(service_name: nil) ⇒ Object
- .find_by_service_name(service_name, stack_name: nil) ⇒ SwarmClusterCliOpe::Models::Container
Instance Method Summary collapse
-
#config=(config) ⇒ Object
Può essere che riceva dei valori dal config, tipo quando facciamo inspect.
-
#copy_in(src, dest) ⇒ Object
Copia i file dentro al container.
-
#copy_out(src, dest) ⇒ Object
Copia i file dal container all’esterno.
-
#exec(cmd) ⇒ Object
Esegue il comando passato.
-
#mapped_uri_connection ⇒ String
Ritorna il connection_uri del nodo che ospita il container.
-
#mapped_volumes ⇒ Array<MappedVolume>
Elenco dei volumi mappato.
-
#node ⇒ SwarmClusterCliOpe::Node
Ritorna il nodo dello swarm che contiene questo container.
-
#node_id ⇒ String
Id del nodo di appartenenza.
Methods inherited from Base
#docker_command, #docker_inspect, #initialize
Methods included from LoggerConcern
Constructor Details
This class inherits a constructor from SwarmClusterCliOpe::Models::Base
Instance Attribute Details
#id ⇒ String
Returns id del container.
8 9 10 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 8 def id @id end |
#image ⇒ String
Returns nome dell’immagine.
10 11 12 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 10 def image @image end |
#labels ⇒ Hash
Returns labels del container.
12 13 14 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 12 def labels @labels end |
#name ⇒ String
6 7 8 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 6 def name @name end |
Class Method Details
.all(service_name: nil) ⇒ Object
34 35 36 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 34 def self.all(service_name: nil) Commands::Container.new.ps(service_name: service_name).result(object_class: Container) end |
.find_by_service_name(service_name, stack_name: nil) ⇒ SwarmClusterCliOpe::Models::Container
30 31 32 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 30 def self.find_by_service_name(service_name, stack_name: nil) Service.find(service_name,stack_name:stack_name).containers.first end |
Instance Method Details
#config=(config) ⇒ Object
Può essere che riceva dei valori dal config, tipo quando facciamo inspect
20 21 22 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 20 def config=(config) @labels = config["Labels"] end |
#copy_in(src, dest) ⇒ Object
Copia i file dentro al container
42 43 44 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 42 def copy_in(src, dest) docker_command.cp(src, "#{id}:#{dest}").success? end |
#copy_out(src, dest) ⇒ Object
Copia i file dal container all’esterno
50 51 52 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 50 def copy_out(src, dest) docker_command.cp("#{id}:#{src}", dest).success? end |
#exec(cmd) ⇒ Object
Esegue il comando passato
56 57 58 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 56 def exec(cmd) docker_command.exec(id, cmd) end |
#mapped_uri_connection ⇒ String
Ritorna il connection_uri del nodo che ospita il container
63 64 65 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 63 def mapped_uri_connection node.connection_uri end |
#mapped_volumes ⇒ Array<MappedVolume>
Elenco dei volumi mappato
70 71 72 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 70 def mapped_volumes docker_inspect.Mounts.collect { |v| MappedVolume.new(v, container: self) } end |
#node ⇒ SwarmClusterCliOpe::Node
Ritorna il nodo dello swarm che contiene questo container
77 78 79 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 77 def node cfgs.get_node_by_id(node_id) end |
#node_id ⇒ String
Returns id del nodo di appartenenza.
25 26 27 |
# File 'lib/swarm_cluster_cli_ope/models/container.rb', line 25 def node_id labels["com.docker.swarm.node.id"] end |