Class: Dcmgr::Drivers::SnapshotStorage
- Inherits:
-
Object
- Object
- Dcmgr::Drivers::SnapshotStorage
- Includes:
- Helpers::CliHelper
- Defined in:
- lib/dcmgr/drivers/snapshot_storage.rb
Direct Known Subclasses
Instance Method Summary collapse
- #check ⇒ Object
- #delete ⇒ Object
- #download ⇒ Object
- #execute(cmd, args) ⇒ Object
-
#initialize(bucket) ⇒ SnapshotStorage
constructor
A new instance of SnapshotStorage.
- #setenv(key, value) ⇒ Object
- #upload ⇒ Object
Methods included from Helpers::CliHelper
Constructor Details
#initialize(bucket) ⇒ SnapshotStorage
Returns a new instance of SnapshotStorage.
9 10 11 12 |
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 9 def initialize(bucket) @env = [] @bucket = bucket end |
Instance Method Details
#check ⇒ Object
27 28 |
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 27 def check end |
#delete ⇒ Object
24 25 |
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 24 def delete end |
#download ⇒ Object
18 19 |
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 18 def download end |
#execute(cmd, args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 30 def execute(cmd, args) script_root_path = File.join(File.('../../../../',__FILE__), 'script') script = File.join(script_root_path, 'storage_service') cmd = "/usr/bin/env #{@env.join(' ')} %s " + cmd args = [script] + args res = sh(cmd, args) if res[:stdout] != '' doc = REXML::Document.new res[:stdout] code = REXML::XPath.match( doc, "//Error/Code/text()" ).to_s = REXML::XPath.match( doc, "//Error/Message/text()" ).to_s bucket_name = REXML::XPath.match( doc, "//Error/BucketName/text()" ).to_s request_id = REXML::XPath.match( doc, "//Error/RequestId/text()" ).to_s host_id = REXML::XPath.match( doc, "//Error/HostId/text()" ).to_s = ["Snapshot execute error: ",cmd, code, , bucket_name, request_id, host_id].join(',') raise else res end end |
#setenv(key, value) ⇒ Object
14 15 16 |
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 14 def setenv(key, value) @env.push("#{key}=#{value}") end |
#upload ⇒ Object
21 22 |
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 21 def upload end |