knife-joyent 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -42,6 +42,16 @@ Currently available commands:
42
42
  knife joyent tag delete <server_id> -A
43
43
  knife joyent tag list <server_id>
44
44
 
45
+ ## Example Usage
46
+
47
+ The following command will provision an Ubuntu 12.04 with 1GB of memory and bootstrap it with chef
48
+
49
+ knife joyent server create \
50
+ --flavor "Small 1GB"
51
+ --image d2ba0f30-bbe8-11e2-a9a2-6bc116856d85 \
52
+ --node-name 'chefbuntu-x' \
53
+ --server-name 'chefbuntu-x'
54
+
45
55
  ## Configuration
46
56
 
47
57
  The following options can be specified in your knife configuration file
data/knife-joyent.gemspec CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.add_dependency "fog", "~> 1.11"
20
+ s.add_dependency "multi_json", "~> 1.7"
20
21
  s.add_dependency "chef", ">= 0.10.10"
21
22
  s.require_paths = ["lib"]
22
23
 
@@ -111,20 +111,17 @@ class Chef
111
111
  def tcp_test_ssh(hostname)
112
112
  ssh_test_max = 10*60
113
113
  ssh_test = 0
114
-
115
- begin
114
+ until _tcp_test_ssh(hostname)
116
115
  if ssh_test < ssh_test_max
117
116
  print(".")
118
117
  ssh_test += 1
119
118
  sleep 1
120
119
  else
121
- ui.error("Unable to ssh to node (#{bootstrap_ip_address}), exiting")
120
+ puts ui.error("Unable to ssh to node (#{bootstrap_ip_address}), exiting")
122
121
  exit 1
123
122
  end
124
- end until _tcp_test_ssh(bootstrap_id) {
125
- sleep @initial_sleep_delay ||= 10
126
- puts("done")
127
- }
123
+ end
124
+ puts ui.color("SSH Ready.", :cyan)
128
125
  end
129
126
 
130
127
 
@@ -143,19 +140,18 @@ class Chef
143
140
  :package => config[:package]
144
141
  }.merge(joyent_metadata))
145
142
 
146
- print "\n#{ui.color("Waiting for server", :magenta)}"
143
+ puts ui.color("Waiting for Server to be Provisioned", :magenta)
147
144
  server.wait_for { print "."; ready? }
148
145
 
149
146
  bootstrap_ip = self.determine_bootstrap_ip(server)
150
147
 
151
- Chef::Log.debug("Bootstrap IP Address #{bootstrap_ip}")
152
148
  unless bootstrap_ip
153
- ui.error("No IP address available for bootstrapping.")
149
+ puts ui.error("No IP address available for bootstrapping.")
154
150
  exit 1
155
151
  end
156
152
 
157
- puts ui.color("attempting to bootstrap on #{bootstrap_ip}", :cyan)
158
-
153
+ Chef::Log.debug("Bootstrap IP Address #{bootstrap_ip}")
154
+ puts ui.color("Bootstrap IP Address #{bootstrap_ip}", :cyan)
159
155
  if Chef::Config[:knife][:provisioner]
160
156
  # tag the provision with 'provisioner'
161
157
  tagkey = 'provisioner'
@@ -171,11 +167,9 @@ class Chef
171
167
  puts ui.color("Updated tags for #{node_name}", :cyan)
172
168
  puts ui.list(tags, :uneven_columns_across, 2)
173
169
  else
174
- puts ui.color("No user defined in knife config for provision tagging", :magenta)
170
+ puts ui.color("No user defined in knife config for provision tagging -- continuing", :magenta)
175
171
  end
176
172
 
177
- bootstrap_for_node(server, bootstrap_ip).run
178
-
179
173
  puts ui.color("Created machine:", :cyan)
180
174
  msg_pair("ID", server.id.to_s)
181
175
  msg_pair("Name", server.name)
@@ -185,6 +179,12 @@ class Chef
185
179
  msg_pair("IP's", server.ips.join(" "))
186
180
  msg_pair("JSON Attributes",config[:json_attributes]) unless config[:json_attributes].empty?
187
181
 
182
+ puts ui.color("Waiting for SSH to come up on: #{bootstrap_ip}", :cyan)
183
+ tcp_test_ssh(bootstrap_ip)
184
+
185
+ puts ui.color("Bootstrapping: #{bootstrap_ip}", :cyan)
186
+ bootstrap_for_node(server, bootstrap_ip).run
187
+
188
188
  rescue Excon::Errors::Conflict => e
189
189
  if e.response && e.response.body.kind_of?(String)
190
190
  error = ::Fog::JSON.decode(e.response.body)
@@ -276,8 +276,8 @@ class Chef
276
276
  tcp_socket = TCPSocket.new(hostname, 22)
277
277
  readable = IO.select([tcp_socket], nil, nil, 5)
278
278
  if readable
279
+ puts ui.color("SSHD OK [#{hostname}] #{tcp_socket.gets}", :cyan)
279
280
  Chef::Log.debug("sshd accepting connections on #{hostname}, banner is #{tcp_socket.gets}")
280
- yield
281
281
  true
282
282
  else
283
283
  false
@@ -287,10 +287,12 @@ class Chef
287
287
  rescue Errno::EPERM
288
288
  false
289
289
  rescue Errno::ECONNREFUSED
290
- sleep 2
290
+ false
291
+ rescue Errno::ECONNRESET
292
+ false
293
+ rescue Errno::ENETUNREACH
291
294
  false
292
295
  rescue Errno::EHOSTUNREACH
293
- sleep 2
294
296
  false
295
297
  ensure
296
298
  tcp_socket && tcp_socket.close
@@ -1,3 +1,3 @@
1
1
  module KnifeJoyent
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-joyent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
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-05-06 00:00:00.000000000 Z
12
+ date: 2013-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fog
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.11'
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.7'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.7'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: chef
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -106,4 +122,3 @@ signing_key:
106
122
  specification_version: 3
107
123
  summary: Joyent CloudAPI Support for Chef's Knife Command
108
124
  test_files: []
109
- has_rdoc: true