foreman_digitalocean 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7357254f2c88d41cd0a69e13f1d7b3a3a8729ef7
4
- data.tar.gz: a1234f4af26b017a3dba33e3994718f1cedb2c44
3
+ metadata.gz: 9379a1ca3a8c5ad06c176ddbea6e97eb53eba36b
4
+ data.tar.gz: ffea1f5f5baa311ef1da930272ca4b1444988208
5
5
  SHA512:
6
- metadata.gz: da0c4205ea0098f68aff3b6d177d70b81cb65cb48e104dc7ccb4520dea82bf73041b78a73e159cc320f9b7da2fb82d4b8a116b17ad91d4964ba30af9dccfe50d
7
- data.tar.gz: 9cf73094139dd599e51bfaefa1d3e7c9daa0220dd8b6a8b6a319144b65f7dacc553ca9cfe6f5f43f5bbd174b35e68c05a5b7e5a12bc2688e61d2c0537282d8bc
6
+ metadata.gz: ebc9b5745ba635c92314d0b01f1b3cefa35dd6e045631f645d20fa45a1f39f6f70d623da3e436a0194f334895fb1e2a54846c4dd26bbedded65631a739362834
7
+ data.tar.gz: 4439ce81bf5365f1f5b117e6360e77423311d16d64e8a720052692093a805c00cd31eaaa127b661e36b57f2c85239d115d234694f3b84bf6b636b3fb063bcfd9
@@ -3,7 +3,7 @@ module DigitaloceanImagesHelper
3
3
  images = @compute_resource.available_images
4
4
  images.each { |image| image.name = image.id if image.name.nil? }
5
5
  select_f f, :uuid, images.to_a.sort_by(&:full_name),
6
- :id, :full_name, {}, :label => _('Image')
6
+ :id, :full_name, {}, :label => _('Image')
7
7
  end
8
8
 
9
9
  def select_image(f, compute_resource)
@@ -14,8 +14,8 @@ module DigitaloceanImagesHelper
14
14
  images,
15
15
  :id,
16
16
  :slug,
17
- { :include_blank => (images.empty? || images.size == 1) ? false : _('Please select an image') },
18
- { :label => ('Image'), :disabled => images.empty? } )
17
+ { :include_blank => images.empty? || images.size == 1 ? false : _('Please select an image') },
18
+ { :label => 'Image', :disabled => images.empty? })
19
19
  end
20
20
 
21
21
  def select_region(f, compute_resource)
@@ -27,7 +27,7 @@ module DigitaloceanImagesHelper
27
27
  :slug,
28
28
  :slug,
29
29
  {},
30
- :label => ('Region'),
30
+ :label => 'Region',
31
31
  :disabled => compute_resource.images.empty?)
32
32
  end
33
33
  end
@@ -1,5 +1,5 @@
1
1
  module FogExtensions
2
- module DigitalOcean
2
+ module Digitalocean
3
3
  module Image
4
4
  extend ActiveSupport::Concern
5
5
 
@@ -11,7 +11,7 @@ module FogExtensions
11
11
  define_method :name=, instance_method(:full_name=)
12
12
  end
13
13
 
14
- def full_name= value
14
+ def full_name=(value)
15
15
  self.os_version = value
16
16
  end
17
17
 
@@ -23,10 +23,10 @@ module FogExtensions
23
23
  # Attempt guessing arch based on the name from digital ocean
24
24
  def arch
25
25
  requires :os_version
26
- if os_version.end_with?("x64")
27
- "x86_64"
28
- elsif os_version.end_with?("x32")
29
- "i386"
26
+ if os_version.end_with?('x64')
27
+ 'x86_64'
28
+ elsif os_version.end_with?('x32')
29
+ 'i386'
30
30
  end
31
31
  end
32
32
  end
@@ -1,5 +1,5 @@
1
1
  module FogExtensions
2
- module DigitalOcean
2
+ module Digitalocean
3
3
  module Server
4
4
  extend ActiveSupport::Concern
5
5
 
@@ -20,7 +20,7 @@ module ForemanDigitalocean
20
20
  super.merge(
21
21
  :uuid => :identity_to_s,
22
22
  :ip => :ipv4_address,
23
- :ip6 => :ipv6_address,
23
+ :ip6 => :ipv6_address
24
24
  )
25
25
  end
