Class: Bosh::Bootstrap::Commander::RemoteScriptCommand
- Defined in:
- lib/bosh-bootstrap/commander/remote_script_command.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
verb e.g.
-
#description ⇒ Object
readonly
noun phrase, e.g.
-
#full_past_tense ⇒ Object
readonly
e.g.
-
#full_present_tense ⇒ Object
readonly
e.g.
-
#save_output_to_settings_key ⇒ Object
readonly
e.g.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
-
#settings ⇒ Object
readonly
settings manifest (result of script might get stored back).
-
#specific_run_as_user ⇒ Object
readonly
Optional:.
Instance Method Summary collapse
-
#as_file {|script_path| ... } ⇒ Object
Stores the script on the local filesystem in a temporary directory Returns path.
-
#initialize(command, description, script, full_present_tense = nil, full_past_tense = nil, options = {}) ⇒ RemoteScriptCommand
constructor
A new instance of RemoteScriptCommand.
-
#perform(server) ⇒ Object
Invoke this command to call back upon
server.run_script. -
#to_filename ⇒ Object
Provide a filename that represents this Command.
Constructor Details
#initialize(command, description, script, full_present_tense = nil, full_past_tense = nil, options = {}) ⇒ RemoteScriptCommand
Returns a new instance of RemoteScriptCommand.
18 19 20 21 22 23 24 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 18 def initialize(command, description, script, full_present_tense=nil, full_past_tense=nil, ={}) super(command, description, full_present_tense, full_past_tense) @script = script @specific_run_as_user = [:user] @settings = [:settings] @save_output_to_settings_key = [:save_output_to_settings_key] end |
Instance Attribute Details
#command ⇒ Object (readonly)
verb e.g. “install”
6 7 8 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 6 def command @command end |
#description ⇒ Object (readonly)
noun phrase, e.g. “packages”
7 8 9 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 7 def description @description end |
#full_past_tense ⇒ Object (readonly)
e.g. “installed packages”
11 12 13 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 11 def full_past_tense @full_past_tense end |
#full_present_tense ⇒ Object (readonly)
e.g. “installing packages”
10 11 12 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 10 def full_present_tense @full_present_tense end |
#save_output_to_settings_key ⇒ Object (readonly)
e.g. bosh.salted_password
16 17 18 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 16 def save_output_to_settings_key @save_output_to_settings_key end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
8 9 10 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 8 def script @script end |
#settings ⇒ Object (readonly)
settings manifest (result of script might get stored back)
15 16 17 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 15 def settings @settings end |
#specific_run_as_user ⇒ Object (readonly)
Optional:
14 15 16 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 14 def specific_run_as_user @specific_run_as_user end |
Instance Method Details
#as_file {|script_path| ... } ⇒ Object
Stores the script on the local filesystem in a temporary directory Returns path
39 40 41 42 43 44 45 46 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 39 def as_file(&block) tmpdir = ENV['TMPDIR'] || "/tmp" script_path = File.join(tmpdir, to_filename) File.open(script_path, "w") do |f| f << @script end yield script_path end |
#perform(server) ⇒ Object
Invoke this command to call back upon server.run_script
27 28 29 30 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 27 def perform(server) server.run_script(self, script, :user => specific_run_as_user, :settings => settings, :save_output_to_settings_key => save_output_to_settings_key) end |
#to_filename ⇒ Object
Provide a filename that represents this Command
33 34 35 |
# File 'lib/bosh-bootstrap/commander/remote_script_command.rb', line 33 def to_filename @to_filename ||= "#{command} #{description}".gsub(/\W+/, '_') end |