knife-hp 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,17 +1,19 @@
1
1
  # TODO #
2
2
  This is a list of features currently lacking and (eventually) under development:
3
- * filter out extraneous images from knife hp image list (requires HP metadata not yet available)
3
+ * should we sort the image list like the HP console does? segmented by Public/Partner/Private? "knife hp image list partner"?
4
4
  * should the node.name and node.id be the same (might have to fix this in the ohai plugin since this appears unavailable for setting)
5
5
  * take either the flavor ID or the flavor name for server create
6
6
  * take either the image ID or the image name for server create
7
- * Virtual cpus to `hp flavor list`?
8
7
  * Show the flavor and image names in `hp server list`
9
- * Floating IPs are assigned on creation, but the public ip is incorrect
10
- * Floating IPs are assigned on creation, support creating nodes without them (see knife-openstack's --private-network)
11
- * Floating IPs are freed on node deletion, support not freeing them
12
- * Re-assign a floating IPs on node creation
13
- * Create the `hp` Ohai plugin (or re-use the `openstack` one) to key off of the /etc/chef/ohai/hints/hp.json file, pulling from the meta-data service.
14
- * Validate ohai cloud support
8
+ * Validate ohai cloud support (waiting on OHAI-425)
9
+
10
+ ## v0.3.0
11
+ * update dependency on to Fog 1.10.0
12
+ * switched back to hp_access_key from hp_account_id since it's fixed in Fog 1.10.0
13
+ * remove support for floating IPs since they're no longer needed, reported by Simon McCartney and Rupak Ganguly
14
+ * 'delay-loading' changes to reduce load-time (Mohit Sethi)
15
+ * added 'knife hp group list' for listing security groups and their rules (KNIFE-227)
16
+ * filter out extraneous images from knife hp image list (requires HP metadata not yet available)
15
17
 
16
18
  ## v0.2.0
17
19
  * support for uneven_columns for prettier output
data/README.md CHANGED
@@ -3,7 +3,7 @@ Knife HP
3
3
 
4
4
  This is the official Opscode Knife plugin for HP Cloud Compute. This plugin gives knife the ability to create, bootstrap and manage instances in the HP Cloud.
5
5
 
6
- Please refer to the CHANGELOG.md for version history.
6
+ Please refer to the [CHANGELOG](CHANGELOG.md) for version history.
7
7
 
8
8
  # Installation #
9
9
 
@@ -21,15 +21,15 @@ Depending on your system's configuration, you may need to run this command with
21
21
 
22
22
  In order to communicate with HP Compute Cloud's API you will need to tell Knife the Access Key ID, the Secret Key and Tenant ID (found on the "API Keys" page). You may also override the auth URI and availability zone. The easiest way to accomplish this is to create these entries in your `knife.rb` file:
23
23
 
24
- knife[:hp_account_id] = "Your HP Cloud Access Key ID"
24
+ knife[:hp_access_key] = "Your HP Cloud Access Key ID"
25
25
  knife[:hp_secret_key] = "Your HP Cloud Secret Key"
26
26
  knife[:hp_tenant_id] = "Your HP Cloud Tenant ID"
27
- knife[:hp_auth_uri] = "Your HP Cloud Auth URI" (optional, default is "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/")
28
- knife[:hp_avl_zone] = "Your HP Cloud Availability Zone" (optional, default is "az1")
27
+ knife[:hp_auth_uri] = "Your HP Cloud Auth URI" (optional, default is 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/')
28
+ knife[:hp_avl_zone] = "Your HP Cloud Availability Zone" (optional, default is 'az1', choices are 'az1', 'az2' or 'az3')
29
29
 
30
30
  If your knife.rb file will be checked into a SCM system (ie readable by others) you may want to read the values from environment variables:
31
31
 
32
- knife[:hp_account_id] = "#{ENV['HP_ACCESS_KEY']}"
32
+ knife[:hp_access_key] = "#{ENV['HP_ACCESS_KEY']}"
33
33
  knife[:hp_secret_key] = "#{ENV['HP_SECRET_KEY']}"
34
34
  knife[:hp_tenant_id] = "#{ENV['HP_TENANT_ID']}"
35
35
  knife[:hp_auth_uri] = "#{ENV['HP_AUTH_URI']}"
@@ -37,11 +37,11 @@ If your knife.rb file will be checked into a SCM system (ie readable by others)
37
37
 
38
38
  You also have the option of passing your HP Cloud API options from the command line:
39
39
 
40
- `-A` (or `--hp-account`) your HP Cloud Access Key ID
40
+ `-A` (or `--hp-access`) your HP Cloud Access Key ID
41
41
  `-K` (or `--hp-secret`) your HP Cloud Secret Key
42
42
  `-T` (or `--hp-tenant`) your HP Cloud Tenant ID
43
- `--hp-auth` your HP Cloud Auth URI (optional, default is "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/")
44
- `-Z` (or `--hp-zone`) your HP Cloud Availability Zone (optional, default is "az1")
43
+ `--hp-auth` your HP Cloud Auth URI (optional, default is 'https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/')
44
+ `-Z` (or `--hp-zone`) your HP Cloud Availability Zone (optional, default is 'az1', choices are 'az1', 'az2' or 'az3')
45
45
 
46
46
  knife hp server create -A 'MyUsername' -K 'MyPassword' -T 'MyTenant' -f 101 -I 120 -S hpkeypair -i ~/.ssh/hpkeypair.pem -r 'role[webserver]'
47
47
 
@@ -59,14 +59,14 @@ This plugin provides the following Knife subcommands. Specific command options c
59
59
  knife hp server create
60
60
  ----------------------
61
61
 
62
- Provisions a new server in the HP Compute 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 [chef-full](https://github.com/opscode/chef/blob/master/chef/lib/chef/knife/bootstrap/chef-full.erb) template. This can be overridden using the `-d` or `--template-file` command options. If you do not pass a node name with `-N NAME` (or `--node-name NAME`) a name will be generated for the node. The default behavior for nodes created through HP's API are to be given an public floating address.
62
+ Provisions a new server in the HP Compute 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 [chef-full](https://github.com/opscode/chef/blob/master/chef/lib/chef/knife/bootstrap/chef-full.erb) template. This can be overridden using the `-d` or `--template-file` command options. If you do not pass a node name with `-N NAME` (or `--node-name NAME`) a name will be generated for the node.
63
63
 
64
64
  knife hp server create -f 101 -I 9883 -S hpkeypair -i ~/.ssh/hpkeypair.pem -Z az2 -x ubuntu
65
65
 
66
66
  knife hp server delete
67
67
  ----------------------
68
68
 
69
- Deletes an existing server in the currently configured HP Compute Cloud account. <b>PLEASE NOTE</b> - this does not delete the associated node and client objects from the Chef Server without using the `-P` or `--purge` option to purge the client. The floating address associated with the node is released on deletion.
69
+ Deletes an existing server in the currently configured HP Compute Cloud account. <b>PLEASE NOTE</b> - this does not delete the associated node and client objects from the Chef Server without using the `-P` or `--purge` option to purge the client.
70
70
 
71
71
  knife hp server list
72
72
  --------------------
@@ -76,26 +76,29 @@ Outputs a list of all servers in the currently configured HP Compute Cloud accou
76
76
  knife hp flavor list
77
77
  --------------------
78
78
 
79
- Outputs a list of all available flavors (available hardware configuration for a server) available to the currently configured HP Compute Cloud account. Each flavor has a unique combination of virtual cores, disk space and memory capacity. This data can be useful when choosing a flavor id to pass to the `knife hp server create` subcommand.
79
+ Outputs a list of all flavors (hardware configuration for a server) available to the currently configured HP Compute Cloud account. Each flavor has a unique combination of virtual cores, disk space and memory capacity. This data may be useful when choosing a flavor id to pass to the `knife hp server create` subcommand.
80
80
 
81
81
  knife hp image list
82
82
  -------------------
83
83
 
84
- Outputs a list of all available images available to the currently configured HP Compute Cloud account. An image is a collection of files used to create or rebuild a server. Currently the list returned is unfiltered and does not match the view on the dashboard, images with "(Kernel)" and "(Ramdisk)" are not intended for use bootstrapping. This data can be useful when choosing an image id to pass to the `knife hp server create` subcommand.
84
+ Outputs a list of all images available to the currently configured HP Compute Cloud account. An image is a collection of files used to create or rebuild a server. The returned list filtered and does not contain images with "(deprecated)", "(Kernel)" or "(Ramdisk)" in their names (this may be disabled with `--disable-filter`). This data may be useful when choosing an image id to pass to the `knife hp server create` subcommand.
85
+
86
+ knife hp group list
87
+ --------------------
88
+
89
+ Outputs a list of the security groups available to the currently configured HP Compute Cloud account. Each group may have multiple rules. This data may be useful when choosing your security group(s) to pass to the `knife hp server create` subcommand.
85
90
 
86
91
  KNOWN ISSUES
87
92
  ============
88
- There are a number of known issues waiting for upstream patches to be merged in Fog and added to Ohai. The CHANGELOG.md has more missing/incomplete features listed.
89
93
 
90
- * az1 is currently unavailable via Fog. The default Availability Zone through the API is 'az3', even when specifying 'az1'. Yet 'az3' is unavailable as an selection option (https://github.com/fog/fog/pull/903). To work with az3, do not pass an Availability Zone at all. See also https://github.com/fog/fog/issues/1175
91
- * The names of the HP Cloud Access Key ID should change from `hp_access_key` to `hp_account_id` to match HP's description https://github.com/fog/fog/pull/902
92
- * There is no support in Ohai yet, but the empty `/etc/chef/ohai/hints/hp.json` is created. http://tickets.opscode.com/browse/OHAI-335
94
+ * There is no support in Ohai yet, but the empty `/etc/chef/ohai/hints/hp.json` is created. http://tickets.opscode.com/browse/OHAI-425
95
+ * The [CHANGELOG](CHANGELOG.md) has more missing/incomplete features listed.
93
96
 
94
97
  # License #
95
98
 
96
99
  Author:: Matt Ray (<matt@opscode.com>)
97
100
 
98
- Copyright:: Copyright (c) 2012 Opscode, Inc.
101
+ Copyright:: Copyright (c) 2012-2013 Opscode, Inc.
99
102
 
100
103
  License:: Apache License, Version 2.0
101
104
 
data/knife-hp.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency "fog", "~> 1.4"
22
+ s.add_dependency "fog", ">= 1.10.0"
23
23
  s.add_dependency "chef", ">= 0.10.10"
24
24
 
25
25
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Matt Ray (<matt@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
3
+ # Copyright:: Copyright (c) 2012-2013 Opscode, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife'
19
+ require 'fog'
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -29,16 +29,17 @@ class Chef
29
29
  includer.class_eval do
30
30
 
31
31
  deps do
32
- require 'fog'
33
- require 'readline'
34
32
  require 'chef/json_compat'
33
+ require 'chef/knife'
34
+ require 'readline'
35
+ Chef::Knife.load_deps
35
36
  end
36
37
 
37
- option :hp_account_id,
38
+ option :hp_access_key,
38
39
  :short => "-A ID",
39
- :long => "--hp-account ID",
40
+ :long => "--hp-access ID",
40
41
  :description => "Your HP Cloud Access Key ID",
41
- :proc => Proc.new { |key| Chef::Config[:knife][:hp_account_id] = key }
42
+ :proc => Proc.new { |key| Chef::Config[:knife][:hp_access_key] = key }
42
43
 
43
44
  option :hp_secret_key,
44
45
  :short => "-K SECRET",
@@ -62,25 +63,25 @@ class Chef
62
63
  :short => "-Z Zone",
63
64
  :long => "--hp-zone Zone",
64
65
  :default => "az1",
65
- :description => "Your HP Cloud Availability Zone (az1/az2)",
66
+ :description => "Your HP Cloud Availability Zone (az1/az2/az3)",
66
67
  :proc => Proc.new { |key| Chef::Config[:knife][:hp_avl_zone] = key }
67
68
  end
68
69
  end
69
70
 
70
71
  def connection
71
- Chef::Log.debug("hp_account_id: #{Chef::Config[:knife][:hp_account_id]}")
72
+ Chef::Log.debug("hp_access_key: #{Chef::Config[:knife][:hp_access_key]}")
72
73
  Chef::Log.debug("hp_secret_key: #{Chef::Config[:knife][:hp_secret_key]}")
73
74
  Chef::Log.debug("hp_tenant_id: #{Chef::Config[:knife][:hp_tenant_id]}")
74
75
  Chef::Log.debug("hp_auth_uri: #{locate_config_value(:hp_auth_uri)}")
75
- Chef::Log.debug("hp_avl_zone: #{locate_config_value(:hp_avl_zone)}")
76
+ Chef::Log.debug("hp_avl_zone: #{availability_zone()}")
76
77
  @connection ||= begin
77
78
  connection = Fog::Compute.new(
78
79
  :provider => 'HP',
79
- :hp_account_id => Chef::Config[:knife][:hp_account_id],
80
+ :hp_access_key => Chef::Config[:knife][:hp_access_key],
80
81
  :hp_secret_key => Chef::Config[:knife][:hp_secret_key],
81
82
  :hp_tenant_id => Chef::Config[:knife][:hp_tenant_id],
82
83
  :hp_auth_uri => locate_config_value(:hp_auth_uri),
83
- :hp_avl_zone => locate_config_value(:hp_avl_zone).to_sym
84
+ :hp_avl_zone => availability_zone()
84
85
  )
85
86
  end
86
87
  end
@@ -96,7 +97,7 @@ class Chef
96
97
  end
97
98
  end
98
99
 
99
- def validate!(keys=[:hp_account_id, :hp_secret_key, :hp_tenant_id])
100
+ def validate!(keys=[:hp_access_key, :hp_secret_key, :hp_tenant_id])
100
101
  errors = []
101
102
 
102
103
  keys.each do |k|
@@ -111,6 +112,17 @@ class Chef
111
112
  end
112
113
  end
113
114
 
115
+ def availability_zone()
116
+ case locate_config_value(:hp_avl_zone)
117
+ when 'az3'
118
+ return 'az-3.region-a.geo-1'
119
+ when 'az2'
120
+ return 'az-2.region-a.geo-1'
121
+ else
122
+ return 'az-1.region-a.geo-1'
123
+ end
124
+ end
125
+
114
126
  end
115
127
  end
116
128
  end
@@ -0,0 +1,57 @@
1
+ #
2
+ # Author:: Matt Ray (<matt@opscode.com>)
3
+ # Copyright:: Copyright (c) 2013 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/hp_base'
20
+
21
+ class Chef
22
+ class Knife
23
+ class HpGroupList < Knife
24
+
25
+ include Knife::HpBase
26
+
27
+ banner "knife hp group list (options)"
28
+
29
+ def run
30
+
31
+ validate!
32
+
33
+ group_list = [
34
+ ui.color('Name', :bold),
35
+ ui.color('Protocol', :bold),
36
+ ui.color('From', :bold),
37
+ ui.color('To', :bold),
38
+ ui.color('CIDR', :bold),
39
+ ui.color('Description', :bold),
40
+ ]
41
+ connection.security_groups.sort_by(&:name).each do |group|
42
+ group.rules.each do |rule|
43
+ unless rule['ip_protocol'].nil?
44
+ group_list << group.name
45
+ group_list << rule['ip_protocol']
46
+ group_list << rule['from_port'].to_s
47
+ group_list << rule['to_port'].to_s
48
+ group_list << rule['ip_range']['cidr']
49
+ group_list << group.description
50
+ end
51
+ end
52
+ end
53
+ puts ui.list(group_list, :uneven_columns_across, 6)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -26,6 +26,12 @@ class Chef
26
26
 
27
27
  banner "knife hp image list (options)"
28
28
 
29
+ option :disable_filter,
30
+ :long => "--disable-filter",
31
+ :description => "Disable filtering of the image list. Currently filters names containing '(deprecated)', '(Ramdisk)' and '(Kernel)'",
32
+ :boolean => true,
33
+ :default => false
34
+
29
35
  def run
30
36
 
31
37
  validate!
@@ -33,21 +39,16 @@ class Chef
33
39
  image_list = [
34
40
  ui.color('ID', :bold),
35
41
  ui.color('Name', :bold),
36
- # ui.color('Kernel ID', :bold),
37
- # ui.color('Architecture', :bold),
38
- # ui.color('Root Store', :bold),
39
- # ui.color('Location', :bold)
40
42
  ]
41
43
 
42
44
  connection.images.sort_by do |image|
43
45
  [image.name.downcase, image.id].compact
44
46
  end.each do |image|
45
- image_list << image.id
46
- image_list << image.name
47
- # image_list << image.kernel_id
48
- # image_list << image.architecture
49
- # image_list << image.root_device_type
50
- # image_list << image.location
47
+ unless ((image.name =~ /(deprecated)|(Ramdisk)|(Kernel)/) &&
48
+ !config[:disable_filter])
49
+ image_list << image.id
50
+ image_list << image.name
51
+ end
51
52
  end
52
53
 
53
54
  image_list = image_list.map do |item|
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Matt Ray (<matt@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
3
+ # Copyright:: Copyright (c) 2012-2013 Opscode, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,9 +25,6 @@ class Chef
25
25
  include Knife::HpBase
26
26
 
27
27
  deps do
28
- require 'fog'
29
- require 'readline'
30
- require 'chef/json_compat'
31
28
  require 'chef/knife/bootstrap'
32
29
  Chef::Knife::Bootstrap.load_deps
33
30
  end
@@ -120,6 +117,12 @@ class Chef
120
117
  :boolean => true,
121
118
  :default => true
122
119
 
120
+ option :private_network,
121
+ :long => '--private-network',
122
+ :description => 'Use the private IP for bootstrapping rather than the public IP',
123
+ :boolean => true,
124
+ :default => false
125
+
123
126
  def tcp_test_ssh(hostname)
124
127
  tcp_socket = TCPSocket.new(hostname, 22)
125
128
  readable = IO.select([tcp_socket], nil, nil, 5)
@@ -149,21 +152,8 @@ class Chef
149
152
 
150
153
  validate!
151
154
 
152
- connection = Fog::Compute.new(
153
- :provider => 'HP',
154
- :hp_account_id => Chef::Config[:knife][:hp_account_id],
155
- :hp_secret_key => Chef::Config[:knife][:hp_secret_key],
156
- :hp_tenant_id => Chef::Config[:knife][:hp_tenant_id],
157
- :hp_auth_uri => locate_config_value(:hp_auth_uri),
158
- :hp_avl_zone => locate_config_value(:hp_avl_zone).to_sym
159
- )
160
-
161
- #request and assign a floating IP for the server
162
- address = connection.addresses.create()
163
- Chef::Log.debug("Floating IP #{address.ip}")
164
-
165
155
  #servers require a name, generate one if not passed
166
- node_name = get_node_name(config[:chef_node_name], address.ip)
156
+ node_name = get_node_name(config[:chef_node_name])
167
157
 
168
158
  Chef::Log.debug("Name #{node_name}")
169
159
  Chef::Log.debug("Flavor #{locate_config_value(:flavor)}")
@@ -189,7 +179,7 @@ class Chef
189
179
  msg_pair("Instance Name", server.name)
190
180
  msg_pair("Flavor", server.flavor['id'])
191
181
  msg_pair("Image", server.image['id'])
192
- #msg_pair("Security Group(s)", server.security_groups.join(", "))
182
+ msg_pair("Security Group(s)", server.security_groups.collect {|x| x['name']}.join(", "))
193
183
  msg_pair("SSH Key Pair", server.key_name)
194
184
 
195
185
  print "\n#{ui.color("Waiting for server", :magenta)}"
@@ -197,35 +187,38 @@ class Chef
197
187
  # wait for it to be ready to do stuff
198
188
  server.wait_for { print "."; ready? }
199
189
 
200
- address.server = server
201
-
202
- server.wait_for { print "."; ready? }
203
-
204
190
  puts("\n")
205
191
 
206
192
  msg_pair("Public IP Address", server.public_ip_address)
207
193
  msg_pair("Private IP Address", server.private_ip_address)
208
194
 
195
+ # bootstrap using private network.
196
+ if config[:private_network]
197
+ bootstrap_ip_address = server.private_ip_address
198
+ else
199
+ bootstrap_ip_address = server.public_ip_address
200
+ end
201
+
209
202
  print "\n#{ui.color("Waiting for sshd", :magenta)}"
210
203
 
211
- #hack to ensure the nodes have had time to spin up
204
+ # hack to ensure the nodes have had time to spin up
212
205
  print(".")
213
206
  sleep 30
214
207
  print(".")
215
208
 
216
- print(".") until tcp_test_ssh(server.public_ip_address) {
209
+ print(".") until tcp_test_ssh(bootstrap_ip_address) {
217
210
  sleep @initial_sleep_delay ||= 10
218
211
  puts("done")
219
212
  }
220
213
 
221
- bootstrap_for_node(server).run
214
+ bootstrap_for_node(server, bootstrap_ip_address).run
222
215
 
223
216
  puts "\n"
224
217
  msg_pair("Instance ID", server.id)
225
218
  msg_pair("Instance Name", server.name)
226
219
  msg_pair("Flavor", server.flavor['id'])
227
220
  msg_pair("Image", server.image['id'])
228
- #msg_pair("Security Group(s)", server.security_groups.join(", "))
221
+ msg_pair("Security Group(s)", server.security_groups.collect {|x| x['name']}.join(", "))
229
222
  msg_pair("SSH Key Pair", server.key_name)
230
223
  msg_pair("Public IP Address", server.public_ip_address)
231
224
  msg_pair("Private IP Address", server.private_ip_address)
@@ -233,9 +226,9 @@ class Chef
233
226
  msg_pair("Run List", config[:run_list].join(', '))
234
227
  end
235
228
 
236
- def bootstrap_for_node(server)
229
+ def bootstrap_for_node(server, bootstrap_ip_address)
237
230
  bootstrap = Chef::Knife::Bootstrap.new
238
- bootstrap.name_args = [server.public_ip_address]
231
+ bootstrap.name_args = bootstrap_ip_address
239
232
  bootstrap.config[:run_list] = config[:run_list]
240
233
  bootstrap.config[:ssh_user] = config[:ssh_user]
241
234
  bootstrap.config[:identity_file] = config[:identity_file]
@@ -251,24 +244,34 @@ class Chef
251
244
  bootstrap
252
245
  end
253
246
 
254
- def ami
255
- @ami ||= connection.images.get(locate_config_value(:image))
247
+ def flavor
248
+ @flavor ||= connection.flavors.get(locate_config_value(:flavor))
249
+ end
250
+
251
+ def image
252
+ @image ||= connection.images.get(locate_config_value(:image))
256
253
  end
257
254
 
258
255
  def validate!
259
256
 
260
- super([:image, :flavor, :hp_account_id, :hp_secret_key, :hp_tenant_id])
257
+ super([:image, :flavor, :hp_access_key, :hp_secret_key, :hp_tenant_id])
258
+
259
+ if flavor.nil?
260
+ ui.error("You have not provided a valid flavor ID. Please note the options for this value are -f or --flavor.")
261
+ exit 1
262
+ end
261
263
 
262
- if ami.nil?
263
- ui.error("You have not provided a valid image ID. Please note the short option for this value recently changed from '-i' to '-I'.")
264
+ if image.nil?
265
+ ui.error("You have not provided a valid image ID. Please note the options for this value are -I or --image.")
264
266
  exit 1
265
267
  end
266
268
  end
267
269
 
268
- #generate a name from the IP if chef_node_name is empty
269
- def get_node_name(chef_node_name, ipaddress)
270
+ #generate a random name if chef_node_name is empty
271
+ def get_node_name(chef_node_name)
270
272
  return chef_node_name unless chef_node_name.nil?
271
- chef_node_name = "hp"+ipaddress.gsub(/\./,'-')
273
+ #lazy uuids
274
+ chef_node_name = "hp-"+rand.to_s.split('.')[1]
272
275
  end
273
276
  end
274
277
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Hp
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-hp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,24 +10,24 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-09-26 00:00:00.000000000 Z
13
+ date: 2013-03-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fog
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - ~>
20
+ - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: '1.4'
22
+ version: 1.10.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
- - - ~>
28
+ - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
- version: '1.4'
30
+ version: 1.10.0
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: chef
33
33
  requirement: !ruby/object:Gem::Requirement
@@ -63,6 +63,7 @@ files:
63
63
  - knife-hp.gemspec
64
64
  - lib/chef/knife/hp_base.rb
65
65
  - lib/chef/knife/hp_flavor_list.rb
66
+ - lib/chef/knife/hp_group_list.rb
66
67
  - lib/chef/knife/hp_image_list.rb
67
68
  - lib/chef/knife/hp_server_create.rb
68
69
  - lib/chef/knife/hp_server_delete.rb