knife-brightbox 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
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=
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.3.0
2
+
3
+ * introducing `--purge` and `--node-name` command line options for the
4
+ delete subcommand to clean up resources after destroying a server
5
+ * Relaxes fog dependency to allow 1.x versions of fog
6
+ * Updates gemspec licence and description
7
+
1
8
  # 0.2.2
2
9
 
3
10
  * Updates fog dependency to 1.7.0
@@ -10,7 +17,7 @@
10
17
  # 0.2
11
18
 
12
19
  * Added the ability to add server groups during bootstrap (@gkarekinian)
13
-
20
+
14
21
  http://git.io/TOcHhQ
15
22
 
16
23
  * Fixes from @gkarekinian, @kangguru
data/README.rdoc CHANGED
@@ -62,7 +62,7 @@ Provisions a new server in the Brightbox Cloud and then perform a Chef bootstrap
62
62
 
63
63
  == knife brightbox server delete
64
64
 
65
- 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'. Please note - this does not delete the associated node and client objects from the Chef server.
65
+ 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.
66
66
 
67
67
  == knife brightbox server list
68
68
 
@@ -5,18 +5,19 @@ require "knife-brightbox/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "knife-brightbox"
7
7
  s.version = Knife::Brightbox::VERSION
8
+ s.license = "Apache License, Version 2.0"
8
9
  s.has_rdoc = true
9
10
  s.authors = ["Sergio Rubio"]
10
11
  s.email = ["rubiojr@frameos.org","rubiojr@frameos.org"]
11
12
  s.homepage = "http://wiki.opscode.com/display/chef"
12
13
  s.summary = "Brightbox Support for Chef's Knife Command"
13
- s.description = s.summary
14
+ s.description = "Plugin to add support for Brightbox's Cloud service to Chef's Knife command"
14
15
  s.extra_rdoc_files = ["README.rdoc", "LICENSE" ]
15
16
 
16
17
  s.files = `git ls-files`.split("\n")
17
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.add_dependency "fog", "~> 1.7.0"
20
+ s.add_dependency "fog", "~> 1.12"
20
21
  s.add_dependency "chef", ">= 0.10"
21
22
  s.require_paths = ["lib"]
22
23
  end
@@ -26,9 +26,45 @@ class Chef
26
26
 
27
27
  banner "knife brightbox server delete SERVER_ID [SERVER_ID] (options)"
28
28
 
29
+ option :purge,
30
+ :short => "-P",
31
+ :long => "--purge",
32
+ :boolean => true,
33
+ :default => false,
34
+ :description => "Destroy corresponding node and client on the Chef Server, in addition to destroying the EC2 node itself. Assumes node and client have the same name as the server (if not, add the '--node-name' option)."
35
+
36
+ option :chef_node_name,
37
+ :short => "-N NAME",
38
+ :long => "--node-name NAME",
39
+ :description => "The name of the node and client to delete, if it differs from the server name. Only has meaning when used with the '--purge' option."
40
+
41
+ # Extracted from Chef::Knife.delete_object, because it has a
42
+ # confirmation step built in... By specifying the '--purge'
43
+ # flag (and also explicitly confirming the server destruction!)
44
+ # the user is already making their intent known. It is not
45
+ # necessary to make them confirm two more times.
46
+ def destroy_item(klass, name, type_name)
47
+ begin
48
+ object = klass.load(name)
49
+ object.destroy
50
+ ui.warn("Deleted #{type_name} #{name}")
51
+ rescue Net::HTTPServerException
52
+ ui.warn("Could not find a #{type_name} named #{name} to delete!")
53
+ end
54
+ end
55
+
56
+ def wait_for_release
57
+ yield
58
+ true
59
+ rescue Excon::Errors::Forbidden
60
+ sleep 1
61
+ false
62
+ end
63
+
29
64
  def run
30
65
  @name_args.each do |instance_id|
31
66
  server = connection.servers.get(instance_id)
67
+
32
68
  if server.nil?
33
69
  ui.error("Server instance #{instance_id} not found. Aborting.")
34
70
  exit 1
@@ -37,6 +73,7 @@ class Chef
37
73
  msg("Name", server.name)
38
74
  msg("Flavor", server.flavor.name)
39
75
  msg("Image", server.image.name)
76
+ msg("Public IP Address", server.public_ip_address)
40
77
 
41
78
  puts "\n"
42
79
  confirm("Do you really want to delete this server")
@@ -44,6 +81,20 @@ class Chef
44
81
  server.destroy
45
82
 
46
83
  ui.warn("Deleted server #{server.id} named #{server.name}")
84
+
85
+ if config[:purge]
86
+ thing_to_delete = config[:chef_node_name] || server.name
87
+ destroy_item(Chef::Node, thing_to_delete, "node")
88
+ destroy_item(Chef::ApiClient, thing_to_delete, "client")
89
+
90
+ server.cloud_ips.each do |cid|
91
+ cid = connection.cloud_ips.get(cid["id"])
92
+ print "#{ui.color("WARNING: ", :yellow)} Deleted cloud ip (#{cid.id})"
93
+ print(".") until wait_for_release { cid.destroy; puts("done!") }
94
+ end
95
+ else
96
+ ui.warn("Corresponding node and client for the #{instance_id} server were not deleted and remain registered with the Chef Server")
97
+ end
47
98
  end
48
99
  end
49
100
 
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Brightbox
3
- VERSION = "0.2.2"
3
+ VERSION = "0.3.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-brightbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Sergio Rubio
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-21 00:00:00.000000000 Z
11
+ date: 2013-06-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: fog
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 1.7.0
19
+ version: '1.12'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 1.7.0
26
+ version: '1.12'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: chef
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,12 +34,11 @@ dependencies:
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0.10'
46
- description: Brightbox Support for Chef's Knife Command
41
+ description: Plugin to add support for Brightbox's Cloud service to Chef's Knife command
47
42
  email:
48
43
  - rubiojr@frameos.org
49
44
  - rubiojr@frameos.org
@@ -65,28 +60,28 @@ files:
65
60
  - lib/chef/knife/brightbox_server_list.rb
66
61
  - lib/knife-brightbox/version.rb
67
62
  homepage: http://wiki.opscode.com/display/chef
68
- licenses: []
63
+ licenses:
64
+ - Apache License, Version 2.0
65
+ metadata: {}
69
66
  post_install_message:
70
67
  rdoc_options: []
71
68
  require_paths:
72
69
  - lib
73
70
  required_ruby_version: !ruby/object:Gem::Requirement
74
- none: false
75
71
  requirements:
76
72
  - - ! '>='
77
73
  - !ruby/object:Gem::Version
78
74
  version: '0'
79
75
  required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
76
  requirements:
82
77
  - - ! '>='
83
78
  - !ruby/object:Gem::Version
84
79
  version: '0'
85
80
  requirements: []
86
81
  rubyforge_project:
87
- rubygems_version: 1.8.23
82
+ rubygems_version: 2.0.3
88
83
  signing_key:
89
- specification_version: 3
84
+ specification_version: 4
90
85
  summary: Brightbox Support for Chef's Knife Command
91
86
  test_files: []
92
87
  has_rdoc: true