Class: CemAcpt::Platform::Base
- Inherits:
-
Object
- Object
- CemAcpt::Platform::Base
- Includes:
- Logging
- Defined in:
- lib/cem_acpt/platform/base.rb
Overview
Base class for all platform classes. This class provides an API for interacting with the underlying platform.
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#image_name ⇒ Object
readonly
Returns the value of attribute image_name.
-
#local_port ⇒ Object
readonly
Returns the value of attribute local_port.
-
#node_name ⇒ Object
readonly
Returns the value of attribute node_name.
-
#test_data ⇒ Object
readonly
Returns the value of attribute test_data.
Class Method Summary collapse
-
.apply_manifest(_instance_name, _manifest, _opts = {}) ⇒ Object
Applies a Puppet manifest on the given node.
-
.command_provider ⇒ Object
Returns a command provider specified by the Platform module of the specific platform.
-
.run_shell(_instance_name, _cmd, _opts = {}) ⇒ Object
Runs a shell command on the given node.
Instance Method Summary collapse
-
#destroy ⇒ Object
Destroy a node.
-
#image_name_builder(conf, tdata) ⇒ Object
Builds an image name if the config specifies to use the image name builder.
-
#initialize(conf, single_test_data, local_port) ⇒ Base
constructor
A new instance of Base.
-
#install_puppet_module_package(_module_pkg_path, _remote_path) ⇒ Object
Upload and install a Puppet module package on the node.
-
#node ⇒ Object
Node should return a hash of all data about a created node.
-
#provision ⇒ Object
Provision a node.
-
#random_node_name ⇒ Object
Generates a random node name.
-
#ready? ⇒ Boolean
Tests to see if a node is ready to accept connections from the test suite.
Methods included from Logging
current_log_config, #current_log_config, current_log_format, current_log_level, #current_log_level, included, #logger, new_log_config, #new_log_config, new_log_formatter, new_log_level, #new_log_level
Constructor Details
#initialize(conf, single_test_data, local_port) ⇒ Base
Returns a new instance of Base.
18 19 20 21 22 23 24 25 26 |
# File 'lib/cem_acpt/platform/base.rb', line 18 def initialize(conf, single_test_data, local_port) raise ArgumentError, 'single_test_data must be a Hash' unless single_test_data.is_a?(Hash) @config = conf.get('node_data') @test_data = single_test_data @local_port = local_port @node_name = @test_data[:node_name] || random_node_name @image_name = conf.has?('image_name_builder') ? image_name_builder(conf, single_test_data) : @test_data[:image_name] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/cem_acpt/platform/base.rb', line 13 def config @config end |
#image_name ⇒ Object (readonly)
Returns the value of attribute image_name.
13 14 15 |
# File 'lib/cem_acpt/platform/base.rb', line 13 def image_name @image_name end |
#local_port ⇒ Object (readonly)
Returns the value of attribute local_port.
13 14 15 |
# File 'lib/cem_acpt/platform/base.rb', line 13 def local_port @local_port end |
#node_name ⇒ Object (readonly)
Returns the value of attribute node_name.
13 14 15 |
# File 'lib/cem_acpt/platform/base.rb', line 13 def node_name @node_name end |
#test_data ⇒ Object (readonly)
Returns the value of attribute test_data.
13 14 15 |
# File 'lib/cem_acpt/platform/base.rb', line 13 def test_data @test_data end |
Class Method Details
.apply_manifest(_instance_name, _manifest, _opts = {}) ⇒ Object
Applies a Puppet manifest on the given node.
69 70 71 |
# File 'lib/cem_acpt/platform/base.rb', line 69 def self.apply_manifest(_instance_name, _manifest, _opts = {}) raise NotImplementedError, '#apply_manifest must be implemented by subclass' end |
.command_provider ⇒ Object
Returns a command provider specified by the Platform module of the specific platform.
64 65 66 |
# File 'lib/cem_acpt/platform/base.rb', line 64 def self.command_provider raise NotImplementedError, '#command_provider must be implemented by subclass' end |
.run_shell(_instance_name, _cmd, _opts = {}) ⇒ Object
Runs a shell command on the given node.
74 75 76 |
# File 'lib/cem_acpt/platform/base.rb', line 74 def self.run_shell(_instance_name, _cmd, _opts = {}) raise NotImplementedError, '#run_shell must be implemented by subclass' end |
Instance Method Details
#destroy ⇒ Object
Destroy a node. Will be called asynchronously.
39 40 41 |
# File 'lib/cem_acpt/platform/base.rb', line 39 def destroy raise NotImplementedError, '#destroy must be implemented by subclass' end |
#image_name_builder(conf, tdata) ⇒ Object
Builds an image name if the config specifies to use the image name builder.
59 60 61 |
# File 'lib/cem_acpt/platform/base.rb', line 59 def image_name_builder(conf, tdata) @image_name_builder ||= CemAcpt::ImageNameBuilder.new(conf).build(tdata) end |
#install_puppet_module_package(_module_pkg_path, _remote_path) ⇒ Object
Upload and install a Puppet module package on the node. Blocking call.
49 50 51 |
# File 'lib/cem_acpt/platform/base.rb', line 49 def install_puppet_module_package(_module_pkg_path, _remote_path) raise NotImplementedError, '#install_puppet_module_package must be implemented by subclass' end |
#node ⇒ Object
Node should return a hash of all data about a created node.
29 30 31 |
# File 'lib/cem_acpt/platform/base.rb', line 29 def node raise NotImplementedError, '#node must be implemented by subclass' end |
#provision ⇒ Object
Provision a node. Will be called asynchronously.
34 35 36 |
# File 'lib/cem_acpt/platform/base.rb', line 34 def provision raise NotImplementedError, '#provision must be implemented by subclass' end |
#random_node_name ⇒ Object
Generates a random node name.
54 55 56 |
# File 'lib/cem_acpt/platform/base.rb', line 54 def random_node_name "acpt-test-#{SecureRandom.hex(10)}" end |
#ready? ⇒ Boolean
Tests to see if a node is ready to accept connections from the test suite.
44 45 46 |
# File 'lib/cem_acpt/platform/base.rb', line 44 def ready? raise NotImplementedError, '#ready? must be implemented by subclass' end |