knife-openstack 1.1.0 → 1.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ea242685d75f01b20a70637b61cf4ab62c709c3
4
- data.tar.gz: 43e9ef99f3d74ef0d31c94aa816fc74c34d980f4
3
+ metadata.gz: a33976b5305864956528c1fedbabe2defc0c4e11
4
+ data.tar.gz: ba9af32d2611e5a80b0d24cdae159f11298ff79e
5
5
  SHA512:
6
- metadata.gz: 913697f43e80f4b1f7fa9a2bd0f7076e861cc91a30daacbe415d51f8bb72c02c03b65201274709d991bba36b9a8784dff84050833943caddf27671ba273f27e1
7
- data.tar.gz: 983ad39ab270c263102031a1027aa7c8d51f8a0246ae4683aa9df06c70f20519399aec1c30aad535e0df731b1e8f80f40cee5078cf7d2e5934499197fcb4aa92
6
+ metadata.gz: eda31037c9f771f7cb86cdacafcefc6c180e873f1338ea6e872b6c4cb2fafb4831a008790ef02b219703afcc287aea13bccf7687d1904408f608d41b9e4b2418
7
+ data.tar.gz: f8ffbe6ad7b916d5e296e82ff5cf26971b848a6f9233e547f13afce68cf69bbae7ca1d21ae84125807d9caa8ae884768c89d8968ad85853bd15bbe676f960bd1
@@ -1,3 +1,7 @@
1
+ ## v1.2.0
2
+ * Allow users to specify alternate private networks. #163
3
+ * Vol sched 1.0.0work #142
4
+
1
5
  ## v1.1.0
2
6
  * Update the travis tests
3
7
  * Added Multi-region support
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Knife OpenStack
4
4
  ===============
5
5
 
6
- This is the official Chef Knife plugin for OpenStack Compute (Nova). This plugin gives knife the ability to create, bootstrap and manage instances in OpenStack Compute clouds. It has been tested against the `Diablo` through `Juno` releases in configurations using Keystone against the OpenStack API (as opposed to the EC2 API).
6
+ This is the official Chef Knife plugin for OpenStack Compute (Nova). This plugin gives knife the ability to create, bootstrap and manage instances in OpenStack Compute clouds. It has been tested against the `Diablo` through `Kilo` releases in configurations using Keystone against the OpenStack API (as opposed to the EC2 API).
7
7
 
8
8
  Please refer to the [CHANGELOG](CHANGELOG.md) for version history and known issues.
9
9
 
@@ -11,12 +11,12 @@ Please refer to the [CHANGELOG](CHANGELOG.md) for version history and known issu
11
11
 
12
12
  Be sure you are running the latest version Chef. Versions earlier than 0.10.0 don't support plugins:
13
13
 
14
- $ curl -L https://chef.io/chef/install.sh > /tmp/install.sh && sudo bash /tmp/install.sh
14
+ $ curl -L https://chef.io/chef/install.sh | sudo bash
15
15
 
16
16
  This plugin is distributed as a Ruby Gem. To install it, run:
17
17
 
18
18
  $ chef gem install knife-openstack
19
- $ # OR
19
+ OR
20
20
  $ gem install knife-openstack
21
21
 
22
22
  Depending on your system's configuration, you may need to run this command with root privileges.
@@ -38,7 +38,7 @@ If your knife.rb file will be checked into a SCM system (ie readable by others)
38
38
  knife[:openstack_username] = "#{ENV['OS_USERNAME']}"
39
39
  knife[:openstack_password] = "#{ENV['OS_PASSWORD']}"
40
40
  knife[:openstack_tenant] = "#{ENV['OS_TENANT_NAME']}"
41
- knife[:openstack_region] = "#{ENV['OS_region_NAME']}"
41
+ knife[:openstack_region] = "#{ENV['OS_REGION_NAME']}"
42
42
 
43
43
  If your OpenStack deployment is over SSL, but does not have a valid certificate, you can add the following option to bypass SSL check:
44
44
 
@@ -84,7 +84,7 @@ This plugin provides the following Knife subcommands. Specific command options c
84
84
  knife openstack server create
85
85
  -----------------------------
86
86
 
