fog-cloudatcost 0.1.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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/compute.rb +21 -18
  12. data/lib/fog/cloudatcost/models/server.rb +6 -6
  13. data/lib/fog/cloudatcost/models/servers.rb +4 -2
  14. data/lib/fog/cloudatcost/models/task.rb +2 -0
  15. data/lib/fog/cloudatcost/models/tasks.rb +4 -2
  16. data/lib/fog/cloudatcost/models/template.rb +4 -2
  17. data/lib/fog/cloudatcost/models/templates.rb +4 -2
  18. data/lib/fog/cloudatcost/requests/console.rb +16 -11
  19. data/lib/fog/cloudatcost/requests/create_server.rb +13 -11
  20. data/lib/fog/cloudatcost/requests/delete_server.rb +13 -11
  21. data/lib/fog/cloudatcost/requests/list_servers.rb +7 -5
  22. data/lib/fog/cloudatcost/requests/list_tasks.rb +7 -5
  23. data/lib/fog/cloudatcost/requests/list_templates.rb +7 -5
  24. data/lib/fog/cloudatcost/requests/power_off.rb +14 -12
  25. data/lib/fog/cloudatcost/requests/power_on.rb +14 -12
  26. data/lib/fog/cloudatcost/requests/rename_server.rb +16 -14
  27. data/lib/fog/cloudatcost/requests/reset.rb +14 -12
  28. data/lib/fog/cloudatcost/requests/reverse_dns.rb +13 -11
  29. data/lib/fog/cloudatcost/requests/run_mode.rb +13 -11
  30. data/lib/fog/cloudatcost/version.rb +3 -1
  31. data/lib/fog/cloudatcost.rb +13 -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 -69
  42. data/lib/fog/cloudatcost/core.rb +0 -9
  43. data/spec/model_setup.rb +0 -14
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ fog-cloudatcost
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/.travis.yml CHANGED
@@ -1,38 +1,24 @@
1
- language: ruby
2
- sudo: false
3
- script: bundle exec rake test
4
- cache: bundler
5
- branches:
6
- except:
7
- - "/\\Av\\d+\\Z/"
1
+ script: bundle exec rake && CODECLIMATE_REPO_TOKEN=412dc14b81fbd1f8d7356deb5feac31a8d69583d00ec1ba18040caf99343ee25 bundle exec codeclimate-test-reporter
8
2
  matrix:
9
3
  fast_finish: true
10
4
  include:
11
- - rvm: 1.9.3
5
+ - rvm: 2.2
12
6
  gemfile: Gemfile
13
- - rvm: 2.0.0
14
- gemfile: Gemfile
15
- - rvm: 2.1.0
16
- gemfile: Gemfile
17
- - rvm: 2.1.1
18
- gemfile: Gemfile
19
- - rvm: 2.1.1
7
+ - rvm: 2.2
20
8
  gemfile: gemfiles/Gemfile-edge
21
- - rvm: 2.2.0
9
+ - rvm: 2.3
22
10
  gemfile: Gemfile
23
- - rvm: 2.2.0
11
+ - rvm: 2.3
24
12
  gemfile: gemfiles/Gemfile-edge
25
- - rvm: 2.3.0
13
+ - rvm: 2.4
26
14
  gemfile: Gemfile
27
- - rvm: 2.3.0
15
+ - rvm: 2.4
28
16
  gemfile: gemfiles/Gemfile-edge
29
- - rvm: jruby-19mode
17
+ - rvm: 2.5
30
18
  gemfile: Gemfile
19
+ - rvm: 2.5
20
+ gemfile: gemfiles/Gemfile-edge
31
21
  - rvm: jruby-head
32
22
  gemfile: Gemfile
33
- allow_failures:
34
23
  - rvm: jruby-head
35
-
36
- addons:
37
- code_climate:
38
- repo_token: 412dc14b81fbd1f8d7356deb5feac31a8d69583d00ec1ba18040caf99343ee25
24
+ gemfile: gemfiles/Gemfile-edge
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'http://rubygems.org'
2
4
 
