Class: Moonshot::Tools::ASGRollout::HookExecEnvironment
- Inherits:
-
Object
- Object
- Moonshot::Tools::ASGRollout::HookExecEnvironment
- Defined in:
- lib/moonshot/tools/asg_rollout/hook_exec_environment.rb
Overview
This object is passed into hooks defined in the ASGRollout process, to give them access to instances and logging facilities.
Instance Attribute Summary collapse
-
#instance_id ⇒ Object
readonly
Returns the value of attribute instance_id.
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #ec2 ⇒ Object
- #ec2_instance ⇒ Object
- #exec(cmd) ⇒ Object
- #info(msg) ⇒ Object
-
#initialize(config, instance_id) ⇒ HookExecEnvironment
constructor
A new instance of HookExecEnvironment.
Constructor Details
#initialize(config, instance_id) ⇒ HookExecEnvironment
Returns a new instance of HookExecEnvironment.
12 13 14 15 16 |
# File 'lib/moonshot/tools/asg_rollout/hook_exec_environment.rb', line 12 def initialize(config, instance_id) @ilog = config.interactive_logger @command_builder = Moonshot::SSHCommandBuilder.new(config.ssh_config, instance_id) @instance_id = instance_id end |
Instance Attribute Details
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id.
10 11 12 |
# File 'lib/moonshot/tools/asg_rollout/hook_exec_environment.rb', line 10 def instance_id @instance_id end |
Instance Method Details
#debug(msg) ⇒ Object
33 34 35 |
# File 'lib/moonshot/tools/asg_rollout/hook_exec_environment.rb', line 33 def debug(msg) @ilog.debug(msg) end |
#ec2 ⇒ Object
24 25 26 |
# File 'lib/moonshot/tools/asg_rollout/hook_exec_environment.rb', line 24 def ec2 Aws::EC2::Client.new end |
#ec2_instance ⇒ Object
28 29 30 31 |
# File 'lib/moonshot/tools/asg_rollout/hook_exec_environment.rb', line 28 def ec2_instance res = Aws::EC2::Resource.new(client: ec2) res.instance(@instance_id) end |
#exec(cmd) ⇒ Object
18 19 20 21 22 |
# File 'lib/moonshot/tools/asg_rollout/hook_exec_environment.rb', line 18 def exec(cmd) cb = @command_builder.build(cmd) fe = SSHForkExecutor.new fe.run(cb.cmd) end |
#info(msg) ⇒ Object
37 38 39 |
# File 'lib/moonshot/tools/asg_rollout/hook_exec_environment.rb', line 37 def info(msg) @ilog.info(msg) end |