87
- Provisions a new server in an OpenStack 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 (default since the 10.10 release). This may be overridden using the `-d` or `--template-file` command options. If you do not have public IP addresses, use the `--private-network` option to use the private IP address for bootstrapping or `--bootstrap-network NAME` to specify an alternate network. Please see `knife openstack server create --help` for all of the supported options.
87
+ Provisions a new server in an OpenStack 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 (default since the 10.10 release). This may be overridden using the `-d` or `--template-file` command options. If you do not have public IP addresses, use the `--openstack-private-network` option to use the private IP address for bootstrapping. In addition, you can use the `--bootstrap-network NAME` option to specify an alternate network for either a private or public network. If a network name isn't specified, the default name will be `'public'` for a public network and `'private'` for a private network e.g. when the `--openstack-private-network` option is specified. Please see `knife openstack server create --help` for all of the supported options.
88
88
 
89
89
  knife openstack server delete
90
90
  -----------------------------
@@ -101,6 +101,11 @@ knife openstack flavor list
101
101
 
102
102
  Provides a list of all available flavors (available "hardware" configurations for a server) available to the currently configured OpenStack account. Each flavor has a unique combination of virtual cpus, disk space and memory capacity. This data may be useful when choosing a flavor to pass to the `knife openstack server create` subcommand.
103
103
 
104
+ knife openstack volume list
105
+ ---------------------------
106
+
107
+ Provides a list of all volumes in the currently configured OpenStack account. Each volume shows its size and its availibility to be attached to server. This data may be useful when choosing a volume to pass to the `knife openstack server create` subcommand.
108
+
104
109
  knife openstack image list
105
110
  --------------------------
106
111
 
@@ -124,6 +129,8 @@ Author:: Matt Ray (<matt@chef.io>)
124
129
 
125
130
  Author:: Chirag Jog (<chirag@clogeny.com>)
126
131
 
132
+ Author:: JJ Asghar (<jj@chef.io>)
133
+
127
134
  Copyright:: Copyright (c) 2011-2015 Chef Software, Inc.
128
135
 
129
136
  License:: Apache License, Version 2.0
@@ -22,6 +22,16 @@ class Chef
22
22
  :default => "-1",
23
23
  :description => "Request to associate a floating IP address to the new OpenStack node. Assumes IPs have been allocated to the project. Specific IP is optional."
24
24
 
25
+ option :openstack_volumes,
26
+ :long => "--openstack-volumes VOLUME1,VOLUME2,VOLUME3",
27
+ :description => "Comma separated list of the UUID(s) of the volume(s) to attach to the server",
28
+ :proc => Proc.new { |volumes| volumes.split(',') }
29
+
30
+ option :openstack_scheduler_hints,
31
+ :long => "--scheduler-hints HINTS",
32
+ :description => "A scheduler group hint to OpenStack",
33
+ :proc => Proc.new { |i| Chef::Config[:knife][:openstack_scheduler_hints] = i }
34
+
25
35
  option :openstack_security_groups,
26
36
  :short => "-G X,Y,Z",
27
37
  :long => "--openstack-groups X,Y,Z",
@@ -34,7 +44,7 @@ class Chef
34
44
  :long => "--openstack-ssh-key-id KEY",
35
45
  :description => "The OpenStack SSH keypair id",
36
46
  :proc => Proc.new { |key| Chef::Config[:knife][:openstack_ssh_key_id] = key }
37
-
47
+
38
48
  option :user_data,
39
49
  :long => "--user-data USER_DATA",
40
50
  :description => "The file path containing user data information for this server",
@@ -47,11 +47,24 @@ class Chef
47
47
  :flavor_ref => service.get_flavor(locate_config_value(:flavor)).id,
48
48
  :security_groups => locate_config_value(:openstack_security_groups),
49
49
  :availability_zone => locate_config_value(:availability_zone),
50
+ "os:scheduler_hints" => locate_config_value(:openstack_scheduler_hints),
50
51
  :metadata => locate_config_value(:metadata),
51
52
  :key_name => locate_config_value(:openstack_ssh_key_id)
52
53
  },
53
54
  :server_create_timeout => locate_config_value(:server_create_timeout)
54
55
  }
56
+ unless locate_config_value(:openstack_volumes).nil?
57
+ counter = 99
58
+ @create_options[:server_def][:block_device_mapping] = locate_config_value(:openstack_volumes).map do |vol|
59
+ counter += 1
60
+ {
61
+ :volume_id => vol,
62
+ :delete_on_termination => false,
63
+ :device_name => "/dev/vd"+counter.chr,
64
+ :volume_size => nil,
65
+ }
66
+ end
67
+ end
55
68
 
56
69
  @create_options[:server_def].merge!({:user_data => locate_config_value(:user_data)}) if locate_config_value(:user_data)
57
70
  @create_options[:server_def].merge!({:nics => locate_config_value(:network_ids).map { |nic| nic_id = { 'net_id' => nic }}}) if locate_config_value(:network_ids)
