knife-azure 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,18 +32,40 @@ class Chef
32
32
 
33
33
  banner "knife azure server delete SERVER [SERVER] (options)"
34
34
 
35
+ option :preserve_azure_os_disk,
36
+ :long => "--preserve-azure-os-disk",
37
+ :boolean => true,
38
+ :default => false,
39
+ :description => "Preserve corresponding OS Disk"
40
+
35
41
  option :purge,
36
42
  :short => "-P",
37
43
  :long => "--purge",
38
44
  :boolean => true,
39
45
  :default => false,
40
- :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)."
46
+ :description => "Destroy corresponding node and client on the Chef Server, in addition to destroying the Windows Azure node itself. Assumes node and client have the same name as the server (if not, add the '--node-name' option)."
41
47
 
42
48
  option :chef_node_name,
43
49
  :short => "-N NAME",
44
50
  :long => "--node-name NAME",
45
51
  :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."
46
52
 
53
+ option :preserve_azure_dns_name,
54
+ :long => "--preserve-azure-dns-name",
55
+ :boolean => true,
56
+ :default => false,
57
+ :description => "Preserve corresponding cloud service (DNS). If the option is not set, it deletes the service not used by any VMs."
58
+
59
+ option :delete_azure_storage_account,
60
+ :long => "--delete-azure-storage-account",
61
+ :boolean => true,
62
+ :default => false,
63
+ :description => "Delete corresponding storage account. If the option is set, it deletes the storage account not used by any VMs."
64
+
65
+ option :azure_dns_name,
66
+ :long => "--azure-dns-name NAME",
67
+ :description => "specifies the DNS name (also known as hosted service name)"
68
+
47
69
  # Extracted from Chef::Knife.delete_object, because it has a
48
70
  # confirmation step built in... By specifying the '--purge'
49
71
  # flag (and also explicitly confirming the server destruction!)
@@ -59,27 +81,46 @@ class Chef
59
81
  end
60
82
  end
61
83
 
84
+ def validate_disk_and_storage
85
+ if locate_config_value(:preserve_azure_os_disk) && locate_config_value(:delete_azure_storage_account)
86
+ ui.warn("Cannot delete storage account while keeping OS Disk. Please set any one option.")
87
+ exit
88
+ else
89
+ true
90
+ end
91
+ end
92
+
62
93
  def run
63
94
 
64
95
  validate!
65
-
96
+ validate_disk_and_storage
66
97
  @name_args.each do |name|
67
98
 
68
99
  begin
69
- server = connection.roles.find(name)
100
+ server = connection.roles.find(name, params = { :azure_dns_name => locate_config_value(:azure_dns_name) })
70
101
 
102
+ if not server
103
+ ui.warn("Server #{name} does not exist")
104
+ return
105
+ end
71
106
  puts "\n"
72
- msg_pair('Service', server.hostedservicename)
73
- msg_pair('Deployment', server.deployname)
74
- msg_pair('Role', server.name)
107
+ msg_pair('DNS Name', server.hostedservicename + ".cloudapp.net")
108
+ msg_pair('VM Name', server.name)
75
109
  msg_pair('Size', server.size)
76
- msg_pair('SSH Ip Address', server.sshipaddress)
77
- msg_pair('SSH Port', server.sshport)
78
-
110
+ msg_pair('Public Ip Address', server.publicipaddress)
79
111
  puts "\n"
80
- confirm("Do you really want to delete this server")
81
112
 
82
- connection.roles.delete(name)
113
+ begin
114
+ confirm("Do you really want to delete this server")
115
+ rescue SystemExit # Need to handle this as confirming with N/n raises SystemExit exception
116
+ server = nil # Cleanup is implicitly performed in other cloud plugins
117
+ exit!
118
+ end
119
+
120
+ connection.roles.delete(name, params = { :preserve_azure_os_disk => locate_config_value(:preserve_azure_os_disk),
121
+ :preserve_azure_dns_name => locate_config_value(:preserve_azure_dns_name),
122
+ :azure_dns_name => server.hostedservicename,
123
+ :delete_azure_storage_account => locate_config_value(:delete_azure_storage_account) })
83
124
 
