Class: Azure::StorageAccounts
- Inherits:
-
Object
- Object
- Azure::StorageAccounts
- Includes:
- AzureUtility
- Defined in:
- lib/azure/service_management/storageaccount.rb
Instance Method Summary collapse
- #all ⇒ Object
- #clear_unattached ⇒ Object
- #create(params) ⇒ Object
- #delete(name) ⇒ Object
-
#exists?(name) ⇒ Boolean
first look up local cache if we have already loaded list.
-
#exists_on_cloud?(name) ⇒ Boolean
Look up on cloud and not local cache.
-
#initialize(connection) ⇒ StorageAccounts
constructor
A new instance of StorageAccounts.
-
#load(force_load = false) ⇒ Object
force_load should be true when there is something in local cache and we want to reload first call is always load.
Methods included from AzureUtility
#error_from_response_xml, #xml_content
Constructor Details
#initialize(connection) ⇒ StorageAccounts
Returns a new instance of StorageAccounts.
22 23 24 |
# File 'lib/azure/service_management/storageaccount.rb', line 22 def initialize(connection) @connection = connection end |
Instance Method Details
#all ⇒ Object
44 45 46 |
# File 'lib/azure/service_management/storageaccount.rb', line 44 def all load.values end |
#clear_unattached ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/azure/service_management/storageaccount.rb', line 72 def clear_unattached all.each do |storage| next unless storage.attached == false @connection.query_azure("storageaccounts/" + storage.name, "delete") end end |
#create(params) ⇒ Object
67 68 69 70 |
# File 'lib/azure/service_management/storageaccount.rb', line 67 def create(params) storage = StorageAccount.new(@connection) storage.create(params) end |
#delete(name) ⇒ Object
80 81 82 83 84 85 |
# File 'lib/azure/service_management/storageaccount.rb', line 80 def delete(name) if exists?(name) servicecall = "storageservices/" + name @connection.query_azure(servicecall, "delete") end end |
#exists?(name) ⇒ Boolean
first look up local cache if we have already loaded list.
49 50 51 52 53 |
# File 'lib/azure/service_management/storageaccount.rb', line 49 def exists?(name) return @azure_storage_accounts.key?(name) if @azure_storage_accounts exists_on_cloud?(name) end |
#exists_on_cloud?(name) ⇒ Boolean
Look up on cloud and not local cache
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/azure/service_management/storageaccount.rb', line 56 def exists_on_cloud?(name) ret_val = @connection.query_azure("storageservices/#{name}") error_code, = error_from_response_xml(ret_val) if ret_val if ret_val.nil? || error_code.length > 0 Chef::Log.warn "Unable to find storage account:" + + " : " + if ret_val false else true end end |
#load(force_load = false) ⇒ Object
force_load should be true when there is something in local cache and we want to reload first call is always load.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/azure/service_management/storageaccount.rb', line 28 def load(force_load = false) unless @azure_storage_accounts || force_load @azure_storage_accounts = begin azure_storage_accounts = {} responseXML = @connection.query_azure("storageservices") servicesXML = responseXML.css("StorageServices StorageService") servicesXML.each do |serviceXML| storage = StorageAccount.new(@connection).parse(serviceXML) azure_storage_accounts[storage.name] = storage end azure_storage_accounts end end @azure_storage_accounts end |