fog-cloudatcost 0.2.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +21 -35
  3. data/.rubocop.yml +10 -1157
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +11 -25
  7. data/Gemfile +2 -0
  8. data/README.md +0 -1
  9. data/Rakefile +6 -18
  10. data/fog-cloudatcost.gemspec +24 -23
  11. data/lib/fog/cloudatcost.rb +13 -1
  12. data/lib/fog/cloudatcost/compute.rb +20 -18
  13. data/lib/fog/cloudatcost/models/server.rb +6 -6
  14. data/lib/fog/cloudatcost/models/servers.rb +4 -2
  15. data/lib/fog/cloudatcost/models/task.rb +2 -0
  16. data/lib/fog/cloudatcost/models/tasks.rb +4 -2
  17. data/lib/fog/cloudatcost/models/template.rb +2 -0
  18. data/lib/fog/cloudatcost/models/templates.rb +4 -2
  19. data/lib/fog/cloudatcost/requests/console.rb +16 -11
  20. data/lib/fog/cloudatcost/requests/create_server.rb +13 -11
  21. data/lib/fog/cloudatcost/requests/delete_server.rb +13 -11
  22. data/lib/fog/cloudatcost/requests/list_servers.rb +7 -5
  23. data/lib/fog/cloudatcost/requests/list_tasks.rb +7 -5
  24. data/lib/fog/cloudatcost/requests/list_templates.rb +7 -5
  25. data/lib/fog/cloudatcost/requests/power_off.rb +14 -12
  26. data/lib/fog/cloudatcost/requests/power_on.rb +14 -12
  27. data/lib/fog/cloudatcost/requests/rename_server.rb +16 -14
  28. data/lib/fog/cloudatcost/requests/reset.rb +14 -12
  29. data/lib/fog/cloudatcost/requests/reverse_dns.rb +13 -11
  30. data/lib/fog/cloudatcost/requests/run_mode.rb +13 -11
  31. data/lib/fog/cloudatcost/version.rb +3 -1
  32. data/spec/fog/models/server_spec.rb +5 -4
  33. data/spec/fog/models/servers_spec.rb +3 -3
  34. data/spec/fog/models/task_spec.rb +3 -2
  35. data/spec/fog/models/tasks_spec.rb +3 -3
  36. data/spec/fog/models/template_spec.rb +3 -2
  37. data/spec/fog/models/templates_spec.rb +3 -3
  38. data/spec/spec_helper.rb +9 -4
  39. metadata +57 -47
  40. data/.codeclimate.yml +0 -28
  41. data/Gemfile.lock +0 -71
  42. data/lib/fog/cloudatcost/core.rb +0 -9
  43. data/spec/model_setup.rb +0 -14
@@ -1,29 +1,31 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def delete_server(id)
6
- body = { sid: "#{id}" }
8
+ body = { sid: id.to_s }
7
9
  request(
8
- :expects => [200],
9
- :method => 'POST',
10
- :path => 'api/v1/cloudpro/delete.php',
11
- :body => body,
10
+ expects: [200],
11
+ method: 'POST',
12
+ path: 'api/v1/cloudpro/delete.php',
13
+ body: body
12
14
  )
13
15
  end
14
16
  end
15
17
 
16
18
  class Mock
