kitchen-cloudstack 0.1.1 → 0.1.2

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.
data/README.md CHANGED
@@ -35,7 +35,8 @@ Then to specify different OS templates,
35
35
  OPTIONAL
36
36
  cloudstack_ssh_keypair_name: [SSH KEY NAME]
37
37
  To use the CloudStack public key provider, you need to have the .PEM file located in the same directory as
38
- your .kitchen.yml file.
38
+ your .kitchen.yml file, your home directory (~), or your .ssh directory (~/.ssh/) and it must be named the same as the
39
+ Keypair on CloudStack suffixed with .pem.
39
40
 
40
41
  By default, a unique server name will be generated and the randomly generated password will be used, though that
41
42
  behavior can be overridden with additional options (e.g., to specify a SSH private key):
@@ -77,23 +77,23 @@ module Kitchen
77
77
  require 'excon'
78
78
  Excon.defaults[:ssl_verify_peer] = false
79
79
  end
80
- password = ''
81
- if (!config[:cloudstack_ssh_keypair_name].nil?)
82
- keypair = config[:cloudstack_ssh_keypair_name]
83
- end
80
+
84
81
  server = create_server
85
82
  debug(server)
83
+
86
84
  state[:server_id] = server['deployvirtualmachineresponse'].fetch('id')
87
85
  jobid = server['deployvirtualmachineresponse'].fetch('jobid')
88
86
  info("CloudStack instance <#{state[:server_id]}> created.")
89
87
  debug("Job ID #{jobid}")
88
+
90
89
  server_start = compute.query_async_job_result('jobid'=>jobid)
91
90
  while server_start['queryasyncjobresultresponse'].fetch('jobstatus') == 0
92
91
  print ". "
93
92
  sleep(10)
94
93
  server_start = compute.query_async_job_result('jobid'=>jobid)
95
- debug("Server_Start: #{server_start} \n")
96
94
  end
95
+ debug("Server_Start: #{server_start} \n")
96
+
97
97
  if server_start['queryasyncjobresultresponse'].fetch('jobstatus') == 2
98
98
  errortext = server_start['queryasyncjobresultresponse'].fetch('jobresult').fetch('errortext')
99
99
  error("ERROR! Job failed with #{errortext}")
@@ -104,40 +104,40 @@ module Kitchen
104
104
  debug(server_info)
105
105
  print "(server ready)"
106
106
 
107
- #Check first if the API response has a keypair. I should probably just make this check the config, but this
108
- #should save against typos in the config file.
109
-
110
- if (!server_info.fetch('keypair').nil?)
111
- state[:hostname] = server_info.fetch('nic').first.fetch('ipaddress')
112
- info("SSH for #{state[:hostname]} with SSH Key #{server_info.fetch('keypair')}.")
113
- if File.exist?("./#{server_info.fetch('keypair')}.pem")
114
- keypair = "./#{server_info.fetch('keypair')}.pem"
115
- elsif File.exist?("~/#{server_info.fetch('keypair')}.pem")
116
- keypair = "~/#{server_info.fetch('keypair')}.pem"
117
- elsif File.exist?("~/.ssh/#{server_info.fetch('keypair')}.pem")
118
- keypair = "~/.ssh/#{server_info.fetch('keypair')}.pem"
119
- else
120
- error("Cannot find PEM file specified.")
121
- end
122
107
 
108
+ keypair = nil
109
+ password = nil
110
+ if File.exist?("./#{config[:cloudstack_ssh_keypair_name]}.pem")
111
+ keypair = "./#{config[:cloudstack_ssh_keypair_name]}.pem"
112
+ elsif File.exist?("~/#{config[:cloudstack_ssh_keypair_name]}.pem")
113
+ keypair = "~/#{config[:cloudstack_ssh_keypair_name]}.pem"
114
+ elsif File.exist?("~/.ssh/#{config[:cloudstack_ssh_keypair_name]}.pem")
115
+ keypair = "~/.ssh/#{config[:cloudstack_ssh_keypair_name]}.pem"
116
+ elsif (!config[:cloudstack_ssh_keypair_name].nil?)
117
+ info("Keypair specified but not found. Using password if enabled.")
118
+ end
119
+
120
+ # debug("Keypair is #{keypair}")
121
+ state[:hostname] = server_info.fetch('nic').first.fetch('ipaddress')
122
+
123
+ if (!keypair.nil?)
124
+ info("SSH for #{state[:hostname]} with keypair #{config[:cloudstack_ssh_keypair_name]}.")
123
125
  ssh = Fog::SSH.new(state[:hostname], config[:username], {:keys => keypair})
