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 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 16 def initialize(builder, script, name: nil, client: nil) @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.
38 39 40 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 38 def client @client end |
#name ⇒ Object (readonly, protected)
Returns the value of attribute name.
38 39 40 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 38 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.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/osctl/image/operations/builder/runscript_from_string.rb', line 24 def execute tmp = Tempfile.new(name, '/tmp') File.chmod(0755, tmp.path) tmp.write(script) tmp.close begin OsCtldClient.new.runscript(builder.ctid, tmp.path) ensure tmp.unlink end end |