Class: OsCtl::Image::Operations::Builder::RunscriptFromString
- Inherits:
-
OsCtl::Image::Operations::Base
- Object
- OsCtl::Image::Operations::Base
- OsCtl::Image::Operations::Builder::RunscriptFromString
- Defined in:
- lib/osctl/image/operations/builder/runscript_from_string.rb
Instance Attribute Summary collapse
- #builder ⇒ Builder readonly
-
#client ⇒ Object
readonly
protected
Returns the value of attribute client.
-
#name ⇒ Object
readonly
protected
Returns the value of attribute name.
- #script ⇒ String readonly
Instance Method Summary collapse
-
#execute ⇒ Integer
Exit status.
-
#initialize(builder, script, name: nil, client: nil) ⇒ RunscriptFromString
constructor
A new instance of RunscriptFromString.
Methods inherited from OsCtl::Image::Operations::Base
Constructor Details
#initialize(builder, script, name: nil, client: nil) ⇒ RunscriptFromString
Returns a new instance of RunscriptFromString.
16 17 18 19 20 21 22 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 16 def initialize(builder, script, name: nil, client: nil) super() @builder = builder @script = script @name = name || 'osctl-image-runscript' @client = client || OsCtldClient.new end |
Instance Attribute Details
#builder ⇒ Builder (readonly)
7 8 9 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 7 def builder @builder end |
#client ⇒ Object (readonly, protected)
Returns the value of attribute client.
40 41 42 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 40 def client @client end |
#name ⇒ Object (readonly, protected)
Returns the value of attribute name.
40 41 42 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 40 def name @name end |
#script ⇒ String (readonly)
10 11 12 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 10 def script @script end |
Instance Method Details
#execute ⇒ Integer
Returns exit status.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 25 def execute tmp = Tempfile.new(name, '/tmp') File.chmod(0o755, tmp.path) tmp.write(script) tmp.close begin OsCtldClient.new.runscript(builder.ctid, tmp.path) ensure tmp.unlink end end |