84
125
  puts "\n"
85
126
  ui.warn("Deleted server #{server.name}")
@@ -92,8 +133,9 @@ class Chef
92
133
  ui.warn("Corresponding node and client for the #{name} server were not deleted and remain registered with the Chef Server")
93
134
  end
94
135
 
95
- rescue NoMethodError
96
- ui.error("Could not locate server '#{name}'. Please verify it was provisioned.")
136
+ rescue Exception => ex
137
+ ui.error("#{ex.message}")
138
+ ui.error("#{ex.backtrace.join("\n")}")
97
139
  end
98
140
  end
99
141
  end
@@ -33,17 +33,13 @@ class Chef
33
33
 
34
34
  validate!
35
35
 
36
- server_list = [
37
- ui.color('Status', :bold),
38
- ui.color('Service', :bold),
39
- ui.color('Deployment', :bold),
40
- ui.color('Role', :bold),
41
- ui.color('Host', :bold),
42
- ui.color('SSH IP', :bold),
43
- ui.color('SSH Port', :bold)
44
- ]
36
+ server_labels = ['DNS Name', 'VM Name', 'Status', 'IP Address', 'SSH Port', 'WinRM Port' ]
37
+ server_list = server_labels.map {|label| ui.color(label, :bold)}
45
38
  items = connection.roles.all
39
+
46
40
  items.each do |server|
41
+ server_list << server.hostedservicename.to_s+".cloudapp.net" # Info about the DNS name at http://msdn.microsoft.com/en-us/library/ee460806.aspx
42
+ server_list << server.name.to_s
47
43
  server_list << begin
48
44
  state = server.status.to_s.downcase
49
45
  case state
@@ -54,16 +50,13 @@ class Chef
54
50
  else
55
51
  ui.color('ready', :green)
56
52
  end
57
- end
58
- server_list << server.hostedservicename.to_s
59
- server_list << server.deployname.to_s
60
- server_list << server.name.to_s
61
- server_list << server.hostname.to_s
62
- server_list << server.sshipaddress.to_s
53
+ end
54
+ server_list << server.publicipaddress.to_s
63
55
  server_list << server.sshport.to_s
56
+ server_list << server.winrmport.to_s
64
57
  end
65
58
  puts ''
66
- puts ui.list(server_list, :columns_across, 7)
59
+ puts ui.list(server_list, :uneven_columns_across, 6)
67
60
  end
68
61
  end
69
62
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Azure
3
- VERSION = "1.0.2"
3
+ VERSION = "1.1.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,270 +1,182 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: knife-azure
3
- version: !ruby/object:Gem::Version
4
- hash: 19
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 2
10
- version: 1.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Barry Davis
14
9
  - Chirag Jog
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-06-06 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- type: :runtime
23
- requirement: &id001 !ruby/object:Gem::Requirement
13
+ date: 2012-06-06 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: chef
17
+ requirement: !ruby/object:Gem::Requirement
24
18
  none: false
25
- requirements:
26
- - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 11
29
- segments:
30
- - 0
31
- - 9
32
- - 2
33
- - 2
34
- version: 0.9.2.2
35
- prerelease: false
36
- name: rake
37
- version_requirements: *id001
38
- - !ruby/object:Gem::Dependency
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.10.0
39
23
  type: :runtime
40
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
41
26
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 55
46
- segments:
47
- - 0
48
- - 10
49
- - 0
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
50
30
  version: 0.10.0
51
- prerelease: false
52
- name: chef
53
- version_requirements: *id002
54
- - !ruby/object:Gem::Dependency
55
- type: :runtime
56
- requirement: &id003 !ruby/object:Gem::Requirement
31
+ - !ruby/object:Gem::Dependency
32
+ name: rdoc
33
+ requirement: !ruby/object:Gem::Requirement
57
34
  none: false
58
- requirements:
35
+ requirements:
59
36
  - - ~>