26
26
 
@@ -39,7 +39,7 @@ module ForemanDigitalocean
39
39
  end
40
40
 
41
41
  def create_vm(args = {})
42
- args["ssh_keys"] = [ssh_key] if ssh_key
42
+ args['ssh_keys'] = [ssh_key] if ssh_key
43
43
  args['image'] = args['image_id']
44
44
  super(args)
45
45
  rescue Fog::Errors::Error => e
@@ -82,11 +82,11 @@ module ForemanDigitalocean
82
82
  end
83
83
 
84
84
  def self.provider_friendly_name
85
- "DigitalOcean"
85
+ 'DigitalOcean'
86
86
  end
87
87
 
88
88
  def associated_host(vm)
89
- associate_by("ip", [vm.public_ip_address])
89
+ associate_by('ip', [vm.public_ip_address])
90
90
  end
91
91
 
92
92
  def user_data_supported?
@@ -103,8 +103,7 @@ module ForemanDigitalocean
103
103
 
104
104
  def client
105
105
  @client ||= Fog::Compute.new(
106
- :provider => "DigitalOcean",
107
- :version => 'V2',
106
+ :provider => 'DigitalOcean',
108
107
  :digitalocean_token => api_key
109
108
  )
110
109
  end
@@ -122,8 +121,8 @@ module ForemanDigitalocean
122
121
  key_name = "foreman-#{id}#{Foreman.uuid}"
123
122
  client.create_ssh_key key_name, public_key
124
123
  KeyPair.create! :name => key_name, :compute_resource_id => id, :secret => private_key
125
- rescue => e
126
- logger.warn "failed to generate key pair"
124
+ rescue StandardError => e
125
+ logger.warn 'failed to generate key pair'
127
126
  logger.error e.message
128
127
  logger.error e.backtrace.join("\n")
129
128
  destroy_key_pair
@@ -136,13 +135,13 @@ module ForemanDigitalocean
136
135
  client.destroy_ssh_key(ssh_key.id) if ssh_key
137
136
  key_pair.destroy
138
137
  true
139
- rescue => e
138
+ rescue StandardError => e
140
139
  logger.warn "failed to delete key pair from DigitalOcean, you might need to cleanup manually : #{e}"
141
140
  end
142
141
 
143
142
  def ssh_key
144
143
  @ssh_key ||= begin
145
- key = client.list_ssh_keys.data[:body]["ssh_keys"].find { |i| i["name"] == key_pair.name }
144
+ key = client.list_ssh_keys.data[:body]['ssh_keys'].find { |i| i['name'] == key_pair.name }
146
145
  key['id'] if key.present?
147
146
  end
148
147
  end
@@ -16,7 +16,7 @@ module ForemanDigitalocean
16
16
 
17
17
  initializer 'foreman_digitalocean.register_plugin', :before => :finisher_hook do
18
18
  Foreman::Plugin.register :foreman_digitalocean do
19
- requires_foreman '>= 1.8'
19
+ requires_foreman '>= 1.16'
20
20
  compute_resource ForemanDigitalocean::Digitalocean
21
21
  parameter_filter ComputeResource, :region, :api_key
22
22
  end
@@ -28,22 +28,16 @@ module ForemanDigitalocean
28
28
 
29
29
  config.to_prepare do
30
30
  require 'fog/digitalocean'
31
- require 'fog/digitalocean/compute_v2'
32
- require 'fog/digitalocean/models/compute_v2/image'
33
- require 'fog/digitalocean/models/compute_v2/server'
34
- require File.expand_path(
35
- '../../../app/models/concerns/fog_extensions/digitalocean/server',
36
- __FILE__)
37
- require File.expand_path(
38
- '../../../app/models/concerns/fog_extensions/digitalocean/image',
39
- __FILE__)
40
-
41
- Fog::Compute::DigitalOceanV2::Image.send :include,
42
- FogExtensions::DigitalOcean::Image
43
- Fog::Compute::DigitalOceanV2::Server.send :include,
44
- FogExtensions::DigitalOcean::Server
31
+ require 'fog/digitalocean/compute'
32
+ require 'fog/digitalocean/models/compute/image'
33
+ require 'fog/digitalocean/models/compute/server'
34
+
35
+ Fog::Compute::DigitalOcean::Image.send :include,
36
+ FogExtensions::Digitalocean::Image
37
+ Fog::Compute::DigitalOcean::Server.send :include,
38
+ FogExtensions::Digitalocean::Server
45
39
  ::Host::Managed.send :include,
