Class: Jellyfish::Fog::Azure::Storage

Inherits:
Provisioner
  • Object
show all
Defined in:
lib/jellyfish_fog_azure/storage.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



23
24
25
# File 'lib/jellyfish_fog_azure/storage.rb', line 23

def attributes
  order_item.payload_response
end

#connectionObject



27
28
29
# File 'lib/jellyfish_fog_azure/storage.rb', line 27

def connection
  Connection.new.connect
end

#handle_errorsObject



31
32
33
34
35
# File 'lib/jellyfish_fog_azure/storage.rb', line 31

def handle_errors
  yield
rescue Excon::Errors::BadRequest, Excon::Errors::Forbidden => e
  raise e, 'Bad request. Check for valid credentials and proper permissions.', e.backtrace
end

#provisionObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/jellyfish_fog_azure/storage.rb', line 5

def provision
  details = order_item.answers
  storage = nil
  name = "storage#{order_item.uuid[0..7]}".delete! '-'
  handle_errors do
    storage = connection.storage_accounts.create(name: name, location: details[:location])
  end
  order_item.provision_status = :ok
  order_item.payload_response = storage.attributes
end

#retireObject



16
17
18
19
20
21
# File 'lib/jellyfish_fog_azure/storage.rb', line 16

def retire
  handle_errors do
    connection.(attributes[:name])
  end
  order_item.provision_status = :retired
end