Class: TestLab::Node

Inherits:
ZTK::DSL::Base
  • Object
show all
Extended by:
ClassMethods
Includes:
Actions, Doctor, LXC, MethodMissing, Provision, SSH, Status, Support::Execution, Support::Lifecycle, Utility::Misc
Defined in:
lib/testlab/node.rb,
lib/testlab/node/lxc.rb,
lib/testlab/node/ssh.rb,
lib/testlab/node/doctor.rb,
lib/testlab/node/status.rb,
lib/testlab/node/actions.rb,
lib/testlab/node/provision.rb,
lib/testlab/node/class_methods.rb,
lib/testlab/node/method_missing.rb

Overview

Node Class

Author:

  • Zachary Patten <zachary AT jovelabs DOT com>

Defined Under Namespace

Modules: Actions, ClassMethods, Doctor, LXC, MethodMissing, Provision, SSH, Status

Constant Summary collapse

STATUS_KEYS =
%w(id instance_id ok state user ip port provider provisioners).map(&:to_sym)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

template_dir

Methods included from Utility::Misc

#do_provisioner_callbacks, #format_message, #format_object_action, #please_wait, #sudo, #sudo_prompt

Methods included from Support::Lifecycle

#bounce, #build, #demolish, #recycle

Methods included from Support::Execution

#bootstrap, #download, #exec, #file, #upload

Methods included from Status

#status

Methods included from SSH

#container_ssh, #ssh, #ssh_shutdown!

Methods included from Provision

#deprovision, #provision

Methods included from MethodMissing

#method_missing

Methods included from LXC

#arch, #lxc

Methods included from Doctor

#doctor

Methods included from Actions

#create, #destroy, #down, #up

Constructor Details

#initialize(*args) ⇒ Node

Returns a new instance of Node.

Raises:



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/testlab/node.rb', line 54

def initialize(*args)
  @ui = TestLab.ui

  @ui.logger.debug { "Loading Node" }

  super(*args)

  self.config.merge!(:node => { :id => self.id.dup })

  @provider = self.provider.new(self.config, @ui)

  raise NodeError, "You must specify a provider class!" if self.provider.nil?

  @ui.logger.debug { "Node '#{self.id}' Loaded" }
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class TestLab::Node::MethodMissing

Class Method Details

.by_priority(priority) ⇒ Object



89
90
91
# File 'lib/testlab/node.rb', line 89

def by_priority(priority)
  self.all.select{ |n| n.priority == priority }
end

.priority_groupsObject



85
86
87
# File 'lib/testlab/node.rb', line 85

def priority_groups
  self.all.map(&:priority).sort.uniq.reverse
end

Instance Method Details

#config_dirObject



70
71
72
# File 'lib/testlab/node.rb', line 70

def config_dir
  self.labfile.config_dir
end

#domainObject



78
79
80
81
# File 'lib/testlab/node.rb', line 78

def domain
  self.config[:bind] ||= Hash.new
  self.config[:bind][:domain] ||= 'tld.invalid'
end

#repo_dirObject



74
75
76
# File 'lib/testlab/node.rb', line 74

def repo_dir
  self.labfile.repo_dir
end