Skip to content

Commit

Permalink
Merge pull request #191 from chef/contributing
Browse files Browse the repository at this point in the history
Require Chef 12 and use Chefstyle
  • Loading branch information
tas50 authored Dec 12, 2016
2 parents d06f82d + f7734a6 commit b7e0779
Show file tree
Hide file tree
Showing 54 changed files with 1,103 additions and 1,091 deletions.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Version:

[Version of the project installed]

# Environment: [Details about the environment such as the Operating System, cookbook details, etc...]

# Scenario:

[What you are trying to achieve and you can't?]

# Steps to Reproduce:

[If you are filing an issue what are the things we need to do in order to repro your problem?]

# Expected Result:

[What are you expecting to happen as the consequence of above reproduction steps?]

# Actual Result:

[What actually happens after the reproduction steps?]
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ language: ruby
cache: bundler
sudo: false
rvm:
- 2.2.3
- 2.3.1
script: bundle exec rake spec
notifications:
irc:
- "chat.freenode.net#openstack-chef"
- 2.2.5
- 2.3.1
branches:
only:
- master
script: bundle exec rake
12 changes: 9 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in knife-openstack.gemspec
gemspec

group :development do
gem 'guard-rspec'
gem 'mixlib-shellout'
gem "guard-rspec"
gem "mixlib-shellout"
gem "rake", "~> 11.0"
gem "rspec", "~> 3.0"
gem "chefstyle"
gem "rspec-expectations"
gem "rspec-mocks"
gem "rspec_junit_formatter"
end
32 changes: 8 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,24 @@ Please refer to the [CHANGELOG](CHANGELOG.md) for version history and known issu
- Documentation: <https://github.com/chef/knife-openstack/blob/master/README.md>
- Source: <http://github.com/chef/knife-openstack/tree/master>
- Issues: <https://github.com/chef/knife-openstack/issues>
- IRC: `#chef` and `#openstack-chef` on Freenode
- Slack: <http://community-slack.chef.io/>
- Mailing list: <https://discourse.chef.io/>

Note: Documentation needs to be updated in chef docs

## Installation

If you're using [ChefDK](https://downloads.chef.io/chef-dk/), simply install the Gem:

```bash
chef gem install knife-openstack
```
## Requirements

If you're using bundler, simply add Chef and Knife OpenStack to your `Gemfile`:
- Chef 12.0 higher
- Ruby 2.2.2 or higher

```ruby
gem 'chef'
gem 'knife-openstack'
```

If you are not using bundler, you can install the gem manually. Be sure you are running Chef 0.10.10 or higher, as earlier versions do not support plugins.

```bash
$ gem install chef
```
## Installation

This plugin is distributed as a Ruby Gem. To install it, run:
Using [ChefDK](https://downloads.chef.io/chef-dk/), simply install the Gem:

```bash
$ gem install knife-openstack
chef gem install knife-openstack
```

Depending on your system's configuration, you may need to run this command with root privileges.

## Configuration

In order to communicate with an OpenStack API you will need to tell Knife your OpenStack Auth API endpoint, your Dashboard username and password (tenant is optional). The easiest way to accomplish this is to create these entries in your `knife.rb` file:
Expand Down Expand Up @@ -176,7 +160,7 @@ Author:: Chirag Jog ([[email protected]](mailto:[email protected]))

Author:: JJ Asghar ([[email protected]](mailto:[email protected]))

Copyright:: Copyright (c) 2011-2015 Chef Software, Inc.
Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.

License:: Apache License, Version 2.0

Expand Down
15 changes: 8 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Author:: Kaustubh Deorukhkar (<[email protected]>)
# Copyright:: Copyright (c) 2013 Chef Software, Inc.

require 'bundler'
require 'bundler/setup'
require 'bundler/gem_tasks'
require 'rubocop/rake_task'
require 'rspec/core/rake_task'
# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.

require "bundler"
require "bundler/setup"
require "bundler/gem_tasks"
require "chefstyle"
require "rubocop/rake_task"
require "rspec/core/rake_task"

RuboCop::RakeTask.new

Expand Down
32 changes: 16 additions & 16 deletions knife-openstack.gemspec
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
# -*- encoding: utf-8 -*-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'knife-openstack/version'
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
require "knife-openstack/version"

Gem::Specification.new do |s|
s.name = 'knife-openstack'
s.name = "knife-openstack"
s.version = Knife::OpenStack::VERSION
s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV["TRAVIS"]
s.platform = Gem::Platform::RUBY
s.has_rdoc = true
s.extra_rdoc_files = ['README.md', 'LICENSE']
s.authors = ['JJ Asghar']
s.email = ['[email protected]']
s.homepage = 'https://github.com/chef/knife-openstack'
s.summary = 'A Chef knife plugin for OpenStack clouds.'
s.description = 'A Chef knife plugin for OpenStack clouds.'
s.license = 'Apache-2.0'
s.extra_rdoc_files = ["README.md", "LICENSE"]
s.authors = ["JJ Asghar"]
s.email = ["[email protected]"]
s.homepage = "https://github.com/chef/knife-openstack"
s.summary = "A Chef knife plugin for OpenStack clouds."
s.description = "A Chef knife plugin for OpenStack clouds."
s.license = "Apache-2.0"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ['lib']
s.require_paths = ["lib"]

s.add_dependency 'fog', '~> 1.23'
s.add_dependency 'chef', '>= 11'
s.add_dependency 'knife-cloud', '~> 1.2.0'
s.required_ruby_version = ">= 2.2.2"

%w(bundler rubocop rake rspec-core rspec-expectations rspec-mocks rspec_junit_formatter).each { |gem| s.add_development_dependency gem }
s.add_dependency "fog", "~> 1.23"
s.add_dependency "chef", ">= 12"
s.add_dependency "knife-cloud", "~> 1.2.0"
end
70 changes: 35 additions & 35 deletions lib/chef/knife/cloud/openstack_server_create_options.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

require 'chef/knife/cloud/server/create_options'
require "chef/knife/cloud/server/create_options"

class Chef
class Knife
Expand All @@ -11,72 +11,72 @@ def self.included(includer)

# Openstack Server create params.
option :private_network,
long: '--openstack-private-network',
description: 'Use the private IP for bootstrapping rather than the public IP',
long: "--openstack-private-network",
description: "Use the private IP for bootstrapping rather than the public IP",
boolean: true,
default: false

option :openstack_floating_ip,
short: '-a [IP]',
long: '--openstack-floating-ip [IP]',
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.'
short: "-a [IP]",
long: "--openstack-floating-ip [IP]",
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 { |volumes| volumes.split(',') }
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 { |volumes| volumes.split(",") }

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

option :openstack_security_groups,
short: '-G X,Y,Z',
long: '--openstack-groups X,Y,Z',
description: 'The security groups for this server',
default: ['default'],
proc: proc { |groups| groups.split(',') }
short: "-G X,Y,Z",
long: "--openstack-groups X,Y,Z",
description: "The security groups for this server",
default: ["default"],
proc: proc { |groups| groups.split(",") }

option :openstack_ssh_key_id,
short: '-S KEY',
long: '--openstack-ssh-key-id KEY',
description: 'The OpenStack SSH keypair id',
short: "-S KEY",
long: "--openstack-ssh-key-id KEY",
description: "The OpenStack SSH keypair id",
proc: proc { |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',
long: "--user-data USER_DATA",
description: "The file path containing user data information for this server",
proc: proc { |user_data| open(user_data, &:read) }

option :bootstrap_network,
long: '--bootstrap-network NAME',
default: 'public',
long: "--bootstrap-network NAME",
default: "public",
description: "Specify network for bootstrapping. Default is 'public'."

option :network,
long: '--no-network',
long: "--no-network",
boolean: true,
default: true,
description: "Use first available network for bootstrapping if 'public' and 'private' are unavailable."

option :network_ids,
long: '--network-ids NETWORK_ID_1,NETWORK_ID_2,NETWORK_ID_3',
description: 'Comma separated list of the UUID(s) of the network(s) for the server to attach',
proc: proc { |networks| networks.split(',') }
long: "--network-ids NETWORK_ID_1,NETWORK_ID_2,NETWORK_ID_3",
description: "Comma separated list of the UUID(s) of the network(s) for the server to attach",
proc: proc { |networks| networks.split(",") }

option :availability_zone,
short: '-Z ZONE_NAME',
long: '--availability-zone ZONE_NAME',
description: 'The availability zone for this server',
short: "-Z ZONE_NAME",
long: "--availability-zone ZONE_NAME",
description: "The availability zone for this server",
proc: proc { |z| Chef::Config[:knife][:availability_zone] = z }

option :metadata,
short: '-M X=1',
long: '--metadata X=1',
description: 'Metadata information for this server (may pass multiple times)',
proc: proc { |data| Chef::Config[:knife][:metadata] ||= {}; Chef::Config[:knife][:metadata].merge!(data.split('=')[0] => data.split('=')[1]) }
short: "-M X=1",
long: "--metadata X=1",
description: "Metadata information for this server (may pass multiple times)",
proc: proc { |data| Chef::Config[:knife][:metadata] ||= {}; Chef::Config[:knife][:metadata].merge!(data.split("=")[0] => data.split("=")[1]) }
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/chef/knife/cloud/openstack_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright:: Copyright (c) 2013 Chef Software, Inc.
#

require 'chef/knife/cloud/fog/service'
require "chef/knife/cloud/fog/service"

class Chef
class Knife
Expand Down Expand Up @@ -35,7 +35,7 @@ def get_server(search_term)
if servers.length > 1
error_message = "Multiple server matches found for '#{search_term}', use an instance_id to be more specific."
ui.fatal(error_message)
fail CloudExceptions::ValidationError, error_message
raise CloudExceptions::ValidationError, error_message
else
servers.first
end
Expand All @@ -47,18 +47,18 @@ def get_server(search_term)
def get_auth_params
load_fog_gem
params = {
provider: 'OpenStack',
provider: "OpenStack",
connection_options: {
ssl_verify_peer: !Chef::Config[:knife][:openstack_insecure]
}
ssl_verify_peer: !Chef::Config[:knife][:openstack_insecure],
},
}

(
Fog::Compute::OpenStack.requirements +
Fog::Compute::OpenStack.recognized -
[:openstack_api_key]
).each do |k|
next unless k.to_s.start_with?('openstack')
next unless k.to_s.start_with?("openstack")
params[k] = Chef::Config[:knife][k]
end
params[:openstack_api_key] = Chef::Config[:knife][:openstack_password] || Chef::Config[:knife][:openstack_api_key]
Expand Down
34 changes: 17 additions & 17 deletions lib/chef/knife/cloud/openstack_service_options.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'chef/knife/cloud/fog/options'
require "chef/knife/cloud/fog/options"
class Chef
class Knife
class Cloud
Expand All @@ -8,41 +8,41 @@ def self.included(includer)
include FogOptions
# Openstack Connection params.
option :openstack_username,
short: '-A USERNAME',
long: '--openstack-username KEY',
description: 'Your OpenStack Username',
short: "-A USERNAME",
long: "--openstack-username KEY",
description: "Your OpenStack Username",
proc: proc { |key| Chef::Config[:knife][:openstack_username] = key }

option :openstack_password,
short: '-K SECRET',
long: '--openstack-password SECRET',
description: 'Your OpenStack Password',
short: "-K SECRET",
long: "--openstack-password SECRET",
description: "Your OpenStack Password",
proc: proc { |key| Chef::Config[:knife][:openstack_password] = key }

option :openstack_tenant,
short: '-T NAME',
long: '--openstack-tenant NAME',
description: 'Your OpenStack Tenant NAME',
short: "-T NAME",
long: "--openstack-tenant NAME",
description: "Your OpenStack Tenant NAME",
proc: proc { |key| Chef::Config[:knife][:openstack_tenant] = key }

option :openstack_auth_url,
long: '--openstack-api-endpoint ENDPOINT',
description: 'Your OpenStack API endpoint',
long: "--openstack-api-endpoint ENDPOINT",
description: "Your OpenStack API endpoint",
proc: proc { |endpoint| Chef::Config[:knife][:openstack_auth_url] = endpoint }

option :openstack_endpoint_type,
long: '--openstack-endpoint-type ENDPOINT_TYPE',
description: 'OpenStack endpoint type to use (publicURL, internalURL, adminURL)',
long: "--openstack-endpoint-type ENDPOINT_TYPE",
description: "OpenStack endpoint type to use (publicURL, internalURL, adminURL)",
proc: proc { |type| Chef::Config[:knife][:openstack_endpoint_type] = type }

option :openstack_insecure,
long: '--insecure',
description: 'Ignore SSL certificate on the Auth URL',
long: "--insecure",
description: "Ignore SSL certificate on the Auth URL",
boolean: true,
default: false,
proc: proc { |key| Chef::Config[:knife][:openstack_insecure] = key }
end
end
end
end
end
end
Expand Down
Loading

0 comments on commit b7e0779

Please sign in to comment.