kitchen-fog 0.6.0 → 0.6.2

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: 6b40bf2e82fa79545da6b55c68430f7578a83557
4
- data.tar.gz: 8cd22ed93fbe59e67fb76da948685ccb56c03767
3
+ metadata.gz: e2e1b0a298df449a085cbdbb1efb97fd4ae9d808
4
+ data.tar.gz: 7151432803cbdec21ee8c0cd4460ccf72fd373cb
5
5
  SHA512:
6
- metadata.gz: bdfe511e6a307c5e56217dca30c88f082498ea9eb0cf36b36761cb0104650696c23ab3caae9a9448f2472c64719883486ef4df6979ac402d1644603c7b0e7149
7
- data.tar.gz: 5c21fa33874143f44585b3801ab8cf84d105be44adca84c9eff6012dd94777a8c4a01ab46e2a393a8cfc521f45813e988f445f70c6d46e8dfa4dce0b795f8e6e
6
+ metadata.gz: 1b67603813c60c4c1102f9674a11a7ff95cf163e2c2726493f2f82973e2962e4043bbf54430bf98e9af92b827319579deb39a81e1d7e75ef48256dcd3eebffa2
7
+ data.tar.gz: c730813645e6ad9c3a1776bde72da9af4a508dd893ed3ccd9150424b51373dd857c14f2a5080c048887b3f5bf7c431cfad887a75bf9be1621919ece8fb59cf1b
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/TerryHowe/kitchen-fog.png?branch=master)](https://travis-ci.org/TerryHowe/kitchen-fog) [![Code Climate](https://codeclimate.com/github/TerryHowe/kitchen-fog.png)](https://codeclimate.com/github/TerryHowe/kitchen-fog)
1
+ [![Build Status](https://travis-ci.org/TerryHowe/kitchen-fog.png?branch=master)](https://travis-ci.org/TerryHowe/kitchen-fog)
2
2
 
3
3
  # Kitchen::Fog
4
4
 
@@ -40,7 +40,7 @@ Provide, at a minimum, the required driver options in your `.kitchen.yml` file.
40
40
  flavor_id: '103'
41
41
  image_id: '8c096c29-a666-4b82-99c4-c77dc70cfb40'
42
42
  networks: [ '76abe0b1-581a-4698-b200-a2e890f4eb8d' ]
43
- network: '76abe0b1-581a-4698-b200-a2e890f4eb8d'
43
+ network_name: '76abe0b1-581a-4698-b200-a2e890f4eb8d'
44
44
  require_chef_omnibus: latest (if you'll be using Chef)
45
45
 
46
46
  By default, a unique server name will be generated and the current user's SSH
@@ -49,10 +49,10 @@ options:
49
49
 
50
50
  name: [A UNIQUE SERVER NAME]
51
51
  ssh_key: [PATH TO YOUR PRIVATE SSH KEY]
52
+ upload_public_ssh_key: [TRUE UPLOADS PUBLIC KEY TO SERVER]
52
53
  public_key_path: [PATH TO YOUR SSH PUBLIC KEY]
53
54
  username: [SSH USER]
54
55
  port: [SSH PORT]
55
- key_name: [SSH KEY NAME]
56
56
 
57
57
  If a key\_name is provided it will be used instead of any
58
58
  public\_key\_path that is specified.
@@ -35,19 +35,20 @@ module Kitchen
35
35
  default_config :port, '22'
36
36
  default_config :use_ipv6, false
37
37
  default_config :network_name, nil
38
+ default_config :upload_public_ssh_key, false
38
39
 
39
40
  def create(state)
40
41
  config[:name] ||= generate_name(instance.name)
41
42
  config[:disable_ssl_validation] and disable_ssl_validation
42
43
  server = create_server(state)
43
44
  unless config[:floating_ip_create].nil?
44
- create_floating_ip(server)
45
+ create_floating_ip(server, state)
45
46
  else
46
47
  state[:hostname] = get_ip(server)
47
48
  end
48
49
  wait_for_sshd(state[:hostname]) ; puts '(ssh ready)'
49
- unless config[:ssh_key] or config[:key_name]
50
- do_ssh_setup(state, config, server)
50
+ if config[:upload_public_ssh_key]
51
+ upload_public_ssh_key(state, config, server)
51
52
  end
52
53
  rescue ::Fog::Errors::Error, Excon::Errors::Error => ex
53
54
  raise ActionFailed, ex.message
@@ -76,25 +77,33 @@ module Kitchen
76
77
  ::Fog::Network.new(authentication)
77
78
  end
78
79
 
80
+ def convert_to_strings(objay)
81
+ if objay.kind_of?(Array)
82
+ objay.map { |v| convert_to_strings(v) }
83
+ elsif objay.kind_of?(Hash)
84
+ Hash[objay.map { |(k, v)| [k.to_s, convert_to_strings(v)] }]
85
+ else
86
+ objay
87
+ end
88
+ end
89
+
79
90
  def create_server(state)
80
- server_def = config[:server_create] || {}
81
- server_def = server_def.dup
82
- server_def[:name] = config[:name]
83
- # Can't use the Fog bootstrap and/or setup methods here; they require a
84
- # public IP address that can't be guaranteed to exist across all
85
- # OpenStack deployments (e.g. TryStack ARM only has private IPs).
86
- server = compute.servers.create(server_def)
91
+ server_configed = config[:server_create] || {}
92
+ server_configed = server_configed.dup
93
+ server_configed[:name] = config[:name]
94
+ server_configed = convert_to_strings(server_configed)
95
+ server = compute.servers.create(server_configed)
87
96
  state[:server_id] = server.id
88
97
  info "Fog instance <#{state[:server_id]}> created."
89
98
  server.wait_for { print '.'; ready? } ; puts "\n(server ready)"
90
99
  server
91
100
  end
92
101
 
93
- def create_floating_ip(server)
102
+ def create_floating_ip(server, state)
94
103
  hsh = config[:floating_ip_create].dup
95
- floater = network.create_floating_ip(hsh[:floating_network_id], hsh)
96
- floating_id = floater.body['floatingip']['id']
97
- state[:hostname] = floater.body['floatingip']['floating_ip_address']
104
+ floater = network.floating_ips.create(hsh)
105
+ floating_id = floater.id
106
+ state[:hostname] = floater.floating_ip_address
98
107
  port = network.ports(:filters => { :device_id => server.id }).first
99
108
  network.associate_floating_ip(floating_id, port.id)
100
109
  end
@@ -147,7 +156,7 @@ module Kitchen
147
156
  return pub, priv
148
157
  end
149
158
 
150
- def do_ssh_setup(state, config, server)
159
+ def upload_public_ssh_key(state, config, server)
151
160
  ssh = ::Fog::SSH.new(state[:hostname], config[:username],
152
161
  { :password => server.password })
153
162
  pub_key = open(config[:public_key_path]).read
@@ -19,7 +19,7 @@
19
19
  module Kitchen
20
20
  module Driver
21
21
  # Version string for Fog Kitchen driver
22
- FOG_VERSION = '0.6.0'
22
+ FOG_VERSION = '0.6.2'
23
23
  end
24
24
  end
25
25
 
@@ -61,6 +61,10 @@ describe Kitchen::Driver::Fog do
61
61
  it 'defaults to no network name' do
62
62
  expect(driver[:network_name]).to eq(nil)
63
63
  end
64
+
65
+ it 'defaults to no upload_public_ssh_key' do
66
+ expect(driver[:upload_public_ssh_key]).to eq(false)
67
+ end
64
68
  end
65
69
 
66
70
  context 'overridden options' do
@@ -108,7 +112,7 @@ describe Kitchen::Driver::Fog do
108
112
  d.stub(:create_server).and_return(server)
109
113
  d.stub(:wait_for_sshd).with('1.2.3.4').and_return(true)
110
114
  d.stub(:get_ip).and_return('1.2.3.4')
111
- d.stub(:do_ssh_setup).and_return(true)
115
+ d.stub(:upload_public_ssh_key).and_return(true)
112
116
  d
113
117
  end
114
118
 
@@ -557,7 +561,7 @@ describe Kitchen::Driver::Fog do
557
561
  end
558
562
  end
559
563
 
560
- describe '#do_ssh_setup' do
564
+ describe '#upload_public_ssh_key' do
561
565
  let(:server) { double(:password => 'aloha') }
562
566
  let(:state) { { :hostname => 'host' } }
563
567
  let(:read) { double(:read => 'a_key') }
@@ -573,7 +577,7 @@ describe Kitchen::Driver::Fog do
573
577
  driver.stub(:open).with(File.expand_path(
574
578
  '~/.ssh/id_dsa.pub')).and_return(read)
575
579
  read.stub(:read).and_return('a_key')
576
- res = driver.send(:do_ssh_setup, state, config, server)
580
+ res = driver.send(:upload_public_ssh_key, state, config, server)
577
581
  expected = [
578
582
  'mkdir .ssh',
579
583
  'echo "a_key" >> ~/.ssh/authorized_keys',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Hartman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-04 00:00:00.000000000 Z
11
+ date: 2013-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -139,7 +139,7 @@ files:
139
139
  - kitchen-fog.gemspec
140
140
  - lib/kitchen/driver/fog.rb
141
141
  - lib/kitchen/driver/fog_version.rb
142
- - spec/kitchen/driver/openstack_spec.rb
142
+ - spec/kitchen/driver/fog_spec.rb
143
143
  - spec/spec_helper.rb
144
144
  homepage: https://github.com/TerryHowe/kitchen-fog
145
145
  licenses:
@@ -166,5 +166,5 @@ signing_key:
166
166
  specification_version: 4
167
167
  summary: A Test Kitchen Fog Nova driver
168
168
  test_files:
169
- - spec/kitchen/driver/openstack_spec.rb
169
+ - spec/kitchen/driver/fog_spec.rb
170
170
  - spec/spec_helper.rb