knife-brightbox 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NGI4N2JhNzFjYThjNDY3NjY4YTQxOGQ1NDQyNTVhYTljMDFhN2ZjYw==
5
- data.tar.gz: !binary |-
6
- YTA5YzM3NjA2MWRlMDNiZTIyYWEwOGEyZTI4YWY4N2ZjNDk2NTc5Yw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZTNlMzlkZjU2ZThjMDY1MjdmZDIzNjMwNzAzMzI5YjU5YWE2ZTMwOTAzYjYz
10
- OTUzMmUwOTI5Y2Q0ZmYyMGQwZGU2MTU1ZDU2MjlmMmFmYWNjMTc1ZmI5NTdj
11
- ODkzMGUxYTE4NTZlMjZlMTc4Nzg2NDY4YjA5MTk3NTc4NjE2YWY=
12
- data.tar.gz: !binary |-
13
- NjlkZDc1YTY1MTBkMTkxZTg0NzU3NDBmNTU5YTA2ODBhZmE3NjQ2YTFjZjEz
14
- YWQyYWE3YTQ2NmRkNjNiZWYxZTE2OTE4ZTc2NWZkZWMzODcwNWE4ZmFhN2M4
15
- ZDY0ZmRjZjQ0ODZiMmEwNTExYjgwNGI5MzQ2ZTY4MjQyM2I0ZDY=
2
+ SHA1:
3
+ metadata.gz: 232a756d01ba131c96ac44c15575521523e7f7cb
4
+ data.tar.gz: 913a7023ea765ebef0cad9d0bc5b21190ee73f7b
5
+ SHA512:
6
+ metadata.gz: 78fd3404057b71b523968e653dce4f7b0051bf639cc1a88a3fd393513ffef022e7bfb020e3c19cc29d8e1095becd35d7231f2e2a1ff46bca4e8ce3ba9706e66c
7
+ data.tar.gz: 686537e040010dd23140b063bf0bbfda1949b08281e7681e8d2f580bb687d87beee5a50b5de6c635aa93260c70097f25b5e775c16312c28f70d62b8cae32f29c
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.4.0
2
+
3
+ * Introduces support for Zones.
4
+ * Can list zones using `knife brightbox zone list`
5
+ * Can specify zone to create server in with `--zone` argument using handle
6
+ (gb1-a)
7
+
1
8
  # 0.3.0
2
9
 
3
10
  * introducing `--purge` and `--node-name` command line options for the
data/README.rdoc CHANGED
@@ -24,6 +24,11 @@ This plugin is distributed as a Ruby Gem. To install it, run:
24
24
 
25
25
  Depending on your system's configuration, you may need to run this command with root privileges.
26
26
 
27
+ If you're using Bundler, add this to your Gemfile and run `bundle install`:
28
+
29
+ gem 'knife-brightbox'
30
+
31
+
27
32
  = CONFIGURATION:
28
33
 
29
34
  In order to communicate with the Brightbox Cloud API you will have to tell Knife about your Username and API Key. The easiest way to accomplish this is to create some entries in your <tt>knife.rb</tt> file:
@@ -51,6 +56,7 @@ Additionally the following options may be set in your `knife.rb`:
51
56
  * image
52
57
  * distro
53
58
  * template_file
59
+ * zone (gb1-a or gb1-b)
54
60
 
55
61
  = SUBCOMMANDS:
56
62
 
@@ -60,6 +66,8 @@ This plugin provides the following Knife subcommands. Specific command options
60
66
 
