Method: Fog::Compute::IBM::Mock#list_addresses

Defined in:
lib/fog/ibm/requests/compute/list_addresses.rb

#list_addressesObject

[View source]

35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/ibm/requests/compute/list_addresses.rb', line 35

def list_addresses
  # Loop through addresses and update states and values if they aren't set
  self.data[:addresses].values.each do |address|
    address['state']    = 2 if address['state'] == 0
    address['ip']       = Fog::IBM::Mock.ip_address if address['ip'].empty?
    address['mode']     = 0 unless address.key? 'mode'
    address['hostname'] = Fog::IBM::Mock.hostname unless address.key? 'hostname'
    address['type']     = 1 unless address.key? 'type'
  end
  response        = Excon::Response.new
  response.status = 200
  response.body   = { 'addresses' => self.data[:addresses].values }
  response
end