60
- - !ruby/object:Gem::Version
61
- hash: 47
62
- segments:
63
- - 2
64
- - 8
65
- - 0
66
- version: 2.8.0
67
- prerelease: false
68
- name: rspec
69
- version_requirements: *id003
70
- - !ruby/object:Gem::Dependency
37
+ - !ruby/object:Gem::Version
38
+ version: '3.12'
71
39
  type: :runtime
72
- requirement: &id004 !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- hash: 31
78
- segments:
79
- - 3
80
- - 12
81
- version: "3.12"
82
40
  prerelease: false
83
- name: rdoc
84
- version_requirements: *id004
85
- - !ruby/object:Gem::Dependency
86
- type: :runtime
87
- requirement: &id005 !ruby/object:Gem::Requirement
41
+ version_requirements: !ruby/object:Gem::Requirement
88
42
  none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
94
- - 0
95
- version: "0"
96
- prerelease: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '3.12'
47
+ - !ruby/object:Gem::Dependency
97
48
  name: bundler
98
- version_requirements: *id005
99
- - !ruby/object:Gem::Dependency
100
- type: :runtime
101
- requirement: &id006 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
102
50
  none: false
103
- requirements:
104
- - - ">="
105
- - !ruby/object:Gem::Version
106
- hash: 3
107
- segments:
108
- - 0
109
- version: "0"
110
- prerelease: false
111
- name: guard-rspec
112
- version_requirements: *id006
113
- - !ruby/object:Gem::Dependency
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
114
55
  type: :runtime
115
- requirement: &id007 !ruby/object:Gem::Requirement
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
116
58
  none: false
117
- requirements:
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rubygems-bundler
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
118
68
  - - ~>
119
- - !ruby/object:Gem::Version
120
- hash: 17
121
- segments:
122
- - 1
123
- - 0
124
- - 3
69
+ - !ruby/object:Gem::Version
125
70
  version: 1.0.3
126
- prerelease: false
127
- name: rubygems-bundler
128
- version_requirements: *id007
129
- - !ruby/object:Gem::Dependency
130
71
  type: :runtime
131
- requirement: &id008 !ruby/object:Gem::Requirement
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
132
74
  none: false
133
- requirements:
75
+ requirements:
134
76
  - - ~>
135
- - !ruby/object:Gem::Version
136
- hash: 5
137
- segments:
138
- - 0
139
- - 2
140
- - 9
141
- version: 0.2.9
142
- prerelease: false
77
+ - !ruby/object:Gem::Version
78
+ version: 1.0.3
79
+ - !ruby/object:Gem::Dependency
143
80
  name: equivalent-xml
144
- version_requirements: *id008
145
- - !ruby/object:Gem::Dependency
146
- type: :runtime
147
- requirement: &id009 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
148
82
  none: false
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- hash: 9
153
- segments:
154
- - 2
155
- - 0
156
- - 3
157
- version: 2.0.3
158
- prerelease: false
159
- name: net-ssh
160
- version_requirements: *id009
161
- - !ruby/object:Gem::Dependency
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: 0.2.9
162
87
  type: :runtime
163
- requirement: &id010 !ruby/object:Gem::Requirement
164
- none: false
165
- requirements:
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- hash: 21
169
- segments:
170
- - 1
171
- - 0
172
- - 1
173
- version: 1.0.1
174
88
  prerelease: false
175
- name: net-ssh-multi
176
- version_requirements: *id010
177
- - !ruby/object:Gem::Dependency
178
- type: :runtime
179
- requirement: &id011 !ruby/object:Gem::Requirement
89
+ version_requirements: !ruby/object:Gem::Requirement
180
90
  none: false
181
- requirements:
91
+ requirements:
182
92
  - - ~>
183
- - !ruby/object:Gem::Version
184
- hash: 31
185
- segments:
186
- - 1
187
- - 0
188
- - 4
189
- version: 1.0.4
190
- prerelease: false
191
- name: net-scp
192
- version_requirements: *id011
193
- - !ruby/object:Gem::Dependency
93
+ - !ruby/object:Gem::Version
94
+ version: 0.2.9
95
+ - !ruby/object:Gem::Dependency
96
+ name: nokogiri
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: 1.5.5
194
103
  type: :runtime