@@ -129,8 +142,10 @@ class Chef
129
142
  # Use SSH password either specified from command line or from openstack server instance
130
143
  config[:ssh_password] = locate_config_value(:ssh_password) || server.password unless config[:openstack_ssh_key_id]
131
144
 
132
- # private_network means bootstrap_network = 'private'
133
- config[:bootstrap_network] = 'private' if config[:private_network]
145
+ # The bootstrap network is always initialised to 'public' when a network name isn't specified. Therefore,
146
+ # only set the bootstrap network to 'private' if still initialised to public and nothing was specified for
147
+ # the private network name.
148
+ config[:bootstrap_network] = 'private' if (config[:private_network] && config[:bootstrap_network] == 'public')
134
149
 
135
150
  # Which IP address to bootstrap
136
151
  unless config[:network] # --no-network
@@ -0,0 +1,70 @@
1
+ #
2
+ # Author:: Seth Chisamore (<schisamo@getchef.com>)
3
+ # Author:: Matt Ray (<matt@getchef.com>)
4
+ # Author:: Evan Felix (<karcaw@gmail.com>)
5
+ # Copyright:: Copyright (c) 2011-2014 Chef Software, Inc.
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+
21
+ require 'chef/knife/cloud/list_resource_command'
22
+ require 'chef/knife/openstack_helpers'
23
+ require 'chef/knife/cloud/openstack_service_options'
24
+
25
+ class Chef
26
+ class Knife
27
+ class Cloud
28
+ class OpenstackVolumeList < ResourceListCommand
29
+ include OpenstackHelpers
30
+ include OpenstackServiceOptions
31
+
32
+ banner "knife openstack volume list (options)"
33
+
34
+ def query_resource
35
+ begin
36
+ @service.connection.volumes
37
+ rescue Excon::Errors::BadRequest => e
38
+ response = Chef::JSONCompat.from_json(e.response.body)
39
+ ui.fatal("Unknown server error (#{response['badRequest']['code']}): #{response['badRequest']['message']}")
40
+ raise e
41
+ end
42
+ end
43
+
44
+ def list(volumes)
45
+ volume_list = [
46
+ ui.color('Name', :bold),
47
+ ui.color('ID', :bold),
48
+ ui.color('Status', :bold),
49
+ ui.color('Size', :bold),
50
+ ui.color('Description', :bold),
51
+ ]
52
+ begin
53
+ volumes.sort_by(&:name).each do |volume|
54
+ volume_list << volume.name
55
+ volume_list << volume.id.to_s
56
+ volume_list << volume.status
57
+ volume_list << "#{volume.size.to_s} GB"
58
+ volume_list << volume.description
59
+ end
60
+ rescue Excon::Errors::BadRequest => e
61
+ response = Chef::JSONCompat.from_json(e.response.body)
62
+ ui.fatal("Unknown server error (#{response['badRequest']['code']}): #{response['badRequest']['message']}")
63
+ raise e
64
+ end
65
+ puts ui.list(volume_list, :uneven_columns_across, 5)
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module OpenStack
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0.rc1"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -0,0 +1,45 @@
1
+ #
2
+ # Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
3
+ # Author:: Ameya Varade (<ameya.varade@clogeny.com>)
4
+ # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+
19
+ require 'spec_helper'
20
+ require 'chef/knife/openstack_volume_list'
21
+ require 'chef/knife/cloud/openstack_service'
22
+ require 'support/shared_examples_for_command'
23
+
24
+ describe Chef::Knife::Cloud::OpenstackVolumeList do
25
+ let (:instance) {Chef::Knife::Cloud::OpenstackVolumeList.new}
26
+
27
+ context "functionality" do
28
+ before do
29
+ resources = [ TestResource.new({:id => "volume-1", :name => "big-disk-volume", :status => "available", :size => 1024, :description => "This is the big disk"}),
30
+ TestResource.new({:id => "volume-2", :name => "little-disk-volume", :status => "in-use", :size => 8, :description => "This is the little disk"})
31
+ ]
32
+ allow(instance).to receive(:query_resource).and_return(resources)
33
+ allow(instance).to receive(:puts)
34
+ allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
35
+ allow(instance).to receive(:validate!)
36
+ end
37
+
38
+ it "lists formatted list of resources" do
39
+ expect(instance.ui).to receive(:list).with(["Name", "ID", "Status", "Size", "Description",
40
+ "big-disk-volume", "volume-1", "available", "1024 GB", "This is the big disk",
41
+ "little-disk-volume", "volume-2", "in-use", "8 GB", "This is the little disk"], :uneven_columns_across, 5)
42
+ instance.run
43
+ end
44
+ end
45
+ end
@@ -300,6 +300,21 @@ describe Chef::Knife::Cloud::OpenstackServerCreate do
300
300
  @instance.before_bootstrap