124
126
  debug(state[:hostname])
125
127
  debug(config[:username])
126
128
  debug(keypair)
127
129
  deploy_private_key(state[:hostname], ssh)
128
- elsif (server_info.fetch('keypair').nil? && server_info.fetch('passwordenabled') == true)
129
- password = server_info.fetch('password')
130
- state[:hostname] = server_info.fetch('nic').first.fetch('ipaddress')
131
- # Print out IP and password so you can record it if you want.
132
- info("Password for #{config[:username]} at #{state[:hostname]} is #{password}")
133
- ssh = Fog::SSH.new(state[:hostname], config[:username], {:password => password})
134
- debug(state[:hostname])
135
- debug(config[:username])
136
- debug(password)
137
- deploy_private_key(state[:hostname], ssh)
138
- elsif (server_info.fetch('keypair').nil? && server_info.fetch('passwordenabled') == false)
139
- state[:hostname] = server_info.fetch('nic').first.fetch('ipaddress')
140
- info("No SSH key specified nor is this a password enabled template. You will have to manually copy your SSH public key to #{state[:hostname]} to use this Kitchen.")
130
+ elsif (server_info.fetch('passwordenabled') == true)
131
+ password = server_info.fetch('password')
132
+ # Print out IP and password so you can record it if you want.
133
+ info("Password for #{config[:username]} at #{state[:hostname]} is #{password}")
134
+ ssh = Fog::SSH.new(state[:hostname], config[:username], {:password => password})
135
+ debug(state[:hostname])
136
+ debug(config[:username])
137
+ debug(password)
138
+ deploy_private_key(state[:hostname], ssh)
139
+ else
140
+ info("No keypair specified (or file not found) nor is this a password enabled template. You will have to manually copy your SSH public key to #{state[:hostname]} to use this Kitchen.")
141
141
  end
142
142
  end
143
143
  end
@@ -159,7 +159,6 @@ module Kitchen
159
159
  readable = IO.select([tcp_socket], nil, nil, 5)
160
160
  if readable
161
161
  debug("\nsshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}\n")
162
- yield
163
162
  true
164
163
  else
165
164
  false
@@ -188,9 +187,9 @@ module Kitchen
188
187
  tcp_test_ssh(hostname)
189
188
  sync_time = 45
190
189
  if (config[:cloudstack_sync_time])
191
- debug("Setting sync time to #{config[:cloudstack_sync_time]}")
192
190
  sync_time = config[:cloudstack_sync_time]
193
191
  end
192
+ debug("Sync time is #{sync_time}")
194
193
  if !(config[:public_key_path].nil?)
195
194
  pub_key = open(config[:public_key_path]).read
196
195
  # Wait a few moments for the OS to run the cloud-setup-password scripts
@@ -202,7 +201,6 @@ module Kitchen
202
201
 
203
202
  end
204
203
  end
205
-
206
204
  end
207
205
  end
208
206
  end
@@ -21,6 +21,6 @@ module Kitchen
21
21
  module Driver
22
22
 
23
23
  # Version string for Cloudstack Kitchen driver
24
- CLOUDSTACK_VERSION = "0.1.1"
24
+ CLOUDSTACK_VERSION = "0.1.2"
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-cloudstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-30 00:00:00.000000000 Z
12
+ date: 2013-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: test-kitchen
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements: []
165
165
  rubyforge_project:
166
- rubygems_version: 1.8.24
166
+ rubygems_version: 1.8.25
167
167
  signing_key:
168
168
  specification_version: 3
169
169
  summary: A Test Kitchen Driver for Cloudstack