Method: OodCore::Cluster#initialize

Defined in:
lib/ood_core/cluster.rb

#initialize(cluster) ⇒ Cluster

Returns a new instance of Cluster.

Parameters:

  • cluster (#to_h)

    the cluster object

Options Hash (cluster):

  • :id (#to_sym)

    The cluster id

  • :metadata (#to_h) — default: {}

    The cluster’s metadata

  • :login (#to_h) — default: {}

    The cluster’s SSH host

  • :job (#to_h) — default: {}

    The job adapter for this cluster

  • :custom (#to_h) — default: {}

    Any custom resources for this cluster

  • :acls (Array<#to_h>) — default: []

    List of ACLs to validate against

  • :batch_connect (#to_h) — default: {}

    Configuration for batch connect templates

  • :errors (#to_a) — default: []

    List of configuration errors



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ood_core/cluster.rb', line 48

def initialize(cluster)
  c = cluster.to_h.symbolize_keys

  # Required options
  @id = c.fetch(:id) { raise ArgumentError, "No id specified. Missing argument: id" }.to_sym

  # General options
   = c.fetch(:metadata, {}).to_h.symbolize_keys
  @login_config    = c.fetch(:login, {})   .to_h.symbolize_keys
  @job_config      = c.fetch(:job, {})     .to_h.symbolize_keys
  @custom_config   = c.fetch(:custom, {})  .to_h.symbolize_keys
  @acls_config     = c.fetch(:acls, [])    .map(&:to_h)
  @batch_connect_config = c.fetch(:batch_connect, {}).to_h.symbolize_keys

  # side affects from object creation and validation
  @errors          = c.fetch(:errors, [])  .to_a
end