knife-azure 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/{readme.rdoc → README.rdoc} +68 -26
  2. data/lib/azure/connection.rb +3 -1
  3. data/lib/azure/deploy.rb +3 -0
  4. data/lib/azure/host.rb +2 -2
  5. data/lib/azure/image.rb +2 -2
  6. data/lib/azure/rest.rb +8 -3
  7. data/lib/azure/role.rb +1 -1
  8. data/lib/azure/storageaccount.rb +87 -0
  9. data/lib/chef/knife/azure_base.rb +19 -17
  10. data/lib/chef/knife/azure_image_list.rb +13 -10
  11. data/lib/chef/knife/azure_server_create.rb +45 -13
  12. data/lib/knife-azure/version.rb +1 -1
  13. metadata +208 -178
  14. data/Gemfile +0 -22
  15. data/Guardfile +0 -8
  16. data/Rakefile +0 -51
  17. data/knife-azure.gemspec +0 -106
  18. data/spec/functional/deploys_test.rb +0 -39
  19. data/spec/functional/host_test.rb +0 -22
  20. data/spec/functional/images_list_test.rb +0 -44
  21. data/spec/functional/role_test.rb +0 -16
  22. data/spec/integration/role_lifecycle_test.rb +0 -60
  23. data/spec/spec_helper.rb +0 -41
  24. data/spec/unit/assets/create_deployment.xml +0 -37
  25. data/spec/unit/assets/create_deployment_in_progress.xml +0 -1
  26. data/spec/unit/assets/create_host.xml +0 -7
  27. data/spec/unit/assets/create_role.xml +0 -54
  28. data/spec/unit/assets/list_deployments_for_service000.xml +0 -126
  29. data/spec/unit/assets/list_deployments_for_service001.xml +0 -166
  30. data/spec/unit/assets/list_deployments_for_service002.xml +0 -1
  31. data/spec/unit/assets/list_deployments_for_service003.xml +0 -1
  32. data/spec/unit/assets/list_disks.xml +0 -1
  33. data/spec/unit/assets/list_hosts.xml +0 -1
  34. data/spec/unit/assets/list_images.xml +0 -1
  35. data/spec/unit/assets/post_success.xml +0 -6
  36. data/spec/unit/deploys_list_spec.rb +0 -55
  37. data/spec/unit/disks_spec.rb +0 -44
  38. data/spec/unit/hosts_spec.rb +0 -55
  39. data/spec/unit/images_spec.rb +0 -35
  40. data/spec/unit/query_azure_mock.rb +0 -69
  41. data/spec/unit/roles_create_spec.rb +0 -82
  42. data/spec/unit/roles_list_spec.rb +0 -32
@@ -97,20 +97,29 @@ class Chef
97
97
  :long => "--hosted-service-name NAME",
98
98
  :description => "specifies the name for the hosted service"
99
99
 
100
+ option :hosted_service_description,
101
+ :short => "-D DESCRIPTION",
102
+ :long => "--hosted_service_description DESCRIPTION",
103
+ :description => "Description for the hosted service"
104
+
105
+ option :storage_account,
106
+ :short => "-a NAME",
107
+ :long => "--storage-account NAME",
108
+ :description => "specifies the name for the hosted service"
109
+
100
110
  option :role_name,
101
111
  :short => "-R name",
102
112
  :long => "--role-name NAME",
103
113
  :description => "specifies the name for the virtual machine"
104
114
 
105
115
  option :host_name,
106
- :short => "-H NAME",
107
116
  :long => "--host-name NAME",
108
117
  :description => "specifies the host name for the virtual machine"
109
118
 
110
- option :media_location_prefix,
111
- :short => "-m PREFIX",
112
- :long => "--media-location-prefix PREFIX",
113
- :description => "user account name (used for constructing os disk media link)"
119
+ option :service_location,
120
+ :short => "-m LOCATION",
121
+ :long => "--service-location LOCATION",
122
+ :description => "specify the Geographic location for the virtual machine and services"
114
123
 
115
124
  option :os_disk_name,
116
125
  :short => "-o DISKNAME",
@@ -138,6 +147,14 @@ class Chef
138
147
  :description => "Comma separated list of UDP local and public ports to open i.e. '80:80,433:5000'"
139
148
 
140
149
 
150
+ def strip_non_ascii(string)
151
+ string.gsub(/[^0-9a-z ]/i, '')
152
+ end
153
+
154
+ def random_string(len=10)
155
+ (0...len).map{65.+(rand(25)).chr}.join
156
+ end
157
+
141
158
  def tcp_test_ssh(fqdn, sshport)
