Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.2.0 #165

Merged
merged 29 commits into from Jun 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3a619da
Add volume list capability
karcaw Jul 29, 2014
7bf43b1
add volume connection to server create
karcaw Jul 30, 2014
2e6593f
add new author
karcaw Jul 30, 2014
d524a50
bug fix for device names
karcaw Jul 31, 2014
92183ed
here's a bit to add scheduler hints
Aug 6, 2014
5941ede
remove some debugging
Aug 6, 2014
df4b51c
Merge pull request #1 from EMSL-MSC/master
karcaw Aug 6, 2014
c71723f
shouldn't barf
Aug 6, 2014
d266280
Merge branch 'master' of github.com:EMSL-MSC/knife-openstack
karcaw Aug 6, 2014
571f418
Merge branch 'master' of github.com:opscode/knife-openstack
karcaw Sep 25, 2014
5504842
convert volume and scheduler calls to new file layout
karcaw Sep 26, 2014
a1b289d
rework volume list to work in new env
karcaw Sep 26, 2014
54ebcca
Cleanup volume list code
karcaw Sep 26, 2014
928336a
Merge tag 'v1.1.0' into vol_sched_1.0.0work
karcaw Apr 28, 2015
d137f0b
add specs and some documentation
karcaw Apr 28, 2015
e1d4449
Bad copy of the flavor file for volumes, fixed
karcaw Apr 28, 2015
cab046b
Allow users to specify alternate private networks.
elbandito May 28, 2015
a46f23f
Allow users to specify alternate private networks.
elbandito May 28, 2015
3a03bdb
Merge branch 'master' of github.com:elbandito/knife-openstack
elbandito Jun 1, 2015
c6318e7
Merge branch 'karcaw-vol_sched_1.0.0work' into 1.2.0
Jun 4, 2015
eb748b4
Merge branch 'elbandito-master' into 1.2.0
Jun 4, 2015
d6da57f
Inital merge and taging of 1.2.0.rc1
Jun 4, 2015
0859d36
Ready for the pre release
Jun 4, 2015
f5720e4
Gotta love randomly deleting code....
Jun 4, 2015
05c39a0
Added a more accurate summary of the gem
Jun 4, 2015
9305f75
Added the updated gem.
Jun 9, 2015
642ccb6
Bumping RC version
Jun 9, 2015
48ce2e4
updated per the new knife-cloud gem rc release
Jun 10, 2015
bd5f17a
Changed to 1.1.0 for knife-cloud.
Jun 18, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
## v1.2.0
* Allow users to specify alternate private networks. #163
* Vol sched 1.0.0work #142

## v1.1.0
* Update the travis tests
* Added Multi-region support
Expand Down
7 changes: 6 additions & 1 deletion README.md
Expand Up @@ -84,7 +84,7 @@ This plugin provides the following Knife subcommands. Specific command options c
knife openstack server create
-----------------------------

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.
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.

knife openstack server delete
-----------------------------
Expand All @@ -101,6 +101,11 @@ knife openstack flavor list

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.

knife openstack volume list
---------------------------

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.

knife openstack image list
--------------------------