3
5
  gemspec
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  [![Build Status](https://travis-ci.org/fog/fog-cloudatcost.svg?branch=master)](https://travis-ci.org/fog/fog-cloudatcost)
2
2
  [![Code Climate](https://codeclimate.com/github/fog/fog-cloudatcost/badges/gpa.svg)](https://codeclimate.com/github/fog/fog-cloudatcost)
3
- [![Dependency Status](https://gemnasium.com/fog/fog-cloudatcost.svg)](https://gemnasium.com/fog/fog-cloudatcost)
4
3
 
5
4
  # fog-cloudatcost
6
5
  Module for the 'fog' gem to support Amazon Web Services http://panel.cloudatcost.com/
data/Rakefile CHANGED
@@ -1,21 +1,9 @@
1
- require 'bundler/gem_tasks'
2
-
1
+ # frozen_string_literal: true
3
2
 
4
- require 'rubygems'
5
- require 'bundler/setup'
6
- require 'rake/testtask'
7
-
8
- task :test do
9
- sh("bundle exec rspec")
10
- end
11
-
12
- require_relative 'lib/fog/cloudatcost'
13
-
14
- task :default => :test
15
- mock = ENV['FOG_MOCK'] || 'true'
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
16
5
 
17
- namespace :test do
18
- task :travis do
19
- sh("export FOG_MOCK=#{mock} && bundle exec rspec")
20
- end
6
+ RSpec::Core::RakeTask.new(:spec) do |t|
7
+ t.pattern = Dir.glob('spec/**/*_spec.rb')
21
8
  end
9
+ task default: :spec
@@ -1,32 +1,33 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('../lib', __FILE__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'fog/cloudatcost/version'
4
6
 
5
-
6
7
  Gem::Specification.new do |spec|
7
- spec.name = 'fog-cloudatcost'
8
- spec.version = Fog::CloudAtCost::VERSION
9
- spec.authors = ["Suraj Shirvankar"]
10
- spec.email = ["surajshirvankar@gmail.com"]
11
- spec.summary = %q{Module for the 'fog' gem to support CloudAtCost.}
12
- spec.description = %q{This library can be used as a module for `fog` or as standalone provider
13
- to use the Amazon Web Services in applications..}
14
- spec.homepage = 'http://github.com/fog/fog-cloudatcost'
15
- spec.license = 'MIT'
8
+ spec.name = 'fog-cloudatcost'
9
+ spec.version = Fog::CloudAtCost::VERSION
10
+ spec.authors = ['Suraj Shirvankar']
11
+ spec.email = ['surajshirvankar@gmail.com']
12
+ spec.summary = "Module for the 'fog' gem to support CloudAtCost."
13
+ spec.description =
14
+ 'This library can be used as a module for `fog` or as standalone provider to use the CloudAtCost in applications.'
15
+ spec.homepage = 'http://github.com/fog/fog-cloudatcost'
16
+ spec.license = 'MIT'
16
17
 
17
- spec.files = `git ls-files -z`.split("\x0")
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ["lib"]
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ['lib']
21
22
 
22
- spec.add_development_dependency 'bundler', '~> 1.6'
23
- spec.add_development_dependency 'rake', '~> 10.0'
24
- spec.add_development_dependency 'rspec', '~> 3.4.0'
25
- spec.add_development_dependency 'rubyzip', '~> 1.1.0'
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'rubocop'
27
+ spec.add_development_dependency 'rubyzip'
28
+ spec.add_development_dependency 'simplecov'
26
29
 
27
- spec.add_dependency 'fog-core', '~> 1.36'
28
- spec.add_dependency 'fog-json', '~> 1.0'
29
- spec.add_dependency 'fog-xml', '~> 0.1'
30
- spec.add_dependency 'ipaddress', '~> 0.8'
30
+ spec.add_dependency 'fog-core'
31
+ spec.add_dependency 'fog-json'
32
+ spec.add_dependency 'ipaddress'
31
33
  end
32
-
@@ -1,10 +1,16 @@
1
- require 'fog/cloudatcost/core'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Fog
4
4
  module Compute
5
5
  class CloudAtCost < Fog::Service
6
6
  requires :api_key, :email
7
7
 
8
+ autoload :Server, File.expand_path('../models/server', __FILE__)
9
+ autoload :Servers, File.expand_path('../models/servers', __FILE__)
10
+ autoload :Task, File.expand_path('../models/task', __FILE__)
11
+ autoload :Tasks, File.expand_path('../models/tasks', __FILE__)
12
+ autoload :Template, File.expand_path('../models/template', __FILE__)
13
+ autoload :Templates, File.expand_path('../models/templates', __FILE__)
8
14
 
9
15
  model_path 'fog/cloudatcost/models'
10
16
  model :server
@@ -23,39 +29,37 @@ module Fog
23
29
  request :power_off
24
30
  request :power_on
25
31
  request :rename_server
32
+ request :delete_server
26
33
  request :reset
27
34
  request :reverse_dns
28
35
  request :run_mode
29
36
 
30
37
  class Mock
31
-
32
- def initialize(options={})
38
+ def initialize(options = {})
33
39
  @api_key = options[:api_key]
34
- @email = options[:email]
40
+ @email = options[:email]
35
41
  end
36
-
37
42
  end
38
43
 
39
44
  class Real
40
-
41
- def initialize(options={})
45
+ def initialize(options = {})
42
46
  @api_key = options[:api_key]
43
- @email = options[:email]
44
- persistent = false
45
- @connection = Fog::Core::Connection.new 'https://panel.cloudatcost.com', persistent, options
47
+ @email = options[:email]
48
+ persistent = false
49
+ @connection = Fog::Core::Connection.new 'https://panel.cloudatcost.com', persistent, options
46
50
  end
47
51
 
48
52
  def request(params)
49
53
  params[:headers] ||= { 'Content-Type' => 'application/x-www-form-urlencoded' }
50
54
  params[:query] ||= {}
51
55
  required_params = {
52
- key: "#{@api_key}",
53
- login: "#{@email}"
56
+ key: @api_key.to_s,
57
+ login: @email.to_s
54
58
  }
55
59
  begin
56
- if params[:method] == 'POST'
60
+ if params[:method] == 'POST'
57
61
  params_body = required_params.merge(params[:body])
58
- params[:body] = params_body.reduce(""){ |acc,(x,y)| "#{acc}&#{x}=#{y}" }
62
+ params[:body] = params_body.reduce('') { |acc, (x, y)| "#{acc}&#{x}=#{y}" }
59
63
  else
60
64
  params[:query] = required_params.merge(params[:query])
61
65
  end
@@ -68,12 +72,11 @@ module Fog
68
72
  error
69
73
  end
70
74
  end
71
- unless response.body.empty?
72
- response.body = Fog::JSON.decode(response.body)
73
- end
75
+
76
+ response.body = Fog::JSON.decode(response.body) unless response.body.empty?
77
+
74
78
  response
75
79
  end
76
-
77
80
  end
78
81
  end
79
82
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fog/compute/models/server'
2
4
 
3
5
  module Fog
4
6
  module Compute
5
7
  class CloudAtCost
6
8
  class Server < Fog::Compute::Server
7
- identity :sid
9
+ identity :sid
8
10
  attribute :id
9
11
  attribute :CustID
10
12
  attribute :packageid
@@ -35,19 +37,18 @@ module Fog
35
37
  attribute :rdnsdefault
36
38
  attribute :template_id
37
39
 
38
-
39
40
  def new_instance?
40
- not persisted?
41
+ !persisted?
41
42
  end
42
43
 
43
44
  def save
44
- raise Fog::Errors::Error.new('Re-saving an existing object may create a duplicate') if persisted?
45
+ raise Fog::Errors::Error, 'Re-saving an existing object may create a duplicate' if persisted?
45
46
  save!
46
47
  end
47
48
 
48
49
  def save!
49
50
  requires :cpu, :ram, :storage, :template_id
50
- data = service.create_server(cpu, ram, storage, template_id)
51
+ service.create_server(cpu, ram, storage, template_id)
51
52
  end
52
53
 
53
54
  def destroy
@@ -89,7 +90,6 @@ module Fog
89
90
  response = service.send(action, sid, *args)
90
91
  response.body
91
92
  end
92
-
93
93
  end
94
94
  end
95
95
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fog/core/collection'
2
4
  require 'fog/cloudatcost/models/server'
3
5
 
@@ -9,7 +11,7 @@ module Fog
9
11
 
10
12
  # Returns list of servers
11
13
  # @return [Fog::Compute::CloudAtCost::Servers]
12
- def all(filters = {})
14
+ def all(_filters = {})
13
15
  data = service.list_servers.body['data']
14
16
  load(data)
15
17
  end
@@ -18,7 +20,7 @@ module Fog
18
20
  # @param [String] id for server to be returned
19
21
  # @return [Fog::Compute::CloudAtCost::Server]
20
22
  def get(id)
21
- server = service.servers.find do |server|
23
+ service.servers.find do |server|
22
24
  server.id != id
23
25
  end
24
26
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fog/core/collection'
2
4
  require 'fog/cloudatcost/models/task'
3
5
 
@@ -9,7 +11,7 @@ module Fog
9
11
 
10
12
  # Returns list of tasks
11
13
  # @return [Fog::Compute::CloudAtCost::Tasks]
12
- def all(filters = {})
14
+ def all(_filters = {})
13
15
  data = service.list_tasks.body['data']
14
16
  load(data)
15
17
  end
@@ -18,7 +20,7 @@ module Fog
18
20
  # @param [String] id for server to be returned
19
21
  # @return [Fog::Compute::CloudAtCost::Task]
20
22
  def get(id)
21
- task = service.list_tasks.find do |task|
23
+ service.list_tasks.find do |task|
22
24
  task.id != id
23
25
  end
24
26
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Fog
2
4
  module Compute
3
5
  class CloudAtCost
4
6
  class Template < Fog::Model
5
- identity :id
6
- attribute :detail
7
+ identity :ce_id
8
+ attribute :name
7
9
  end
8
10
  end
9
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fog/core/collection'
2
4
  require 'fog/cloudatcost/models/template'
3
5
 
@@ -9,7 +11,7 @@ module Fog
9
11
 
10
12
  # Returns list of servers
11
13
  # @return [Fog::Compute::CloudAtCost::Templates]
12
- def all(filters = {})
14
+ def all(_filters = {})
13
15
  data = service.list_templates.body['data']
14
16
  load(data)
15
17
  end
@@ -18,7 +20,7 @@ module Fog
18
20
  # @param [String] id for server to be returned
19
21
  # @return [Fog::Compute::CloudAtCost::Template]
20
22
  def get(id)
21
- template = service.templates.find do |template|
23
+ service.templates.find do |_template|
22
24
  server.id != id
23
25
  end
24
26
  end
@@ -1,28 +1,33 @@
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 console(id)
6
- body = { :sid => "#{id}" }
8
+ body = { sid: id.to_s }
7
9
  request(
8
- :expects => [200],
9
- :method => 'POST',
10
- :path => 'api/v1/console.php',
11
- :body => body,
10
+ expects: [200],
11
+ method: 'POST',
12
+ path: 'api/v1/console.php',
13
+ body: body
12
14
  )
13
15
  end
14
16
  end
15
17
 
16
18
  class Mock
17
- def console(id, hostname)
18
- response = Excon::Response.new
19
- response.status = 200
20
- response.body = {
19
+ def console(_id, _hostname)
20
+ console_url =
21
+ 'http:\/\/panel.cloudatcost.com:12345\/console.html?servername=123456&hostname=1.1.1.1'\
22
+ '&sshkey=123456&sha1hash=aBcDeFgG'
23
+ response = Excon::Response.new
24
+ response.status = 200
25
+ response.body = {
21
26
  'server_id' => Fog::Mock.random_numbers(1).to_i,
22
27
  'api' => 'v1',
23
28
  'status' => 'ok',
24
- 'console' => 'http:\/\/panel.cloudatcost.com:12345\/console.html?servername=123456&hostname=1.1.1.1&sshkey=123456&sha1hash=aBcDeFgG',
25
- 'time' => 12312323,
29
+ 'console' => console_url,
30
+ 'time' => 12_312_323
26
31
  }
27
32
  response
28
33
  end
@@ -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 create_server(cpu, ram, storage, template_id)
6
- body = { cpu: "#{cpu}", ram: "#{ram}", storage: "#{storage}", os: "#{template_id}" }
8
+ body = { cpu: cpu.to_s, ram: ram.to_s, storage: storage.to_s, os: template_id.to_s }
7
9
  request(
8
- :expects => [200],
9
- :method => 'POST',
10
- :path => 'api/v1/cloudpro/build.php',
11
- :body => body,
10
+ expects: [200],
11
+ method: 'POST',
12
+ path: 'api/v1/cloudpro/build.php',
13
+ body: body
12
14
  )
13
15
  end
14
16
  end
15
17
 
16
18
  class Mock
17
- def create_server(cpu, ram, storage, template_id)
18
- response = Excon::Response.new
19
- response.status = 200
20
- response.body = {
19
+ def create_server(_cpu, _ram, _storage, _template_id)
20
+ response = Excon::Response.new
21
+ response.status = 200
22
+ response.body = {
21
23
  'result' => 'successful',
22
24
  'api' => 'v1',
23
25
  'action' => 'build',
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,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