Class: Nymphia::DSL::Context::Host

Inherits:
Object
  • Object
show all
Includes:
HostContextMethods
Defined in:
lib/nymphia/dsl/context/host.rb

Direct Known Subclasses

Gateway, Proxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, name, description, default_params, gateway_usage, &block) ⇒ Host

Returns a new instance of Host.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/nymphia/dsl/context/host.rb', line 6

def initialize(context, name, description, default_params, gateway_usage, &block)
  @host_name = name
  @context = context.merge(host_name: name)
  @result = {
    metadata: {
      host_name: name,
      description: description,
    },
  }

  if default_params.nil?
    @result[:contents] = {}
  else
    @default_params = default_params.dup
    @result[:contents] = @default_params
  end

  unless gateway_usage.nil?
    proxy_command = "ssh #{@context[:gateways][gateway_usage][:metadata][:host_name]} -q -W %h:%p"

    if @result[:contents]['ProxyCommand']
      @result[:contents]['ProxyCommand'] << proxy_command
    else
      @result[:contents]['ProxyCommand'] = Array(proxy_command)
    end
  end

  instance_eval(&block) if block
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Nymphia::DSL::Context::HostContextMethods

Instance Attribute Details

#resultObject (readonly)

Returns the value of attribute result.



4
5
6
# File 'lib/nymphia/dsl/context/host.rb', line 4

def result
  @result
end