Class: HP::Cloud::ObjectStore

Inherits:
Resource
  • Object
show all
Defined in:
lib/hpcloud/object_store.rb

Instance Attribute Summary

Attributes inherited from Resource

#container, #cstatus, #destination, #fname, #ftype, #path, #public, #public_url, #readers, #restart, #writers

Instance Method Summary collapse

Methods inherited from Resource

#close, #container_head, #copy, #copy_all, #copy_file, #get_destination, #get_mime_type, #grant, #head, #initialize, #isDirectory, #isFile, #isLocal, #isMulti, #isObject, #isRemote, #is_object_store?, #is_shared?, #is_valid?, #not_implemented, #open, #parse, #read, #remove, #revoke, #set_destination, #set_error, #set_mime_type, #set_restart, #tempurl, #to_hash, #valid_source, #write

Constructor Details

This class inherits a constructor from HP::Cloud::Resource

Instance Method Details

#foreach(&block) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/hpcloud/object_store.rb', line 29

def foreach(&block)
  if @@limit.nil?
    @@limit = Config.new.get_i(:storage_page_length, 10000)
  end
  total = 0
  count = 0
  marker = nil
  begin
    options = { :limit => @@limit, :marker => marker}
    begin
      result = @storage.get_containers(options)
    rescue NoMethodError => e
      result = @storage.directories.each { |container|
        yield ResourceFactory.create(@storage, ':' + container.key)
      }
      return
    end
    total = result.headers['X-Account-Container-Count'].to_i
	  lode = result.body.length
	  count += lode
    result.body.each { |x|
      name = x['name']
      res = ResourceFactory.create(@storage, ':' + name)
      res.size = x['bytes']
      res.count = x['count']
      yield res
      marker = name
    }
    break if lode < @@limit
  end until count >= total
end

#is_container?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/hpcloud/object_store.rb', line 61

def is_container?
  true # container of containers
end

#valid_destination(source) ⇒ Object



25
26
27
# File 'lib/hpcloud/object_store.rb', line 25

def valid_destination(source)
  return false
end