Class: Deltacloud::Drivers::Azure::AzureDriver
- Inherits:
-
BaseDriver
- Object
- BaseDriver
- Deltacloud::Drivers::Azure::AzureDriver
- Defined in:
- lib/deltacloud/drivers/azure/azure_driver.rb
Constant Summary
Constants inherited from BaseDriver
BaseDriver::MEMBER_SHOW_METHODS, BaseDriver::STATE_MACHINE_OPTS
Constants included from Deltacloud
Instance Method Summary collapse
- #blob_data(credentials, bucket_id, blob_id, opts = {}) {|WAZ::Blobs::Container.find(bucket_id)[blob_id].value| ... } ⇒ Object
-
#blob_metadata(credentials, opts = {}) ⇒ Object
-
Blob Metadada -.
-
-
#blobs(credentials, opts = {}) ⇒ Object
– Blobs –.
-
#buckets(credentials, opts = {}) ⇒ Object
– Buckets –.
-
#create_blob(credentials, bucket_id, blob_id, blob_data, opts = {}) ⇒ Object
– Create Blob –.
-
#create_bucket(credentials, name, opts = {}) ⇒ Object
– Create bucket –.
-
#delete_blob(credentials, bucket_id, blob_id, opts = {}) ⇒ Object
– Delete Blob –.
-
#delete_bucket(credentials, name, opts = {}) ⇒ Object
– Delete bucket –.
-
#update_blob_metadata(credentials, opts = {}) ⇒ Object
-
Update Blob Metadata -.
-
Methods inherited from BaseDriver
#address, #api_provider, #blob, #bucket, #catched_exceptions_list, #configured_providers, constraints, define_hardware_profile, define_instance_states, driver_name, feature, features, #filter_hardware_profiles, #filter_on, #find_hardware_profile, #firewall, #hardware_profile, #hardware_profiles, hardware_profiles, #has_capability?, #has_feature?, has_feature?, #image, #instance, #instance_actions_for, #instance_state_machine, instance_state_machine, #key, #name, #realm, #storage_snapshot, #storage_volume, #supported_collections, #valid_credentials?
Methods included from Deltacloud
[], config, configure, connect, database, default_frontend, drivers, enabled_frontends, frontend_required?, frontends, generate_routes, initialize_database, need_database?, new, require_frontend!
Methods included from CollectionMethods
#collection_exists?, #collection_names, #collections
Methods included from Exceptions
exception_from_status, exceptions, included, logger, #safely
Instance Method Details
#blob_data(credentials, bucket_id, blob_id, opts = {}) {|WAZ::Blobs::Container.find(bucket_id)[blob_id].value| ... } ⇒ Object
92 93 94 95 96 |
# File 'lib/deltacloud/drivers/azure/azure_driver.rb', line 92 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 = {}) ⇒ Object
- Blob Metadada -
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/deltacloud/drivers/azure/azure_driver.rb', line 133 def (credentials, opts = {}) azure_connect(credentials) = nil safely do blob = WAZ::Blobs::Container.find(opts['bucket'])[opts[:id]] return nil unless blob = blob. end = {} .inject({}){|result_hash, (k,v)| [k]=v if k.to_s.match(/x_ms_meta/i)} .gsub_keys(/x_ms_meta_/,'') end |
#blobs(credentials, opts = {}) ⇒ Object
– Blobs –
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/deltacloud/drivers/azure/azure_driver.rb', line 74 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 = {}) ⇒ Object
– Buckets –
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/deltacloud/drivers/azure/azure_driver.rb', line 29 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 = {}) ⇒ Object
– Create Blob –
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/deltacloud/drivers/azure/azure_driver.rb', line 101 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::(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 = {}) ⇒ Object
– Create bucket –
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/deltacloud/drivers/azure/azure_driver.rb', line 48 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 = {}) ⇒ Object
– Delete Blob –
122 123 124 125 126 127 128 |
# File 'lib/deltacloud/drivers/azure/azure_driver.rb', line 122 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 = {}) ⇒ Object
– Delete bucket –
64 65 66 67 68 69 |
# File 'lib/deltacloud/drivers/azure/azure_driver.rb', line 64 def delete_bucket(credentials, name, opts={}) azure_connect(credentials) safely do WAZ::Blobs::Container.find(name).destroy! end end |
#update_blob_metadata(credentials, opts = {}) ⇒ Object
- Update Blob Metadata -
149 150 151 152 153 154 155 156 157 |
# File 'lib/deltacloud/drivers/azure/azure_driver.rb', line 149 def (credentials, opts={}) azure_connect(credentials) = opts['meta_hash'] BlobHelper::(, "x-ms-meta-") safely do the_blob = WAZ::Blobs::Container.find(opts['bucket'])[opts[:id]] the_blob.() end end |