142
159
  tcp_socket = TCPSocket.new(fqdn, sshport)
143
160
  readable = IO.select([tcp_socket], nil, nil, 5)
@@ -174,14 +191,13 @@ class Chef
174
191
  details << ui.color('winner is', :bold, :blue)
175
192
  [
176
193
  :azure_subscription_id,
177
- :azure_pem_file,
194
+ :azure_mgmt_cert,
178
195
  :azure_host_name,
179
- :hosted_service_name,
180
196
  :role_name,
181
197
  :host_name,
182
198
  :ssh_user,
183
199
  :ssh_password,
184
- :media_location_prefix,
200
+ :service_location,
185
201
  :source_image,
186
202
  :role_size
187
203
  ].each do |key|
@@ -195,11 +211,27 @@ class Chef
195
211
  end
196
212
  def run
197
213
  $stdout.sync = true
214
+ storage = nil
198
215
 
199
216
  Chef::Log.info("validating...")
200
217
  validate!
201
218
 
202
219
  Chef::Log.info("creating...")
220
+
221
+ if not locate_config_value(:hosted_service_name)
222
+ config[:hosted_service_name] = [strip_non_ascii(locate_config_value(:role_name)), random_string].join
223
+ end
224
+
225
+ #If Storage Account is not specified, check if the geographic location has one to re-use
226
+ if not locate_config_value(:storage_account)
227
+ storage_accts = connection.storageaccounts.all
228
+ storage = storage_accts.find { |storage_acct| storage_acct.location.to_s == locate_config_value(:service_location) }
229
+ if not storage
230
+ config[:storage_account] = [strip_non_ascii(locate_config_value(:role_name)), random_string].join.downcase
231
+ else
232
+ config[:storage_account] = storage.name.to_s
233
+ end
234
+ end
203
235
  server = connection.deploys.create(create_server_def)
204
236
 
205
237
  puts("\n")
@@ -249,14 +281,13 @@ class Chef
249
281
  def validate!
250
282
  super([
251
283
  :azure_subscription_id,
252
- :azure_pem_file,
284
+ :azure_mgmt_cert,
253
285
  :azure_host_name,
254
- :hosted_service_name,
255
286
  :role_name,
256
287
  :host_name,
257
288
  :ssh_user,
258
289
  :ssh_password,
259
- :media_location_prefix,
290
+ :service_location,
260
291
  :source_image,
261
292
  :role_size
262
293
  ])
@@ -265,11 +296,12 @@ class Chef
265
296
  def create_server_def