61
67
  Provisions a new server in the Brightbox Cloud and then perform a Chef bootstrap (using the SSH protocol). The goal of the bootstrap is to get Chef installed on the target system so it can run Chef Client with a Chef Server. The main assumption is a baseline OS installation exists (provided by the provisioning). It is primarily intended for Chef Client systems that talk to a Chef server. By default the server is bootstrapped using the {ubuntu10.04-gems}[https://github.com/opscode/chef/blob/master/chef/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb] template. This can be overridden using the <tt>-d</tt> or <tt>--template-file</tt> command options.
62
68
 
69
+ You can specify the Brightbox zone your new server will use using the `--zone` switch. By default it is `gb1-a`. It can also be `gb1-b` at the time of this writing. See `knife brightbox zone list` to request a current list from the API.
70
+
63
71
  == knife brightbox server delete
64
72
 
65
73
  Deletes an existing server in the currently configured Brightbox Cloud account by the server/instance id. You can find the instance id by entering 'knife brightbox server list'. You can specify the `--purge` flag to delete the associated node and client objects from the Chef server along with the cloup ip.
@@ -76,6 +84,9 @@ Outputs a list of all available flavors (available hardware configuration for a
76
84
 
77
85
  Outputs a list of all available images available to the currently configured Brightbox Cloud account. An image is a collection of files used to create or rebuild a server. Brightbox provides a number of pre-built OS images by default. This data can be useful when choosing an image id to pass to the <tt>knife brightbox server create</tt> subcommand.
78
86
 
87
+ == knife brightbox zone list
88
+
89
+ Outputs a list of all available zones available to the currently configured Brightbox Cloud account. A zone represents cloud resources at a datacentre. Each zone is completely isolated in terms of power, cooling, security and networking equipment. This data can be useful when choosing an zone handle to pass to the <tt>knife brightbox server create</tt> subcommand.
79
90
 
80
91
  = LICENSE:
81
92
 
@@ -110,7 +110,12 @@ class Chef
110
110
  :boolean => true,
111
111
  :default => false
112
112
 
113
-
113
+ option :zone,
114
+ # no short switch because -z is --local-mode
115
+ :long => "--zone ZONE",
116
+ :description => "Brightbox zone; default is gb1-a. Can also be gb1-b",
117
+ :default => 'gb1-a',
118
+ :proc => Proc.new { |z| Chef::Config[:zone] = z }
114
119
 
115
120
  def tcp_test_ssh(hostname)
116
121
  tcp_socket = TCPSocket.new(hostname, 22)
@@ -143,6 +148,7 @@ class Chef
143
148
  server = connection.servers.create(
144
149
  :name => config[:server_name],
145
150
  :image_id => Chef::Config[:knife][:image],
151
+ :zone_id => zone_id,
146
152
  :flavor_id => Chef::Config[:knife][:flavor] || config[:flavor]
147
153
  )
148
154
  puts " done \n"
@@ -151,6 +157,7 @@ class Chef
151
157
  puts "#{ui.color("Name", :cyan)}: #{server.name}"
152
158
  puts "#{ui.color("Flavor", :cyan)}: #{server.flavor_id}"
153
159
  puts "#{ui.color("Image", :cyan)}: #{server.image.name}"
160
+ puts "#{ui.color("Zone", :cyan)}: #{server.zone['handle']}"
154
161
 
155
162
  print "\n#{ui.color("Waiting server", :magenta)}"
156
163
 
@@ -209,6 +216,34 @@ class Chef
209
216
  bootstrap
210
217
  end
211
218
 
219
+ private
220
+
221
+ # Get zone identifiers from Brightbox's API (example: `zon-ca1g2`) and
222
+ # their handle (example: `gb1-a`). They are not necessarily the same
223
+ # on every user account.
224
+ def zones
225
+ connection.zones.inject({}) do |memo, z|
226
+ memo[z.handle] = z.id
227
+
228
+ memo
229
+ end
230
+ end
231
+
232
+ def zone_id
233
+ zone_handle = Chef::Config[:knife][:zone] || config[:zone]
234
+
235
+ begin
236
+ zones.fetch(zone_handle)
237
+ rescue KeyError
238
+ ui.error <<-EOF
239
+ This is not a valid zone: #{zone_handle}
240
+
241
+ Valid zones: #{zones.keys.join(', ')}
242
+ EOF
243
+
244
+ exit 1
245
+ end
246
+ end
212
247
  end
213
248
  end
214
249
  end
@@ -0,0 +1,42 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2011 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife/brightbox_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class BrightboxZoneList < Knife
24
+
25
+ include Knife::BrightboxBase
26
+
27
+ banner "knife brightbox zone list (options)"
28
+
29
+ def run
30
+ zone_list = [
31
+ ui.color('Handle (use as the --zone switch)', :bold),
32
+ ui.color('ID', :bold),
33
+ ]
34
+ connection.zones.sort_by(&:handle).each do |zone|
35
+ zone_list << zone.handle
36
+ zone_list << zone.id
37
+ end
38
+ puts ui.list(zone_list, :columns_across, 2)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Brightbox
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-brightbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Rubio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-24 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.12'
20
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
26
  version: '1.12'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: chef
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.10'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.10'
41
41
  description: Plugin to add support for Brightbox's Cloud service to Chef's Knife command
@@ -58,6 +58,7 @@ files:
58
58
  - lib/chef/knife/brightbox_server_create.rb
59
59
  - lib/chef/knife/brightbox_server_delete.rb
60
60
  - lib/chef/knife/brightbox_server_list.rb
61
+ - lib/chef/knife/brightbox_zone_list.rb
61
62
  - lib/knife-brightbox/version.rb
62
63
  homepage: http://wiki.opscode.com/display/chef
63
64
  licenses:
@@ -69,17 +70,17 @@ require_paths:
69
70
  - lib
70
71
  required_ruby_version: !ruby/object:Gem::Requirement
71
72
  requirements:
72
- - - ! '>='
73
+ - - ">="
73
74
  - !ruby/object:Gem::Version
74
75
  version: '0'
75
76
  required_rubygems_version: !ruby/object:Gem::Requirement
76
77
  requirements:
77
- - - ! '>='
78
+ - - ">="
78
79
  - !ruby/object:Gem::Version
79
80
  version: '0'
80
81
  requirements: []
81
82
  rubyforge_project:
82
- rubygems_version: 2.0.3
83
+ rubygems_version: 2.2.2
83
84
  signing_key:
84
85
  specification_version: 4
85
86
  summary: Brightbox Support for Chef's Knife Command