knife-nc 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/HISTORY.md +20 -0
- data/README.md +0 -1
- data/knife-nc.gemspec +1 -0
- data/lib/chef/knife/nc_server_delete.rb +30 -7
- data/lib/chef/knife/nc_server_list.rb +22 -19
- data/lib/knife-nc/version.rb +1 -1
- metadata +17 -4
data/Gemfile
CHANGED
data/HISTORY.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# 変更履歴
|
2
|
+
|
3
|
+
## 0.0.2
|
4
|
+
|
5
|
+
* gem install knife-nc で nifty-cloud-sdk gem もインストールされるようになった
|
6
|
+
* nc server delete コマンドの、サーバ停止しているのに停止しようとしてエラーになるバグを修正した
|
7
|
+
* nc server delete コマンドの、disable_api_termination が true になっていると削除できないバグを修正した
|
8
|
+
* nc server list コマンドの、サーバが 1 台も存在しないとエラー終了してしまうバグを修正した
|
9
|
+
|
10
|
+
## 0.0.1
|
11
|
+
|
12
|
+
version 0.0.0 がインストールされているとうまく動かないことがあるかもしれないので、gem uninstall knife-nc -v 0.0.0 したほうがいいかもです。
|
13
|
+
|
14
|
+
* NIFTY Cloud 上の主要な 8 イメージに対応した
|
15
|
+
* 起動時スクリプトに対応した
|
16
|
+
* -R または --ssh-passphrase で SSH パスフレーズが指定できるようになった
|
17
|
+
|
18
|
+
## 0.0.0
|
19
|
+
|
20
|
+
* 初期インポート
|
data/README.md
CHANGED
data/knife-nc.gemspec
CHANGED
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = "NIFTY Cloud Support for Chef's Knife Command"
|
13
13
|
s.description = s.summary
|
14
14
|
s.extra_rdoc_files = ["README.md", "LICENSE" ]
|
15
|
+
s.add_dependency "nifty-cloud-sdk", ">= 1.7"
|
15
16
|
|
16
17
|
s.files = `git ls-files`.split("\n")
|
17
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -42,6 +42,11 @@ class Chef
|
|
42
42
|
:long => "--node-name NAME",
|
43
43
|
: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."
|
44
44
|
|
45
|
+
option :force,
|
46
|
+
:long => "--force",
|
47
|
+
:default => false,
|
48
|
+
:description => "Force to delete server by changing the server's disableApiTermination attribute to false."
|
49
|
+
|
45
50
|
# Extracted from Chef::Knife.delete_object, because it has a
|
46
51
|
# confirmation step built in... By specifying the '--purge'
|
47
52
|
# flag (and also explicitly confirming the server destruction!)
|
@@ -78,15 +83,33 @@ class Chef
|
|
78
83
|
puts "\n"
|
79
84
|
confirm("Do you really want to delete this server")
|
80
85
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
86
|
+
if server.instanceState.name != 'stopped'
|
87
|
+
print "\n#{ui.color("Waiting for server to shutdown", :magenta)}"
|
88
|
+
connection.stop_instances(:instance_id => instance_id, :force => true)
|
89
|
+
while server.instanceState.name != 'stopped'
|
90
|
+
print "."
|
91
|
+
server = connection.describe_instances(:instance_id => instance_id).reservationSet.item.first.instancesSet.item.first
|
92
|
+
sleep 5
|
93
|
+
end
|
94
|
+
puts("done\n")
|
87
95
|
end
|
88
96
|
|
89
|
-
|
97
|
+
attribute = connection.describe_instance_attribute(:instance_id => instance_id, :attribute => 'disableApiTermination')
|
98
|
+
if attribute.disableApiTermination.value != 'false'
|
99
|
+
if config[:force] == false
|
100
|
+
ui.error("Server's 'disableApiTermination' attribute is true. Use --force option to delete server.")
|
101
|
+
exit 1
|
102
|
+
else
|
103
|
+
print "\n#{ui.color("Enabling API termination for server", :magenta)}"
|
104
|
+
connection.modify_instance_attribute(:instance_id => instance_id, :attribute => 'disableApiTermination', :value => 'false')
|
105
|
+
while attribute.disableApiTermination.value != 'false'
|
106
|
+
print "."
|
107
|
+
attribute = connection.describe_instance_attribute(:instance_id => instance_id, :attribute => 'disableApiTermination')
|
108
|
+
sleep 5
|
109
|
+
end
|
110
|
+
puts("done\n")
|
111
|
+
end
|
112
|
+
end
|
90
113
|
|
91
114
|
connection.terminate_instances(:instance_id => instance_id)
|
92
115
|
|
@@ -41,25 +41,28 @@ class Chef
|
|
41
41
|
ui.color('Security Group', :bold),
|
42
42
|
ui.color('State', :bold)
|
43
43
|
]
|
44
|
-
connection.describe_instances.reservationSet
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
44
|
+
set = connection.describe_instances.reservationSet
|
45
|
+
if set
|
46
|
+
set.item.each do |instance|
|
47
|
+
server = instance.instancesSet.item.first
|
48
|
+
group = instance.groupSet
|
49
|
+
server_list << server.instanceId
|
50
|
+
server_list << server.ipAddress.to_s
|
51
|
+
server_list << server.privateIpAddress.to_s
|
52
|
+
server_list << server.instanceType
|
53
|
+
server_list << server.imageId
|
54
|
+
server_list << server.keyName
|
55
|
+
server_list << (group ? group.item.first.groupId : '')
|
56
|
+
server_list << begin
|
57
|
+
state = server.instanceState.name
|
58
|
+
case state
|
59
|
+
when 'sotopped', 'warning', 'waiting', 'creating', 'suspending', 'uploading', 'import_error'
|
60
|
+
ui.color(state, :red)
|
61
|
+
when 'pending'
|
62
|
+
ui.color(state, :yellow)
|
63
|
+
else
|
64
|
+
ui.color(state, :green)
|
65
|
+
end
|
63
66
|
end
|
64
67
|
end
|
65
68
|
end
|
data/lib/knife-nc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-nc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
-
dependencies:
|
12
|
+
date: 2012-10-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nifty-cloud-sdk
|
16
|
+
requirement: &70198309663100 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.7'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70198309663100
|
14
25
|
description: NIFTY Cloud Support for Chef's Knife Command
|
15
26
|
email:
|
16
27
|
- tidnlyam@gmail.com
|
@@ -23,6 +34,7 @@ files:
|
|
23
34
|
- .gitignore
|
24
35
|
- .rspec
|
25
36
|
- Gemfile
|
37
|
+
- HISTORY.md
|
26
38
|
- LICENSE
|
27
39
|
- README.md
|
28
40
|
- Rakefile
|
@@ -58,9 +70,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
70
|
version: '0'
|
59
71
|
requirements: []
|
60
72
|
rubyforge_project:
|
61
|
-
rubygems_version: 1.8.
|
73
|
+
rubygems_version: 1.8.10
|
62
74
|
signing_key:
|
63
75
|
specification_version: 3
|
64
76
|
summary: NIFTY Cloud Support for Chef's Knife Command
|
65
77
|
test_files:
|
66
78
|
- spec/spec_helper.rb
|
79
|
+
has_rdoc: true
|