Class: Dcmgr::Drivers::SnapshotStorage

Inherits:
Object
  • Object
show all
Includes:
Helpers::CliHelper
Defined in:
lib/dcmgr/drivers/snapshot_storage.rb

Direct Known Subclasses

IIJGIOStorage, S3Storage

Instance Method Summary collapse

Methods included from Helpers::CliHelper

#sh, #tryagain

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

#checkObject



27
28
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 27

def check
end

#deleteObject



24
25
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 24

def delete
end

#downloadObject



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.expand_path('../../../../',__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
    message = 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
    error_message = ["Snapshot execute error: ",cmd, code, message, bucket_name, request_id, host_id].join(',')
    raise error_message
  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

#uploadObject



21
22
# File 'lib/dcmgr/drivers/snapshot_storage.rb', line 21

def upload
end