Class: Fog::Compute::Fifo::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/fifo/compute.rb,
lib/fog/fifo/requests/compute/get_vm.rb,
lib/fog/fifo/requests/compute/stop_vm.rb,
lib/fog/fifo/requests/compute/list_vms.rb,
lib/fog/fifo/requests/compute/start_vm.rb,
lib/fog/fifo/requests/compute/create_vm.rb,
lib/fog/fifo/requests/compute/delete_vm.rb,
lib/fog/fifo/requests/compute/reboot_vm.rb,
lib/fog/fifo/requests/compute/get_dataset.rb,
lib/fog/fifo/requests/compute/get_iprange.rb,
lib/fog/fifo/requests/compute/get_network.rb,
lib/fog/fifo/requests/compute/get_package.rb,
lib/fog/fifo/requests/compute/list_datasets.rb,
lib/fog/fifo/requests/compute/list_ipranges.rb,
lib/fog/fifo/requests/compute/list_networks.rb,
lib/fog/fifo/requests/compute/list_packages.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



71
72
73
74
# File 'lib/fog/fifo/compute.rb', line 71

def initialize(options = {})
  @fifo_username = options[:fifo_username] || Fog.credentials[:fifo_username]
  @fifo_password = options[:fifo_password] || Fog.credentials[:fifo_password]
end

Class Method Details

.dataObject



61
62
63
64
65
# File 'lib/fog/fifo/compute.rb', line 61

def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {}
  end
end

Instance Method Details

#dataObject



67
68
69
# File 'lib/fog/fifo/compute.rb', line 67

def data
  self.class.data
end

#delete_vm(uuid) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/fifo/requests/compute/delete_vm.rb', line 6

def delete_vm(uuid)
  if vm = self.data[:vms][uuid]
    res = Excon::Response.new
    res.status = 200
    res
  else
    raise Excon::Errors::NotFound, "Not Found"
  end
end

#get_dataset(id) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/fifo/requests/compute/get_dataset.rb', line 6

def get_dataset(id)
  if ds = self.data[:datasets][id]
    res = Excon::Response.new
    res.status = 200
    res.body = ds
  else
    raise Excon::Errors::NotFound
  end
end

#get_iprange(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/fifo/requests/compute/get_iprange.rb', line 6

def get_iprange(id)
  if pkg = self.data[:iprange][id]
    response = Excon::Response.new
    response.body = pkg
    response.status = 200
    response
  else
    raise Excon::Errors::NotFound
  end
end

#get_network(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/fifo/requests/compute/get_network.rb', line 6

def get_network(id)
  if pkg = self.data[:networks][id]
    response = Excon::Response.new
    response.body = pkg
    response.status = 200
    response
  else
    raise Excon::Errors::NotFound
  end
end

#get_package(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/fifo/requests/compute/get_package.rb', line 6

def get_package(id)
  if pkg = self.data[:packages][id]
    response = Excon::Response.new
    response.body = pkg
    response.status = 200
    response
  else
    raise Excon::Errors::NotFound
  end
end

#get_vm(uuid) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/fifo/requests/compute/get_vm.rb', line 6

def get_vm(uuid)
  if vm = self.data[:vms][uuid]
    res = Excon::Response.new
    res.status = 200
    res.body = vm
    res
  else
    raise Excon::Errors::NotFound, "Not Found"
  end
end

#list_datasetsObject



6
7
8
9
10
11
# File 'lib/fog/fifo/requests/compute/list_datasets.rb', line 6

def list_datasets
  res = Excon::Response.new
  res.status = 200
  res.body = self.data[:datasets].values
  res
end

#list_iprangesObject



6
7
8
9
10
11
# File 'lib/fog/fifo/requests/compute/list_ipranges.rb', line 6

def list_ipranges
  res = Excon::Response.new
  res.status = 200
  res.body = self.data[:ipranges].values
  res
end

#list_networksObject



6
7
8
9
10
11
# File 'lib/fog/fifo/requests/compute/list_networks.rb', line 6

def list_networks
  res = Excon::Response.new
  res.status = 200
  res.body = self.data[:networks].values
  res
end

#list_packagesObject



6
7
8
9
10
11
# File 'lib/fog/fifo/requests/compute/list_packages.rb', line 6

def list_packages
  response = Excon::Response.new()
  response.status = 200
  response.body = self.data[:packages].values
  response
end

#list_vmObject



6
7
8
9
10
11
# File 'lib/fog/fifo/requests/compute/list_vms.rb', line 6

def list_vm
  res = Excon::Response.new
  res.status = 200
  res.body = self.data[:machines].values
  res
end

#remoot_vm(uuid) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/fifo/requests/compute/reboot_vm.rb', line 6

def remoot_vm(uuid)
  if vm = self.data[:vms][uuid]
    res = Excon::Response.new
    res.status = 200
    res
  else
    raise Excon::Errors::NotFound, "Not Found"
  end
end

#request(opts) ⇒ Object



76
77
78
# File 'lib/fog/fifo/compute.rb', line 76

def request(opts)
  raise "Not Implemented"
end

#start_vm(uuid) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/fifo/requests/compute/start_vm.rb', line 6

def start_vm(uuid)
  if vm = self.data[:vms][uuid]
    res = Excon::Response.new
    res.status = 200
    res.body = vm
    res
  else
    raise Excon::Errors::NotFound, "Not Found"
  end
end

#stop_vm(uuid) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/fifo/requests/compute/stop_vm.rb', line 6

def stop_vm(uuid)
  if vm = self.data[:vms][uuid]
    res = Excon::Response.new
    res.status = 200
    res.body = vm
    res
  else
    raise Excon::Errors::NotFound, "Not Found"
  end
end