301
301
  expect(@instance.config[:ssh_password]).to be == server_password
302
302
  end
303
+
304
+ it "configures the default private bootstrap network to use 'private'" do
305
+ allow(@instance.server).to receive(:addresses).and_return({"private"=>[{"version"=>4, "addr"=>"127.0.0.1"}]})
306
+ @instance.config[:private_network] = true
307
+ @instance.before_bootstrap
308
+ expect(@instance.config[:bootstrap_network]).to be == 'private'
309
+ end
310
+
311
+ it "configures the bootstrap to use alternate private network" do
312
+ allow(@instance.server).to receive(:addresses).and_return({"secure"=>[{"version"=>4, "addr"=>"127.0.0.1"}]})
313
+ @instance.config[:bootstrap_network] = 'secure'
314
+ @instance.config[:private_network] = true
315
+ @instance.before_bootstrap
316
+ expect(@instance.config[:bootstrap_network]).to be == 'secure'
317
+ end
303
318
  end
304
319
 
305
320
  describe "#post_connection_validations" do
@@ -0,0 +1,29 @@
1
+ #
2
+ # Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
3
+ # Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
4
+ # Author:: Ameya Varade (<ameya.varade@clogeny.com>)
5
+ # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+
20
+ require 'spec_helper'
21
+ require 'chef/knife/openstack_volume_list'
22
+ require 'chef/knife/cloud/openstack_service'
23
+ require 'support/shared_examples_for_command'
24
+
25
+ describe Chef::Knife::Cloud::OpenstackVolumeList do
26
+ it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackVolumeList.new
27
+
28
+ include_context "#validate!", Chef::Knife::Cloud::OpenstackVolumeList.new
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JJ Asghar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
@@ -151,6 +151,7 @@ files:
151
151
  - lib/chef/knife/openstack_server_delete.rb
152
152
  - lib/chef/knife/openstack_server_list.rb
153
153
  - lib/chef/knife/openstack_server_show.rb
154
+ - lib/chef/knife/openstack_volume_list.rb
154
155
  - lib/knife-openstack/version.rb
155
156
  - spec/functional/flavor_list_func_spec.rb
156
157
  - spec/functional/group_list_func_spec.rb
@@ -160,6 +161,7 @@ files:
160
161
  - spec/functional/server_delete_func_spec.rb
161
162
  - spec/functional/server_list_func_spec.rb
162
163
  - spec/functional/server_show_func_spec.rb
164
+ - spec/functional/volume_list_func_spec.rb
163
165
  - spec/integration/cleanup.rb
164
166
  - spec/integration/config/environment.yml.sample
165
167
  - spec/integration/config/incorrect_openstack.pem
@@ -175,6 +177,7 @@ files:
175
177
  - spec/unit/openstack_server_list_spec.rb
176
178
  - spec/unit/openstack_server_show_spec.rb
177
179
  - spec/unit/openstack_service_spec.rb
180
+ - spec/unit/openstack_volume_list_spec.rb
178
181
  homepage: https://github.com/chef/knife-openstack
179
182
  licenses: []
180
183
  metadata: {}
@@ -189,9 +192,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
192
  version: '0'
190
193
  required_rubygems_version: !ruby/object:Gem::Requirement
191
194
  requirements:
192
- - - ">="
195
+ - - ">"
193
196
  - !ruby/object:Gem::Version
194
- version: '0'
197
+ version: 1.3.1
195
198
  requirements: []
196
199
  rubyforge_project:
197
200
  rubygems_version: 2.2.2
@@ -207,6 +210,7 @@ test_files:
207
210
  - spec/functional/server_delete_func_spec.rb
208
211
  - spec/functional/server_list_func_spec.rb
209
212
  - spec/functional/server_show_func_spec.rb
213
+ - spec/functional/volume_list_func_spec.rb
210
214
  - spec/integration/cleanup.rb
211
215
  - spec/integration/config/environment.yml.sample
212
216
  - spec/integration/config/incorrect_openstack.pem
@@ -222,4 +226,4 @@ test_files:
222
226
  - spec/unit/openstack_server_list_spec.rb
223
227
  - spec/unit/openstack_server_show_spec.rb
224
228
  - spec/unit/openstack_service_spec.rb
225
- has_rdoc: true
229
+ - spec/unit/openstack_volume_list_spec.rb