Class/Module Index [+]

Quicksearch

Deltacloud::Drivers::Azure::AzureDriver

Public Instance Methods

blob_data(credentials, bucket_id, blob_id, opts={}) click to toggle source
# File lib/deltacloud/drivers/azure/azure_driver.rb, line 96
def blob_data(credentials, bucket_id, blob_id, opts={})
  azure_connect(credentials)
  # WAZ get blob data methods cant accept blocks for 'streaming'... FIXME
    yield WAZ::Blobs::Container.find(bucket_id)[blob_id].value
end
blob_metadata(credentials, opts = {}) click to toggle source

-

Blob Metadada

-

# File lib/deltacloud/drivers/azure/azure_driver.rb, line 137
def blob_metadata(credentials, opts = {})
  azure_connect(credentials)
  all_meta = nil
  safely do
    blob = WAZ::Blobs::Container.find(opts['bucket'])[opts[:id]]
    return nil unless blob
    all_meta = blob.metadata
  end
  user_meta = {}
  all_meta.inject({}){|result_hash, (k,v)| user_meta[k]=v if k.to_s.match(/x_ms_meta/)}
  user_meta.gsub_keys(/x_ms_meta_/,'')
end
blobs(credentials, opts={}) click to toggle source
# File lib/deltacloud/drivers/azure/azure_driver.rb, line 78
def blobs(credentials, opts={})
  blob_list = []
  azure_connect(credentials)
  safely do
    the_bucket = WAZ::Blobs::Container.find(opts['bucket'])
    if(opts[:id])
      the_blob = the_bucket[opts[:id]]
      blob_list << convert_blob(the_blob) unless the_blob.nil?
    else
      the_bucket.blobs.each do |waz_blob|
        blob_list << convert_blob(waz_blob)
      end #each.do
    end #if
  end #safely do
  blob_list = filter_on(blob_list, :id, opts)
  blob_list
end
buckets(credentials, opts={}) click to toggle source
# File lib/deltacloud/drivers/azure/azure_driver.rb, line 33
def buckets(credentials, opts={})
  buckets = []
  azure_connect(credentials)
  safely do
    unless (opts[:id].nil?)
      waz_bucket =  WAZ::Blobs::Container.find(opts[:id])
      buckets << convert_container(waz_bucket)
    else
      WAZ::Blobs::Container.list.each do |waz_container|
        buckets << Bucket.new({:id =>waz_container.name, :name => waz_container.name})
      end #container.list.each
    end #unless
  end #safely
  buckets = filter_on(buckets, :id, opts)
end
create_blob(credentials, bucket_id, blob_id, blob_data, opts={}) click to toggle source
# File lib/deltacloud/drivers/azure/azure_driver.rb, line 105
def create_blob(credentials, bucket_id, blob_id, blob_data, opts={})
  azure_connect(credentials)
  #insert azure-specific header for user metadata ... x-ms-meta-kEY = VALUE
  BlobHelper::rename_metadata_headers(opts, "x-ms-meta-")
  safely do
    #get a handle to the bucket in order to put there
    the_bucket = WAZ::Blobs::Container.find(bucket_id)
    the_bucket.store(blob_id, blob_data[:tempfile], blob_data[:type], opts)
  end
  Blob.new( { :id => blob_id,
              :bucket => bucket_id,
              :content_lengh => blob_data[:tempfile].length,
              :content_type => blob_data[:type],
              :last_modified => '',
              :user_metadata => opts.gsub_keys(/x-ms-meta-/,'')
          } )
end
create_bucket(credentials, name, opts={}) click to toggle source
# File lib/deltacloud/drivers/azure/azure_driver.rb, line 52
def create_bucket(credentials, name, opts={})
  #for whatever reason, bucket names MUST be lowercase...
  #http://msdn.microsoft.com/en-us/library/dd135715.aspx
  name.downcase!
  bucket = nil
  azure_connect(credentials)
  safely do
    waz_container = WAZ::Blobs::Container.create(name)
    bucket = convert_container(waz_container)
  end
  bucket
end
delete_blob(credentials, bucket_id, blob_id, opts={}) click to toggle source
# File lib/deltacloud/drivers/azure/azure_driver.rb, line 126
def delete_blob(credentials, bucket_id, blob_id, opts={})
  azure_connect(credentials)
  #get a handle to bucket and blob, and destroy!
  the_bucket = WAZ::Blobs::Container.find(bucket_id)
  the_blob = the_bucket[blob_id]
  the_blob.destroy!
end
delete_bucket(credentials, name, opts={}) click to toggle source
# File lib/deltacloud/drivers/azure/azure_driver.rb, line 68
def delete_bucket(credentials, name, opts={})
  azure_connect(credentials)
  safely do
    WAZ::Blobs::Container.find(name).destroy!
  end
end
supported_collections() click to toggle source
# File lib/deltacloud/drivers/azure/azure_driver.rb, line 27
def supported_collections; [:buckets]
end
update_blob_metadata(credentials, opts={}) click to toggle source

-

Update Blob Metadata

-

# File lib/deltacloud/drivers/azure/azure_driver.rb, line 153
def update_blob_metadata(credentials, opts={})
  azure_connect(credentials)
  meta_hash = opts['meta_hash']
  BlobHelper::rename_metadata_headers(meta_hash, "x-ms-meta-")
  safely do
    the_blob = WAZ::Blobs::Container.find(opts['bucket'])[opts[:id]]
    the_blob.put_metadata!(meta_hash)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.