Expand Down
6 changes: 3 additions & 3 deletions knife-openstack.gemspec
Expand Up @@ -11,8 +11,8 @@ Gem::Specification.new do |s|
s.authors = ["JJ Asghar"]
s.email = ["jj@chef.io"]
s.homepage = "https://github.com/chef/knife-openstack"
s.summary = %q{Chef Compute Support for Chef's Knife Command}
s.description = %q{Chef Compute Support for Chef's Knife Command using knife-cloud gem}
s.summary = %q{A Chef knife plugin for OpenStack clouds.}
s.description = %q{A Chef knife plugin for OpenStack clouds.}

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand All @@ -21,7 +21,7 @@ Gem::Specification.new do |s|

s.add_dependency "fog", "~> 1.23"
s.add_dependency "chef", ">= 11"
s.add_dependency "knife-cloud", "~> 1.0"
s.add_dependency "knife-cloud", "~> 1.1.0"

%w(rake rspec-core rspec-expectations rspec-mocks rspec_junit_formatter).each { |gem| s.add_development_dependency gem }
end
12 changes: 11 additions & 1 deletion lib/chef/knife/cloud/openstack_server_create_options.rb
Expand Up @@ -22,6 +22,16 @@ def self.included(includer)
:default => "-1",
: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."

option :openstack_volumes,
:long => "--openstack-volumes VOLUME1,VOLUME2,VOLUME3",
:description => "Comma separated list of the UUID(s) of the volume(s) to attach to the server",
:proc => Proc.new { |volumes| volumes.split(',') }

option :openstack_scheduler_hints,
:long => "--scheduler-hints HINTS",
:description => "A scheduler group hint to OpenStack",
:proc => Proc.new { |i| Chef::Config[:knife][:openstack_scheduler_hints] = i }

option :openstack_security_groups,
:short => "-G X,Y,Z",
:long => "--openstack-groups X,Y,Z",
Expand All @@ -34,7 +44,7 @@ def self.included(includer)
:long => "--openstack-ssh-key-id KEY",
:description => "The OpenStack SSH keypair id",
:proc => Proc.new { |key| Chef::Config[:knife][:openstack_ssh_key_id] = key }

option :user_data,
:long => "--user-data USER_DATA",
:description => "The file path containing user data information for this server",
Expand Down
19 changes: 17 additions & 2 deletions lib/chef/knife/openstack_server_create.rb
Expand Up @@ -47,11 +47,24 @@ def before_exec_command
:flavor_ref => service.get_flavor(locate_config_value(:flavor)).id,
:security_groups => locate_config_value(:openstack_security_groups),
:availability_zone => locate_config_value(:availability_zone),
"os:scheduler_hints" => locate_config_value(:openstack_scheduler_hints),
:metadata => locate_config_value(:metadata),
:key_name => locate_config_value(:openstack_ssh_key_id)
},
:server_create_timeout => locate_config_value(:server_create_timeout)
}
unless locate_config_value(:openstack_volumes).nil?
counter = 99
@create_options[:server_def][:block_device_mapping] = locate_config_value(:openstack_volumes).map do |vol|
counter += 1
{
:volume_id => vol,
:delete_on_termination => false,
:device_name => "/dev/vd"+counter.chr,
:volume_size => nil,
}
end
end

@create_options[:server_def].merge!({:user_data => locate_config_value(:user_data)}) if locate_config_value(:user_data)
@create_options[:server_def].merge!({:nics => locate_config_value(:network_ids).map { |nic| nic_id = { 'net_id' => nic }}}) if locate_config_value(:network_ids)
Expand Down Expand Up @@ -129,8 +142,10 @@ def before_bootstrap
# Use SSH password either specified from command line or from openstack server instance
config[:ssh_password] = locate_config_value(:ssh_password) || server.password unless config[:openstack_ssh_key_id]

# private_network means bootstrap_network = 'private'
config[:bootstrap_network] = 'private' if config[:private_network]
# The bootstrap network is always initialised to 'public' when a network name isn't specified. Therefore,
# only set the bootstrap network to 'private' if still initialised to public and nothing was specified for
# the private network name.
config[:bootstrap_network] = 'private' if (config[:private_network] && config[:bootstrap_network] == 'public')

# Which IP address to bootstrap
unless config[:network] # --no-network
Expand Down
70 changes: 70 additions & 0 deletions lib/chef/knife/openstack_volume_list.rb
@@ -0,0 +1,70 @@
#
# Author:: Seth Chisamore (<schisamo@getchef.com>)
# Author:: Matt Ray (<matt@getchef.com>)
# Author:: Evan Felix (<karcaw@gmail.com>)
# Copyright:: Copyright (c) 2011-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/knife/cloud/list_resource_command'
require 'chef/knife/openstack_helpers'
require 'chef/knife/cloud/openstack_service_options'

class Chef
class Knife
class Cloud
class OpenstackVolumeList < ResourceListCommand
include OpenstackHelpers
include OpenstackServiceOptions

banner "knife openstack volume list (options)"

def query_resource
begin
@service.connection.volumes
rescue Excon::Errors::BadRequest => e
response = Chef::JSONCompat.from_json(e.response.body)
ui.fatal("Unknown server error (#{response['badRequest']['code']}): #{response['badRequest']['message']}")
raise e
end
end

