kitchen-rax 0.9.0 → 0.10.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: e4900a69b56ac71b3d3020872845bb6f8ad64784
4
- data.tar.gz: 812f068a487fa640559475440a67eb5f729dc433
3
+ metadata.gz: 98f16b2c39bbd6b0adf07f393824972fbd705036
4
+ data.tar.gz: cbd1fe8a828cc0b137c6dd48a29000fd6c915440
5
5
  SHA512:
6
- metadata.gz: 64767fa00f3389394cf40c64c8af7af6df116a64ea92c9b649a109b64104a833d9803b55b9c20b814b1d881ac2442de4372386c9bdd9be6b79fcd1979e7aea97
7
- data.tar.gz: 1902fcde2c9ad0d79a976c307b061dcb85360e8091d46d6e1f28027d366067ec309ff5ba4a95fbdb88c141cd007df33fc20ef3b8e4e7a43420498d5a37f05a3a
6
+ metadata.gz: aff67bad596628a0610c2067bdd5260b3ac96455ad90431ba25e0f8af0950b36fb74517618db34fdbd044ef04e8487cd1bf22520f9bbfcf8c7aac93c42a96550
7
+ data.tar.gz: ebb2516cdcb58ff8793e27f053291a259018fbeea1baad62fd21a4f4baecd5fe54fbe7e2684aa0db6a50285f4513f48d50d674530da29dfceaa26b417768875f
@@ -0,0 +1,40 @@
1
+ module Kitchen
2
+
3
+ module Driver
4
+
5
+ class Cloud
6
+
7
+ def self.compute(config)
8
+ server_def = { provider: 'Rackspace' }
9
+ opts = [:version, :rackspace_username, :rackspace_api_key, :rackspace_region]
10
+ opts.each do |opt|
11
+ server_def[opt] = config[opt]
12
+ end
13
+ Fog::Compute.new(server_def)
14
+ end
15
+
16
+ def self.create_server(instance, config)
17
+ server_def = { name: generate_name(instance), config_drive: true}
18
+ [:image_id, :flavor_id, :personality].each do |opt|
19
+ server_def[opt] = config[opt]
20
+ end
21
+ server_def[:no_passwd_lock] = true
22
+ server = compute(config).servers.new(server_def)
23
+ server.save
24
+ server
25
+ end
26
+
27
+ private
28
+
29
+ def generate_name(instance)
30
+ [
31
+ instance.name.gsub(/\W/, '')[0..14],
32
+ (Etc.getlogin || 'nologin').gsub(/\W/, '')[0..14],
33
+ Socket.gethostname.gsub(/\W/, '')[0..22],
34
+ Array.new(7) { rand(36).to_s(36) }.join
35
+ ].join('-')
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -15,6 +15,7 @@ module Kitchen
15
15
  default_config :rackspace_region, 'lon'
16
16
  default_config :wait_for, 600
17
17
  default_config :image_id
18
+ default_config :personality
18
19
  default_config :networks, nil
19
20
 
20
21
  default_config :rackspace_username do
@@ -35,15 +36,10 @@ module Kitchen
35
36
  end
36
37
 
37
38
  def create(state)
38
- server = create_server
39
- state[:server_id] = server.id
40
- info("Rackspace instance <#{state[:server_id]}> created.")
41
- server.wait_for { ready? }
42
- info("The instance has finished building.")
43
- rackconnect_check(server)
44
- info("The instance is ready to accept connections on IP #{server.public_ip_address} with password #{server.password}.")
45
- state[:hostname] = server.public_ip_address
46
- state[:password] = server.password
39
+ info("Creating a new Rackspace instance.")
40
+ server = Kitchen::Driver::cloud.create_server(instance, config)
41
+ wait_for_build_completion(server, state)
42
+ check_winrm_connectivity(instance, server.public_ip_address, server.password)
47
43
  rescue Fog::Errors::Error, Excon::Errors::Error => ex
48
44
  raise ActionFailed, ex.message
49
45
  end
@@ -59,30 +55,21 @@ module Kitchen
59
55
 
60
56
  private
61
57
 
62
- def compute
63
- server_def = { provider: 'Rackspace' }
64
- opts = [:version, :rackspace_username, :rackspace_api_key, :rackspace_region]
65
- opts.each do |opt|
66
- server_def[opt] = config[opt]
67
- end
68
- Fog::Compute.new(server_def)
69
- end
58
+ def wait_for_build_completion(server, state)
59
+ state[:server_id] = server.id
60
+ info("Rackspace instance <#{state[:server_id]}> created.")
61
+ server.wait_for { ready? }
62
+ info("The instance has finished building.")
63
+ rackconnect_check(server)
64
+ info("The instance is ready to accept connections on IP #{server.public_ip_address} with password #{server.password}.")
65
+ state[:hostname] = server.public_ip_address
66
+ state[:password] = server.password
67
+ end
70
68
 
71
- def create_server
72
- server_name = [
73
- instance.name.gsub(/\W/, '')[0..14],
74
- (Etc.getlogin || 'nologin').gsub(/\W/, '')[0..14],
75
- Socket.gethostname.gsub(/\W/, '')[0..22],
76
- Array.new(7) { rand(36).to_s(36) }.join
77
- ].join('-')
78
- server_def = { name: server_name }
79
- [:image_id, :flavor_id].each do |opt|
80
- server_def[opt] = config[opt]
81
- end
82
- server_def[:no_passwd_lock] = true
83
- server = compute.servers.new(server_def)
84
- server.save
85
- server
69
+ def check_winrm_connectivity(instance, ip, password)
70
+ info("Checking the WinRM port is open.")
71
+ Kitchen::Driver::WinRM.check(instance, ip, password)
72
+ info("The WinRM port is ready to accept connections.")
86
73
  end
87
74
 
88
75
  def rackconnect_check(server)
@@ -21,6 +21,6 @@ module Kitchen
21
21
  module Driver
22
22
 
23
23
  # Version string for Rax Kitchen driver
24
- RAX_VERSION = "0.9.0"
24
+ RAX_VERSION = "0.10.0"
25
25
  end
26
26
  end
@@ -0,0 +1,14 @@
1
+ module Kitchen
2
+
3
+ module Driver
4
+
5
+ class WinRM
6
+
7
+ def self.check(instance, hostname, password)
8
+ pseudo_state = { hostname: hostname, username: "root", password: password }
9
+ instance.transport.connection(pseudo_state).wait_until_ready
10
+ end
11
+
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-rax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Kouame
@@ -127,8 +127,10 @@ files:
127
127
  - bin/console
128
128
  - bin/setup
129
129
  - kitchen-rax.gemspec
130
+ - lib/kitchen/driver/cloud.rb
130
131
  - lib/kitchen/driver/rax.rb
131
132
  - lib/kitchen/driver/rax_version.rb
133
+ - lib/kitchen/driver/winrm.rb
132
134
  - spec/kitchen/rax_spec.rb
133
135
  - spec/spec_helper.rb
134
136
  homepage: ''