17
- def delete_server(id)
18
- response = Excon::Response.new
19
- response.status = 200
20
- response.body = {
19
+ def delete_server(_id)
20
+ response = Excon::Response.new
21
+ response.status = 200
22
+ response.body = {
21
23
  'result' => 'successful',
22
24
  'api' => 'v1',
23
25
  'action' => 'delete',
24
26
  'status' => 'ok',
25
- 'taskid' => 123123123123,
26
- 'time' => 12312323,
27
+ 'taskid' => 123_123_123_123,
28
+ 'time' => 12_312_323
27
29
  }
28
30
  response
29
31
  end
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def list_servers
6
8
  request(
7
- :expects => [200],
8
- :method => 'GET',
9
- :path => '/api/v1/listservers.php'
9
+ expects: [200],
10
+ method: 'GET',
11
+ path: '/api/v1/listservers.php'
10
12
  )
11
13
  end
12
14
  end
@@ -17,8 +19,8 @@ module Fog
17
19
  response = Excon::Response.new
18
20
  response.status = 200
19
21
  response.body = {
20
- 'status' => 'OK',
21
- 'servers' => self.data[:data]
22
+ 'status' => 'OK',
23
+ 'servers' => data[:data]
22
24
  }
23
25
  response
24
26
  end
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def list_tasks
6
8
  request(
7
- :expects => [200],
8
- :method => 'GET',
9
- :path => '/api/v1/listtasks.php'
9
+ expects: [200],
10
+ method: 'GET',
11
+ path: '/api/v1/listtasks.php'
10
12
  )
11
13
  end
12
14
  end
@@ -17,8 +19,8 @@ module Fog
17
19
  response = Excon::Response.new
18
20
  response.status = 200
19
21
  response.body = {
20
- 'status' => 'OK',
21
- 'servers' => self.data[:data]
22
+ 'status' => 'OK',
23
+ 'servers' => data[:data]
22
24
  }
23
25
  response
24
26
  end
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def list_templates
6
8
  request(
7
- :expects => [200],
8
- :method => 'GET',
9
- :path => '/api/v1/listtemplates.php'
9
+ expects: [200],
10
+ method: 'GET',
11
+ path: '/api/v1/listtemplates.php'
10
12
  )
11
13
  end
12
14
  end
@@ -17,8 +19,8 @@ module Fog
17
19
  response = Excon::Response.new
18
20
  response.status = 200
19
21
  response.body = {
20
- 'status' => 'OK',
21
- 'servers' => self.data[:data]
22
+ 'status' => 'OK',
23
+ 'servers' => data[:data]
22
24
  }
23
25
  response
24
26
  end
@@ -1,30 +1,32 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def power_off(id)
6
- body = { :sid => "#{id}", :action => 'poweroff' }
8
+ body = { sid: id.to_s, action: 'poweroff' }
7
9
  request(
8
- :expects => [200],
9
- :method => 'POST',
10
- :path => 'api/v1/powerop.php',
11
- :body => body,
10
+ expects: [200],
11
+ method: 'POST',
12
+ path: 'api/v1/powerop.php',
13
+ body: body
12
14
  )
13
15
  end
14
16
  end
15
17
 
16
18
  class Mock
17
- def power_off(id)
18
- response = Excon::Response.new
19
- response.status = 200
20
- response.body = {
21
- 'server_id' => Fog::Mock.random_numbers(1).to_i,
19
+ def power_off(_id)
20
+ response = Excon::Response.new
21
+ response.status = 200
22
+ response.body = {
23
+ 'server_id' => Fog::Mock.random_numbers(1).to_i,
22
24
  'api' => 'v1',
23
25
  'status' => 'ok',
24
26
  'result' => 'successful',
25
27
  'action' => 'poweroff',
26
- 'time' => 12312323,
27
- 'taskid' => 123123123123
28
+ 'time' => 12_312_323,
29
+ 'taskid' => 123_123_123_123
28
30
  }
29
31
  response
30
32
  end
@@ -1,30 +1,32 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def power_on(id)
6
- body = { :sid => "#{id}", :action => 'poweron' }
8
+ body = { sid: id.to_s, action: 'poweron' }
7
9
  request(
8
- :expects => [200],
9
- :method => 'POST',
10
- :path => 'api/v1/powerop.php',
11
- :body => body,
10
+ expects: [200],
11
+ method: 'POST',
12
+ path: 'api/v1/powerop.php',
13
+ body: body
12
14
  )
13
15
  end
14
16
  end
15
17
 
16
18
  class Mock
17
- def power_on(id)
18
- response = Excon::Response.new
19
- response.status = 200
20
- response.body = {
21
- 'server_id' => Fog::Mock.random_numbers(1).to_i,
19
+ def power_on(_id)
20
+ response = Excon::Response.new
21
+ response.status = 200
22
+ response.body = {
23
+ 'server_id' => Fog::Mock.random_numbers(1).to_i,
22
24
  'api' => 'v1',
23
25
  'status' => 'ok',
24
26
  'result' => 'successful',
25
27
  'action' => 'poweron',
26
- 'time' => 12312323,
27
- 'taskid' => 123123123123
28
+ 'time' => 12_312_323,
29
+ 'taskid' => 123_123_123_123
28
30
  }
29
31
  response
30
32
  end
@@ -1,28 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def rename_server(id, name)
6
- body = { :sid => "#{id}", :name => "#{name}" }
8
+ body = { sid: id.to_s, name: name.to_s }
7
9
  request(
8
- :expects => [200],
9
- :method => 'POST',
10
- :path => 'api/v1/renameserver.php',
11
- :body => body,
10
+ expects: [200],
11
+ method: 'POST',
12
+ path: 'api/v1/renameserver.php',
13
+ body: body
12
14
  )
13
15
  end
14
16
  end
15
17
 
16
18
  class Mock
17
- def rename_server(id, name)
18
- response = Excon::Response.new
19
- response.status = 200
20
- response.body = {
21
- 'server_id' => Fog::Mock.random_numbers(1).to_i,
22
- 'api' => "v1",
23
- 'status' => "ok",
24
- 'result' => "successful",
25
- 'time' => 12312323,
19
+ def rename_server(_id, _name)
20
+ response = Excon::Response.new
21
+ response.status = 200
22
+ response.body = {
23
+ 'server_id' => Fog::Mock.random_numbers(1).to_i,
24
+ 'api' => 'v1',
25
+ 'status' => 'ok',
26
+ 'result' => 'successful',
27
+ 'time' => 12_312_323
26
28
  }
27
29
  response
28
30
  end
@@ -1,30 +1,32 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def reset(id)
6
- body = { :sid => "#{id}", :action => 'reset' }
8
+ body = { sid: id.to_s, action: 'reset' }
7
9
  request(
8
- :expects => [200],
9
- :method => 'POST',
10
- :path => "api/v1/powerop.php",
11
- :body => body,
10
+ expects: [200],
11
+ method: 'POST',
12
+ path: 'api/v1/powerop.php',
13
+ body: body
12
14
  )
13
15
  end
14
16
  end
15
17
 
16
18
  class Mock
17
- def reset(id)
18
- response = Excon::Response.new
19
- response.status = 200
20
- response.body = {
21
- 'server_id' => Fog::Mock.random_numbers(1).to_i,
19
+ def reset(_id)
20
+ response = Excon::Response.new
21
+ response.status = 200
22
+ response.body = {
23
+ 'server_id' => Fog::Mock.random_numbers(1).to_i,
22
24
  'api' => 'v1',
23
25
  'status' => 'ok',
24
26
  'result' => 'successful',
25
27
  'action' => 'reset',
26
- 'time' => 12312323,
27
- 'taskid' => 123123123123
28
+ 'time' => 12_312_323,
29
+ 'taskid' => 123_123_123_123
28
30
  }
29
31
  response
30
32
  end
@@ -1,28 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def reverse_dns(id, host_name)
6
- body = { :sid => "#{id}", :hostname => "#{host_name}" }
8
+ body = { sid: id.to_s, hostname: host_name.to_s }
7
9
  request(
8
- :expects => [200],
9
- :method => 'POST',
10
- :path => 'api/v1/rdns.php',
11
- :body => body,
10
+ expects: [200],
11
+ method: 'POST',
12
+ path: 'api/v1/rdns.php',
13
+ body: body
12
14
  )
13
15
  end
14
16
  end
15
17
 
16
18
  class Mock
17
- def reverse_dns(id, hostname)
18
- response = Excon::Response.new
19
- response.status = 200
20
- response.body = {
21
- 'server_id' => Fog::Mock.random_numbers(1).to_i,
19
+ def reverse_dns(_id, _hostname)
20
+ response = Excon::Response.new
21
+ response.status = 200
22
+ response.body = {
23
+ 'server_id' => Fog::Mock.random_numbers(1).to_i,
22
24
  'api' => 'v1',
23
25
  'status' => 'ok',
24
26
  'result' => 'successful',
25
- 'time' => 12312323,
27
+ 'time' => 12_312_323
26
28
  }
27
29
  response
28
30
  end
@@ -1,28 +1,30 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Real
5
7
  def run_mode(id, action)
6
- body = { :sid => "#{id}", :mode => "#{action}" }
8
+ body = { sid: id.to_s, mode: action.to_s }
7
9
  request(
8
- :expects => [200],
9
- :method => 'POST',
10
- :path => 'api/v1/runmode.php',
11
- :body => body,
10
+ expects: [200],
11
+ method: 'POST',
12
+ path: 'api/v1/runmode.php',
13
+ body: body
12
14
  )
13
15
  end
14
16
  end
15
17
 
16
18
  class Mock
17
- def run_mode(id, action)
18
- response = Excon::Response.new
19
- response.status = 200
20
- response.body = {
21
- 'server_id' => Fog::Mock.random_numbers(1).to_i,
19
+ def run_mode(_id, _action)
20
+ response = Excon::Response.new
21
+ response.status = 200
22
+ response.body = {
23
+ 'server_id' => Fog::Mock.random_numbers(1).to_i,
22
24
  'api' => 'v1',
23
25
  'status' => 'ok',
24
26
  'result' => 'successful',
25
- 'time' => 12312323,
27
+ 'time' => 12_312_323
26
28
  }
27
29
  response
28
30
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module CloudAtCost
3
- VERSION = '0.2.3'
5
+ VERSION = '0.4.0'
4
6
  end
5
7
  end
@@ -1,14 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
- require 'fog/cloudatcost/models/server'
3
4
 
4
- describe Fog::Compute::CloudAtCost::Server do
5
+ RSpec.describe Fog::Compute::CloudAtCost::Server do
5
6
  let(:server) { Fog::Compute::CloudAtCost::Server.new }
6
7
 
7
- server_attributes = %w(sid id CustID packageid label servername
8
+ server_attributes = %w[sid id CustID packageid label servername
8
9
  vmname ip netmask gateway hostname rootpass
9
10
  vncport vncpass servertype template cpu cpuusage
10
11
  ram ramusage storage hdusage sdate status panel_note
11
- mode uid rdns rdnsdefault template_id)
12
+ mode uid rdns rdnsdefault template_id]
12
13
 
13
14
  it 'tests attributes' do
14
15
  server_attributes.each do |attribute|
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
- require 'fog/cloudatcost/models/servers'
3
4
 
4
- describe Fog::Compute::CloudAtCost::Servers do
5
+ RSpec.describe Fog::Compute::CloudAtCost::Servers do
5
6
  subject { Fog::Compute::CloudAtCost::Servers }
6
7
 
7
8
  it 'should have a collection of servers' do
8
9
  expect(subject.model).to eq(Fog::Compute::CloudAtCost::Server)
9
10
  end
10
11
  end
11
-
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
- require 'fog/cloudatcost/models/task'
3
4
 
4
- describe Fog::Compute::CloudAtCost::Task do
5
+ RSpec.describe Fog::Compute::CloudAtCost::Task do
5
6
  let(:server) { Fog::Compute::CloudAtCost::Task.new }
6
7
 
7
8
  it 'respond to #id' do