46
- ForemanDigitalocean::Concerns::HostManagedExtensions
40
+ ForemanDigitalocean::Concerns::HostManagedExtensions
47
41
  end
48
42
  end
49
43
  end
@@ -1,9 +1,9 @@
1
- require File.expand_path("../engine", File.dirname(__FILE__))
1
+ require File.expand_path('../engine', File.dirname(__FILE__))
2
2
  namespace :test do
3
- desc "Run the plugin unit test suite."
3
+ desc 'Run the plugin unit test suite.'
4
4
  task :digitalocean => ['db:test:prepare'] do
5
5
  test_task = Rake::TestTask.new('digitalocean_test_task') do |t|
6
- t.libs << ["test", "#{ForemanDigitalocean::Engine.root}/test"]
6
+ t.libs << ['test', "#{ForemanDigitalocean::Engine.root}/test"]
7
7
  t.test_files = [
8
8
  "#{ForemanDigitalocean::Engine.root}/test/**/*_test.rb"
9
9
  ]
@@ -24,8 +24,8 @@ namespace :digitalocean do
24
24
  "#{ForemanDigitalocean::Engine.root}/lib/**/*.rb",
25
25
  "#{ForemanDigitalocean::Engine.root}/test/**/*.rb"]
26
26
  end
27
- rescue
28
- puts "Rubocop not loaded."
27
+ rescue StandardError
28
+ puts 'Rubocop not loaded.'
29
29
  end
30
30
 
31
31
  Rake::Task['rubocop_digitalocean'].invoke
@@ -38,7 +38,7 @@ end
38
38
 
39
39
  load 'tasks/jenkins.rake'
40
40
  if Rake::Task.task_defined?(:'jenkins:unit')
41
- Rake::Task["jenkins:unit"].enhance do
41
+ Rake::Task['jenkins:unit'].enhance do
42
42
  Rake::Task['test:digitalocean'].invoke
43
43
  Rake::Task['digitalocean:rubocop'].invoke
44
44
  end
@@ -1,3 +1,3 @@
1
1
  module ForemanDigitalocean
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'.freeze
3
3
  end
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :container_resource, :class => ComputeResource do
3
3
  sequence(:name) { |n| "compute_resource#{n}" }
4
4
 
@@ -1,6 +1,6 @@
1
1
  # This calls the main test_helper in Foreman core
2
2
  require 'test_helper'
3
3
 
4
- # Add plugin to FactoryGirl's paths
5
- FactoryGirl.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
- FactoryGirl.reload
4
+ # Add plugin to FactoryBot's paths
5
+ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
+ FactoryBot.reload
@@ -9,7 +9,7 @@ module ForemanDigitalocean
9
9
  teardown { Fog.unmock! }
10
10
 
11
11
  test 'ssh key pair gets created after its saved' do
12
- digitalocean = FactoryGirl.build(:digitalocean_cr)
12
+ digitalocean = FactoryBot.build(:digitalocean_cr)
13
13
  digitalocean.expects(:setup_key_pair)
14
14
  digitalocean.save
15
15
  end
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_digitalocean
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy McNeely, Daniel Lobato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-23 00:00:00.000000000 Z
11
+ date: 2018-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rubocop
14
+ name: fog-digitalocean
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.42'
20
- type: :development
19
+ version: '0.3'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.42'
26
+ version: '0.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.51.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.51.0
27
41
  description: Provision and manage DigitalOcean droplets from Foreman.
28
42
  email:
29
43
  - elobatocs@gmail.com
@@ -74,12 +88,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
88
  version: '0'
75
89
  requirements: []
76
90
  rubyforge_project:
77
- rubygems_version: 2.2.2
91
+ rubygems_version: 2.6.12
78
92
  signing_key:
79
93
  specification_version: 4
80
94
  summary: Provision and manage DigitalOcean droplets from Foreman
81
95
  test_files:
82
96
  - test/factories/compute_resources.rb
83
- - test/test_plugin_helper.rb
84
97
  - test/unit/foreman_digitalocean/digitalocean_test.rb
85
- has_rdoc:
98
+ - test/test_plugin_helper.rb