195
- requirement: &id012 !ruby/object:Gem::Requirement
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
196
106
  none: false
197
- requirements:
107
+ requirements:
198
108
  - - ~>
199
- - !ruby/object:Gem::Version
200
- hash: 9
201
- segments:
202
- - 1
203
- - 5
204
- - 5
109
+ - !ruby/object:Gem::Version
205
110
  version: 1.5.5
111
+ - !ruby/object:Gem::Dependency
112
+ name: knife-windows
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :runtime
206
120
  prerelease: false
207
- name: nokogiri
208
- version_requirements: *id012
209
- description: A plugin to Opscode knife for creating instances on the Microsoft Azure platform
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ description: A plugin to Opscode knife for creating instances on the Microsoft Azure
128
+ platform
210
129
  email: oss@opscode.com
211
130
  executables: []
212
-
213
131
  extensions: []
214
-
215
- extra_rdoc_files:
132
+ extra_rdoc_files:
216
133
  - LICENSE
217
- files:
134
+ files:
218
135
  - LICENSE
219
- - README.rdoc
220
- - lib/azure/image.rb
221
- - lib/azure/rest.rb
136
+ - README.md
137
+ - lib/azure/certificate.rb
222
138
  - lib/azure/connection.rb
223
- - lib/azure/host.rb
139
+ - lib/azure/deploy.rb
224
140
  - lib/azure/disk.rb
141
+ - lib/azure/host.rb
142
+ - lib/azure/image.rb
143
+ - lib/azure/rest.rb
144
+ - lib/azure/role.rb
225
145
  - lib/azure/storageaccount.rb
226
- - lib/azure/deploy.rb
227
146
  - lib/azure/utility.rb
228
- - lib/azure/role.rb
229
- - lib/knife-azure/version.rb
147
+ - lib/chef/knife/azure_base.rb
148
+ - lib/chef/knife/azure_image_list.rb
149
+ - lib/chef/knife/azure_server_create.rb
230
150
  - lib/chef/knife/azure_server_delete.rb
231
151
  - lib/chef/knife/azure_server_describe.rb
232
- - lib/chef/knife/azure_server_create.rb
233
- - lib/chef/knife/azure_image_list.rb
234
- - lib/chef/knife/azure_base.rb
235
152
  - lib/chef/knife/azure_server_list.rb
153
+ - lib/knife-azure/version.rb
236
154
  homepage: http://github.com/opscode/knife-azure
237
- licenses:
155
+ licenses:
238
156
  - Apache 2.0
239
157
  post_install_message:
240
158
  rdoc_options: []
241
-
242
- require_paths:
159
+ require_paths:
243
160
  - lib
244
- required_ruby_version: !ruby/object:Gem::Requirement
161
+ required_ruby_version: !ruby/object:Gem::Requirement
245
162
  none: false
246
- requirements:
247
- - - ">="
248
- - !ruby/object:Gem::Version
249
- hash: 3
250
- segments:
163
+ requirements:
164
+ - - ! '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ segments:
251
168
  - 0
252
- version: "0"
253
- required_rubygems_version: !ruby/object:Gem::Requirement
169
+ hash: -1796452093353551552
170
+ required_rubygems_version: !ruby/object:Gem::Requirement
254
171
  none: false
255
- requirements:
256
- - - ">="
257
- - !ruby/object:Gem::Version
258
- hash: 3
259
- segments:
260
- - 0
261
- version: "0"
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
262
176
  requirements: []
263
-
264
177
  rubyforge_project:
265
- rubygems_version: 1.8.10
178
+ rubygems_version: 1.8.23
266
179
  signing_key:
267
180
  specification_version: 3
268
181
  summary: A plugin to Opscode knife for creating instances on the Microsoft Azure platform
269
182
  test_files: []
270
-