Class: Fog::Compute::CloudAtCost::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/cloudatcost/requests/list_tasks.rb,
lib/fog/cloudatcost/compute.rb,
lib/fog/cloudatcost/requests/reset.rb,
lib/fog/cloudatcost/requests/console.rb,
lib/fog/cloudatcost/requests/power_on.rb,
lib/fog/cloudatcost/requests/run_mode.rb,
lib/fog/cloudatcost/requests/power_off.rb,
lib/fog/cloudatcost/requests/reverse_dns.rb,
lib/fog/cloudatcost/requests/list_servers.rb,
lib/fog/cloudatcost/requests/create_server.rb,
lib/fog/cloudatcost/requests/delete_server.rb,
lib/fog/cloudatcost/requests/rename_server.rb,
lib/fog/cloudatcost/requests/list_templates.rb

Overview

noinspection RubyStringKeysInHashInspection

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



38
39
40
41
# File 'lib/fog/cloudatcost/compute.rb', line 38

def initialize(options = {})
  @api_key = options[:api_key]
  @email = options[:email]
end

Instance Method Details

#console(_id, _hostname) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/cloudatcost/requests/console.rb', line 19

def console(_id, _hostname)
  console_url =
    'http:\/\/panel.cloudatcost.com:12345\/console.html?servername=123456&hostname=1.1.1.1'\
    '&sshkey=123456&sha1hash=aBcDeFgG'
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'server_id'  => Fog::Mock.random_numbers(1).to_i,
    'api'        => 'v1',
    'status'     => 'ok',
    'console'    => console_url,
    'time'       => 12_312_323
  }
  response
end

#create_server(_cpu, _ram, _storage, _template_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/cloudatcost/requests/create_server.rb', line 19

def create_server(_cpu, _ram, _storage, _template_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'result'     => 'successful',
    'api'        => 'v1',
    'action'     => 'build',
    'status'     => 'ok',
    'taskid'     => 123_123_123_123,
    'time'       => 12_312_323
  }
  response
end

#delete_server(_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/cloudatcost/requests/delete_server.rb', line 19

def delete_server(_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'result'     => 'successful',
    'api'        => 'v1',
    'action'     => 'delete',
    'status'     => 'ok',
    'taskid'     => 123_123_123_123,
    'time'       => 12_312_323
  }
  response
end

#list_serversObject



18
19
20
21
22
23
24
25
26
# File 'lib/fog/cloudatcost/requests/list_servers.rb', line 18

def list_servers
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'status' => 'OK',
    'servers' => data[:data]
  }
  response
end

#list_tasksObject



18
19
20
21
22
23
24
25
26
# File 'lib/fog/cloudatcost/requests/list_tasks.rb', line 18

def list_tasks
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'status' => 'OK',
    'servers' => data[:data]
  }
  response
end

#list_templatesObject



18
19
20
21
22
23
24
25
26
# File 'lib/fog/cloudatcost/requests/list_templates.rb', line 18

def list_templates
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'status' => 'OK',
    'servers' => data[:data]
  }
  response
end

#power_off(_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/cloudatcost/requests/power_off.rb', line 19

def power_off(_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'server_id' => Fog::Mock.random_numbers(1).to_i,
    'api'        => 'v1',
    'status'     => 'ok',
    'result'     => 'successful',
    'action'     => 'poweroff',
    'time'       => 12_312_323,
    'taskid'     => 123_123_123_123
  }
  response
end

#power_on(_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/cloudatcost/requests/power_on.rb', line 19

def power_on(_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'server_id' => Fog::Mock.random_numbers(1).to_i,
    'api'        => 'v1',
    'status'     => 'ok',
    'result'     => 'successful',
    'action'     => 'poweron',
    'time'       => 12_312_323,
    'taskid'     => 123_123_123_123
  }
  response
end

#rename_server(_id, _name) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/cloudatcost/requests/rename_server.rb', line 19

def rename_server(_id, _name)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'server_id' => Fog::Mock.random_numbers(1).to_i,
    'api'        => 'v1',
    'status'     => 'ok',
    'result'     => 'successful',
    'time'       => 12_312_323
  }
  response
end

#reset(_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/cloudatcost/requests/reset.rb', line 19

def reset(_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'server_id' => Fog::Mock.random_numbers(1).to_i,
    'api'        => 'v1',
    'status'     => 'ok',
    'result'     => 'successful',
    'action'     => 'reset',
    'time'       => 12_312_323,
    'taskid'     => 123_123_123_123
  }
  response
end

#reverse_dns(_id, _hostname) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/cloudatcost/requests/reverse_dns.rb', line 19

def reverse_dns(_id, _hostname)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'server_id' => Fog::Mock.random_numbers(1).to_i,
    'api'        => 'v1',
    'status'     => 'ok',
    'result'     => 'successful',
    'time'       => 12_312_323
  }
  response
end

#run_mode(_id, _action) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fog/cloudatcost/requests/run_mode.rb', line 19

def run_mode(_id, _action)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'server_id' => Fog::Mock.random_numbers(1).to_i,
    'api'        => 'v1',
    'status'     => 'ok',
    'result'     => 'successful',
    'time'       => 12_312_323
  }
  response
end