Class: Proxy::OpenSCAP::StorageFS

Inherits:
Storage
  • Object
show all
Defined in:
lib/smart_proxy_openscap/storage_fs.rb

Instance Method Summary collapse

Methods inherited from Storage

#initialize

Constructor Details

This class inherits a constructor from Proxy::OpenSCAP::Storage

Instance Method Details

#delete_arf_fileObject

Raises:



40
41
42
43
44
45
# File 'lib/smart_proxy_openscap/storage_fs.rb', line 40

def delete_arf_file
  path = "#{@path_to_dir}/#{@namespace}/#{@cname}/#{@id}"
  raise FileNotFound, "Can't find path #{path}" if !File.directory?(path) || File.zero?(path)
  FileUtils.rm_r path
  {:id => @id, :deleted => true}.to_json
end

#get_arf_html(digest) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/smart_proxy_openscap/storage_fs.rb', line 30

def get_arf_html(digest)
  OpenSCAP.oscap_init
  xml = get_arf_file(digest)[:xml]
  size = get_arf_file(digest)[:size]
  arf_object = OpenSCAP::DS::Arf.new(:content => xml, :path => 'arf.xml.bz2', :length => size)
  # @TODO: Drop this when support for 1.8.7 ends
  return arf_object.html if RUBY_VERSION.start_with? '1.8'
  arf_object.html.force_encoding('UTF-8')
end

#get_arf_xml(digest) ⇒ Object



26
27
28
# File 'lib/smart_proxy_openscap/storage_fs.rb', line 26

def get_arf_xml(digest)
  get_arf_file(digest)[:xml]
end

#move_corrupted(digest) ⇒ Object



21
22
23
24
# File 'lib/smart_proxy_openscap/storage_fs.rb', line 21

def move_corrupted(digest)
  source = "#{Proxy::OpenSCAP::Plugin.settings.spooldir}/#{@namespace}/#{@cname}/#{@id}/#{@date}"
  move "#{source}/#{digest}", StoreCorruptedError
end

#store_archive(data) ⇒ Object



5
6
7
# File 'lib/smart_proxy_openscap/storage_fs.rb', line 5

def store_archive(data)
  store(data, StoreReportError)
end

#store_corrupted(data) ⇒ Object



17
18
19
# File 'lib/smart_proxy_openscap/storage_fs.rb', line 17

def store_corrupted(data)
  store(data, StoreCorruptedError)
end

#store_failed(data) ⇒ Object



13
14
15
# File 'lib/smart_proxy_openscap/storage_fs.rb', line 13

def store_failed(data)
  store(data, StoreFailedError)
end

#store_spool(data) ⇒ Object



9
10
11
# File 'lib/smart_proxy_openscap/storage_fs.rb', line 9

def store_spool(data)
  store(data, StoreSpoolError)
end