def list(volumes)
volume_list = [
ui.color('Name', :bold),
ui.color('ID', :bold),
ui.color('Status', :bold),
ui.color('Size', :bold),
ui.color('Description', :bold),
]
begin
volumes.sort_by(&:name).each do |volume|
volume_list << volume.name
volume_list << volume.id.to_s
volume_list << volume.status
volume_list << "#{volume.size.to_s} GB"
volume_list << volume.description
end
rescue Excon::Errors::BadRequest => e
response = Chef::JSONCompat.from_json(e.response.body)
ui.fatal("Unknown server error (#{response['badRequest']['code']}): #{response['badRequest']['message']}")
raise e
end
puts ui.list(volume_list, :uneven_columns_across, 5)
end
end
end
end
end
2 changes: 1 addition & 1 deletion lib/knife-openstack/version.rb
@@ -1,6 +1,6 @@
module Knife
module OpenStack
VERSION = "1.1.0"
VERSION = "1.2.0.rc2"
MAJOR, MINOR, TINY = VERSION.split('.')
end
end
45 changes: 45 additions & 0 deletions spec/functional/volume_list_func_spec.rb
@@ -0,0 +1,45 @@
#
# Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
# Author:: Ameya Varade (<ameya.varade@clogeny.com>)
# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'spec_helper'
require 'chef/knife/openstack_volume_list'
require 'chef/knife/cloud/openstack_service'
require 'support/shared_examples_for_command'

describe Chef::Knife::Cloud::OpenstackVolumeList do
let (:instance) {Chef::Knife::Cloud::OpenstackVolumeList.new}

context "functionality" do
before do
resources = [ TestResource.new({:id => "volume-1", :name => "big-disk-volume", :status => "available", :size => 1024, :description => "This is the big disk"}),
TestResource.new({:id => "volume-2", :name => "little-disk-volume", :status => "in-use", :size => 8, :description => "This is the little disk"})
]
allow(instance).to receive(:query_resource).and_return(resources)
allow(instance).to receive(:puts)
allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
allow(instance).to receive(:validate!)
end

it "lists formatted list of resources" do
expect(instance.ui).to receive(:list).with(["Name", "ID", "Status", "Size", "Description",
"big-disk-volume", "volume-1", "available", "1024 GB", "This is the big disk",
"little-disk-volume", "volume-2", "in-use", "8 GB", "This is the little disk"], :uneven_columns_across, 5)
instance.run
end
end
end
15 changes: 15 additions & 0 deletions spec/unit/openstack_server_create_spec.rb
Expand Up @@ -300,6 +300,21 @@
@instance.before_bootstrap
expect(@instance.config[:ssh_password]).to be == server_password
end

it "configures the default private bootstrap network to use 'private'" do
allow(@instance.server).to receive(:addresses).and_return({"private"=>[{"version"=>4, "addr"=>"127.0.0.1"}]})
@instance.config[:private_network] = true
@instance.before_bootstrap
expect(@instance.config[:bootstrap_network]).to be == 'private'
end

it "configures the bootstrap to use alternate private network" do
allow(@instance.server).to receive(:addresses).and_return({"secure"=>[{"version"=>4, "addr"=>"127.0.0.1"}]})
@instance.config[:bootstrap_network] = 'secure'
@instance.config[:private_network] = true
@instance.before_bootstrap
expect(@instance.config[:bootstrap_network]).to be == 'secure'
end
end

describe "#post_connection_validations" do
Expand Down
29 changes: 29 additions & 0 deletions spec/unit/openstack_volume_list_spec.rb
@@ -0,0 +1,29 @@
#
# Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
# Author:: Ameya Varade (<ameya.varade@clogeny.com>)
# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'spec_helper'
require 'chef/knife/openstack_volume_list'
require 'chef/knife/cloud/openstack_service'
require 'support/shared_examples_for_command'

describe Chef::Knife::Cloud::OpenstackVolumeList do
it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackVolumeList.new

include_context "#validate!", Chef::Knife::Cloud::OpenstackVolumeList.new
end