Parent

Class/Module Index [+]

Quicksearch

Fog::Storage::IBM::Mock

Public Class Methods

data() click to toggle source
# File lib/fog/ibm/storage.rb, line 51
def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :volumes      => {},
    }
  end
end
new(options={}) click to toggle source
# File lib/fog/ibm/storage.rb, line 72
def initialize(options={})
  @ibm_username = options[:ibm_username]
  @ibm_password = options[:ibm_password]
  @data = self.class.data[@ibm_username]
end
reset() click to toggle source
# File lib/fog/ibm/storage.rb, line 59
def self.reset
  @data = nil
end

Public Instance Methods

create_volume(name, offering_id, format, location_id, size) click to toggle source
# File lib/fog/ibm/requests/storage/create_volume.rb, line 47
def create_volume(name, offering_id, format, location_id, size)
  volume          = Fog::IBM::Mock.create_volume(name, offering_id, format, location_id, size)
  self.data[:volumes][volume['id']] = volume
  response        = Excon::Response.new
  response.status = 200
  response.body   = format_create_volume_response_for(volume['id'])
  response
end
data() click to toggle source
# File lib/fog/ibm/storage.rb, line 63
def data
  self.class.data[@ibm_username]
end
delete_volume(volume_id) click to toggle source
# File lib/fog/ibm/requests/storage/delete_volume.rb, line 27
def delete_volume(volume_id)
  response = Excon::Response.new
  if volume_exists? volume_id
    self.data[:volumes].delete volume_id
    response.status = 200
    response.body = {"success"=>true}
  else
    response.status = 404
  end
  response
end
format_create_volume_response_for(volume_id) click to toggle source

The create_volume response doesn't contain ioPrice either

# File lib/fog/ibm/requests/storage/create_volume.rb, line 57
def format_create_volume_response_for(volume_id)
  # If we aren't attached/ready, make us ready
  ready_volume(volume_id) unless volume_attached? volume_id
  self.data[:volumes][volume_id].reject { |k,v| k == 'ioPrice' }
end
format_get_volume_response_for(volume_id) click to toggle source

get_volume response doesn't contain instanceId

# File lib/fog/ibm/requests/storage/get_volume.rb, line 39
def format_get_volume_response_for(volume_id)
  # If we aren't attached/ready, make us ready
  ready_volume(volume_id) unless volume_attached? volume_id
  self.data[:volumes][volume_id].reject { |k,v| k == 'instanceId' }
end
format_list_volumes_response() click to toggle source

The list_volumes response doesn't contain ioPrice

# File lib/fog/ibm/requests/storage/get_volume.rb, line 46
def format_list_volumes_response
  self.data[:volumes].values.dup.map { |volume| volume.reject { |k,v| k == 'ioPrice'} }
end
get_volume(volume_id) click to toggle source

For whatever reason, get_volume returns different data than an entry in list_volumes

# File lib/fog/ibm/requests/storage/get_volume.rb, line 27
def get_volume(volume_id)
  response = Excon::Response.new
  if volume_exists? volume_id
    response.status = 200
    response.body   = format_get_volume_response_for(volume_id)
  else
    response.status = 404
  end
  response
end
list_offerings() click to toggle source
# File lib/fog/ibm/requests/storage/list_offerings.rb, line 40
def list_offerings
  response = Excon::Response.new
  response.status = 200
  response.body = {"volumes"=>
      [{"name"=>"Small",
        "price"=>
         {"pricePerQuantity"=>1,
          "effectiveDate"=>-1,
          "rate"=>0.0384,
          "countryCode"=>"897",
          "unitOfMeasure"=>"UHR",
          "currencyCode"=>"USD"},
        "location"=>"61",
        "id"=>"20001208",
        "formats"=>
         [{"label"=>"ext3", "id"=>"EXT3"}, {"label"=>"raw", "id"=>"RAW"}],
        "capacity"=>256},
       {"name"=>"Small",
        "price"=>
         {"pricePerQuantity"=>1,
          "effectiveDate"=>-1,
          "rate"=>0.0384,
          "countryCode"=>"897",
          "unitOfMeasure"=>"UHR",
          "currencyCode"=>"USD"},
        "location"=>"141",
        "id"=>"20001208",
        "formats"=>
         [{"label"=>"ext3", "id"=>"EXT3"}, {"label"=>"raw", "id"=>"RAW"}],
        "capacity"=>256}]},
  response
end
list_volumes() click to toggle source
# File lib/fog/ibm/requests/storage/list_volumes.rb, line 37
def list_volumes
  response = Excon::Response.new
  response.status = 200
  response.body = { 'volumes' => format_list_volumes_response }
  response
end
ready_volume(volume_id) click to toggle source

Sets volume status to Detached if it's not already set, and or attached

# File lib/fog/ibm/requests/storage/get_volume.rb, line 64
def ready_volume(volume_id)
  # If not ready, make ready
  self.data[:volumes][volume_id]['state'] = 4
end
reset_data() click to toggle source
# File lib/fog/ibm/storage.rb, line 67
def reset_data
  self.class.data.delete(@ibm_username)
  @data = self.class.data[@ibm_username]
end
volume_attached?(volume_id) click to toggle source
# File lib/fog/ibm/requests/storage/get_volume.rb, line 59
def volume_attached?(volume_id)
  self.data[:volumes][volume_id]['instanceId'] != "0"
end
volume_exists?(volume_id) click to toggle source
# File lib/fog/ibm/requests/storage/get_volume.rb, line 50
def volume_exists?(volume_id)
  self.data[:volumes].key? volume_id
end
volume_ready?(volume_id) click to toggle source

Checks if an volume is Active

# File lib/fog/ibm/requests/storage/get_volume.rb, line 55
def volume_ready?(volume_id)
  self.data[:volumes][volume_id]['state'] == 4
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.