266
297
  server_def = {
267
298
  :hosted_service_name => locate_config_value(:hosted_service_name),
299
+ :storage_account => locate_config_value(:storage_account),
268
300
  :role_name => locate_config_value(:role_name),
269
301
  :host_name => locate_config_value(:host_name),
270
- :ssh_user => locate_config_value(:ssh_user),
302
+ :ssh_user => locate_config_value(:ssh_user),
271
303
  :ssh_password => locate_config_value(:ssh_password),
272
- :media_location_prefix => locate_config_value(:media_location_prefix),
304
+ :service_location => locate_config_value(:service_location),
273
305
  :os_disk_name => locate_config_value(:os_disk_name),
274
306
  :source_image => locate_config_value(:source_image),
275
307
  :role_size => locate_config_value(:role_size),
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Azure
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.2"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,240 +1,270 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: knife-azure
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 2
10
+ version: 1.0.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Barry Davis
14
+ - Chirag Jog
9
15
  autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
- date: 2012-06-06 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: knife-azure
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
18
+
19
+ date: 2012-06-06 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
22
  type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ 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
23
35
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
36
+ name: rake
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ type: :runtime
40
+ requirement: &id002 !ruby/object:Gem::Requirement
25
41
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: rspec
32
- requirement: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 55
46
+ segments:
47
+ - 0
48
+ - 10
49
+ - 0
50
+ 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
33
57
  none: false
34
- requirements:
58
+ requirements:
35
59
  - - ~>
36
- - !ruby/object:Gem::Version
60
+ - !ruby/object:Gem::Version
61
+ hash: 47
62
+ segments:
63
+ - 2
64
+ - 8
65
+ - 0
37
66
  version: 2.8.0
38
- type: :development
39
67
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
68
+ name: rspec
69
+ version_requirements: *id003
70
+ - !ruby/object:Gem::Dependency
71
+ type: :runtime
72
+ requirement: &id004 !ruby/object:Gem::Requirement
41
73
  none: false
42
- requirements:
74
+ requirements:
43
75
  - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 2.8.0
46
- - !ruby/object:Gem::Dependency
76
+ - !ruby/object:Gem::Version
77
+ hash: 31
78
+ segments:
79
+ - 3
80
+ - 12
81
+ version: "3.12"
82
+ prerelease: false
47
83
  name: rdoc
48
- requirement: !ruby/object:Gem::Requirement
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ type: :runtime
87
+ requirement: &id005 !ruby/object:Gem::Requirement
49
88
  none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '3.12'
54
- type: :development
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
55
96
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '3.12'
62
- - !ruby/object:Gem::Dependency
63
97
  name: bundler
64
- requirement: !ruby/object:Gem::Requirement
98
+ version_requirements: *id005
99
+ - !ruby/object:Gem::Dependency
100
+ type: :runtime
101
+ requirement: &id006 !ruby/object:Gem::Requirement
65
102
  none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
71
110
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
111
  name: guard-rspec
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: libnotify
96
- requirement: !ruby/object:Gem::Requirement
112
+ version_requirements: *id006
113
+ - !ruby/object:Gem::Dependency
114
+ type: :runtime
115
+ requirement: &id007 !ruby/object:Gem::Requirement
97
116
  none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
117
+ requirements:
118
+ - - ~>
119
+ - !ruby/object:Gem::Version
120
+ hash: 17
121
+ segments:
122
+ - 1
123
+ - 0
124
+ - 3
125
+ version: 1.0.3
103
126
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
127
  name: rubygems-bundler
112
- requirement: !ruby/object:Gem::Requirement
128
+ version_requirements: *id007
129
+ - !ruby/object:Gem::Dependency
130
+ type: :runtime
131
+ requirement: &id008 !ruby/object:Gem::Requirement
113
132
  none: false
114
- requirements:
133
+ requirements:
115
134
  - - ~>
116
- - !ruby/object:Gem::Version
117
- version: 0.2.8
118
- type: :development
135
+ - !ruby/object:Gem::Version
136
+ hash: 5
137
+ segments:
138
+ - 0
139
+ - 2
140
+ - 9
141
+ version: 0.2.9
119
142
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ~>
124
- - !ruby/object:Gem::Version
125
- version: 0.2.8
126
- - !ruby/object:Gem::Dependency
127
- name: interactive_editor
128
- requirement: !ruby/object:Gem::Requirement
143
+ name: equivalent-xml
144
+ version_requirements: *id008
145
+ - !ruby/object:Gem::Dependency
146
+ type: :runtime
147
+ requirement: &id009 !ruby/object:Gem::Requirement
129
148
  none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :development
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ hash: 9
153
+ segments:
154
+ - 2
155
+ - 0
156
+ - 3
157
+ version: 2.0.3
135
158
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
159
+ name: net-ssh
160
+ version_requirements: *id009
161
+ - !ruby/object:Gem::Dependency
162
+ type: :runtime
163
+ requirement: &id010 !ruby/object:Gem::Requirement
137
164
  none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
- - !ruby/object:Gem::Dependency
143
- name: equivalent-xml
144
- requirement: !ruby/object:Gem::Requirement
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
+ 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
145
180
  none: false
146
- requirements:
181
+ requirements:
147
182
  - - ~>
148
- - !ruby/object:Gem::Version
149
- version: 0.2.9
150
- type: :development
183
+ - !ruby/object:Gem::Version
184
+ hash: 31
185
+ segments:
186
+ - 1
187
+ - 0
188
+ - 4
189
+ version: 1.0.4
151
190
  prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
191
+ name: net-scp
192
+ version_requirements: *id011
193
+ - !ruby/object:Gem::Dependency
194
+ type: :runtime
195
+ requirement: &id012 !ruby/object:Gem::Requirement
153
196
  none: false
154
- requirements:
197
+ requirements:
155
198
  - - ~>
156
- - !ruby/object:Gem::Version
157
- version: 0.2.9
158
- description: A plugin to Opscode knife for creating instances on the Microsoft Azure
159
- platform
199
+ - !ruby/object:Gem::Version
200
+ hash: 9
201
+ segments:
202
+ - 1
203
+ - 5
204
+ - 5
205
+ version: 1.5.5
206
+ prerelease: false
207
+ name: nokogiri
208
+ version_requirements: *id012
209
+ description: A plugin to Opscode knife for creating instances on the Microsoft Azure platform
160
210
  email: oss@opscode.com
161
211
  executables: []
212
+
162
213
  extensions: []
163
- extra_rdoc_files:
214
+
215
+ extra_rdoc_files:
164
216
  - LICENSE
165
- files:
166
- - Gemfile
167
- - Guardfile
217
+ files:
168
218
  - LICENSE
169
- - Rakefile
170
- - knife-azure.gemspec
171
- - lib/azure/connection.rb
172
- - lib/azure/deploy.rb
173
- - lib/azure/disk.rb
174
- - lib/azure/host.rb
219
+ - README.rdoc
175
220
  - lib/azure/image.rb
176
221
  - lib/azure/rest.rb
177
- - lib/azure/role.rb
222
+ - lib/azure/connection.rb
223
+ - lib/azure/host.rb
224
+ - lib/azure/disk.rb
225
+ - lib/azure/storageaccount.rb
226
+ - lib/azure/deploy.rb
178
227
  - lib/azure/utility.rb
179
- - lib/chef/knife/azure_base.rb
180
- - lib/chef/knife/azure_image_list.rb
181
- - lib/chef/knife/azure_server_create.rb
228
+ - lib/azure/role.rb
229
+ - lib/knife-azure/version.rb
182
230
  - lib/chef/knife/azure_server_delete.rb
183
231
  - 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
184
235
  - lib/chef/knife/azure_server_list.rb
185
- - lib/knife-azure/version.rb
186
- - readme.rdoc
187
- - spec/functional/deploys_test.rb
188
- - spec/functional/host_test.rb
189
- - spec/functional/images_list_test.rb
190
- - spec/functional/role_test.rb
191
- - spec/integration/role_lifecycle_test.rb
192
- - spec/spec_helper.rb
193
- - spec/unit/assets/create_deployment.xml
194
- - spec/unit/assets/create_deployment_in_progress.xml
195
- - spec/unit/assets/create_host.xml
196
- - spec/unit/assets/create_role.xml
197
- - spec/unit/assets/list_deployments_for_service000.xml
198
- - spec/unit/assets/list_deployments_for_service001.xml
199
- - spec/unit/assets/list_deployments_for_service002.xml
200
- - spec/unit/assets/list_deployments_for_service003.xml
201
- - spec/unit/assets/list_disks.xml
202
- - spec/unit/assets/list_hosts.xml
203
- - spec/unit/assets/list_images.xml
204
- - spec/unit/assets/post_success.xml
205
- - spec/unit/deploys_list_spec.rb
206
- - spec/unit/disks_spec.rb
207
- - spec/unit/hosts_spec.rb
208
- - spec/unit/images_spec.rb
209
- - spec/unit/query_azure_mock.rb
210
- - spec/unit/roles_create_spec.rb
211
- - spec/unit/roles_list_spec.rb
212
236
  homepage: http://github.com/opscode/knife-azure
213
- licenses:
237
+ licenses:
214
238
  - Apache 2.0
215
239
  post_install_message:
216
240
  rdoc_options: []
217
- require_paths:
241
+
242
+ require_paths:
218
243
  - lib
219
- required_ruby_version: !ruby/object:Gem::Requirement
244
+ required_ruby_version: !ruby/object:Gem::Requirement
220
245
  none: false
221
- requirements:
222
- - - ! '>='
223
- - !ruby/object:Gem::Version
224
- version: '0'
225
- segments:
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ hash: 3
250
+ segments:
226
251
  - 0
227
- hash: 3931309687418111457
228
- required_rubygems_version: !ruby/object:Gem::Requirement
252
+ version: "0"
253
+ required_rubygems_version: !ruby/object:Gem::Requirement
229
254
  none: false
230
- requirements:
231
- - - ! '>='
232
- - !ruby/object:Gem::Version
233
- version: '0'
255
+ requirements:
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ hash: 3
259
+ segments:
260
+ - 0
261
+ version: "0"
234
262
  requirements: []
263
+
235
264
  rubyforge_project:
236
- rubygems_version: 1.8.23
265
+ rubygems_version: 1.8.10
237
266
  signing_key:
238
267
  specification_version: 3
239
268
  summary: A plugin to Opscode knife for creating instances on the Microsoft Azure platform
240
269
  test_files: []
270
+