knife-openstack 1.2.0 → 1.3.1

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: 0c00775263f09abba7c70e8976430af5ff4b99ae
4
- data.tar.gz: 2d61ed82c4db747e26c7258f422f9a907fe8261e
3
+ metadata.gz: 87e92a88883a178ca6fa4739e5113be9023bd5bd
4
+ data.tar.gz: 273697b3000cc203628fc2f42ca26f29da490467
5
5
  SHA512:
6
- metadata.gz: 6c6ac27c1078fb3651987aadf4b19350adf5d9a084357ade2fc3d687c6dd89576621bb8b1a72d7d4610255f07f0c98f2342720d90ee47cb3addc7e767b064f91
7
- data.tar.gz: 190ca4e8a68ffaac997928ff1d568d10221d1a0138561da8b7b9b87d6969ce1b41cac277a1cf769a59c40cb2c5ccda57e4b00eb23445ffae397f6d8e9ff07f4e
6
+ metadata.gz: 7bde3dfa21f8da3df278cd2f4ae1b20432d07d2f7622554064e2a73442a1944b7ae82691c07a52baec0ee7b6c2e990edc0408a4a41131375f298ef4b25be699b
7
+ data.tar.gz: 3e686c596764b992a02488b049ee9c56c329eda8c74168650e60711573b7bb0523eb7c14530bc4e0b2c2e6f49465726070bb42edd99561076fb26ce2be2a016f
@@ -1,6 +1,15 @@
1
1
  rvm:
2
- - 2.0.0
3
- - 2.1.5
4
- - 2.2.0
5
-
2
+ - 2.0.0
3
+ - 2.1.5
4
+ - 2.2.0
6
5
  script: bundle exec rake spec
6
+ deploy:
7
+ provider: rubygems
8
+ api_key:
9
+ secure: fHosXRjyuBtNwtLKiMdTQkvFdV7uHNZaK8VoeBAT6kIk9xVgTQRXnPq5AflJMwnALrLyYDZq2okWxquu3xljYu9u3bOnQDVTrrHtvWTmoMb9jcPPtIDAJ0eT1ctlmXNGBcq5/jk4YP/83qfByKvxj0w6gGx5KhQ0DqiYWxzxAus=
10
+ on:
11
+ tags: true
12
+ notifications:
13
+ irc:
14
+ - "chat.freenode.net#openstack-chef"
15
+ - "chat.freenode.net#chef-hacking"
data/README.md CHANGED
@@ -1,27 +1,26 @@
1
1
  [![Build Status](https://travis-ci.org/chef/knife-openstack.png)](https://travis-ci.org/chef/knife-openstack)
2
2
 
3
- Knife OpenStack
4
- ===============
3
+ # Knife OpenStack
5
4
 
6
5
  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
6
 
8
7
  Please refer to the [CHANGELOG](CHANGELOG.md) for version history and known issues.
9
8
 
10
- # Installation #
9
+ ## Installation
11
10
 
12
11
  Be sure you are running the latest version Chef. Versions earlier than 0.10.0 don't support plugins:
13
12
 
14
13
  $ curl -L https://chef.io/chef/install.sh | sudo bash
15
-
14
+
16
15
  This plugin is distributed as a Ruby Gem. To install it, run:
17
16
 
18
17
  $ chef gem install knife-openstack
19
18
  OR
20
19
  $ gem install knife-openstack
21
-
20
+
22
21
  Depending on your system's configuration, you may need to run this command with root privileges.
23
22
 
24
- # Configuration #
23
+ ## Configuration
25
24
 
26
25
  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:
27
26
 
@@ -60,11 +59,11 @@ Additionally the following options may be set in your `knife.rb`:
60
59
  * openstack_ssh_key_id
61
60
  * template_file
62
61
 
63
- # Working with Floating IPs #
62
+ ## Working with Floating IPs
64
63
 
65
64
  To use a floating IP address while bootstrapping nodes, use the `-a` or `--openstack-floating-ip` option.
66
65
 
67
- # Working with Windows Images #
66
+ ## Working with Windows Images
68
67
 
69
68
  Provisioning and bootstrapping for Windows 2003 and later images is now supported. The Windows images need to have WinRM enabled with Basic Authentication configured. Current support does not support Kerberos Authentication.
70
69
 
@@ -77,51 +76,47 @@ NOTE:
77
76
  * Administrator Username (`--winrm-user` or `-x`) and Password (`-P`) are required parameters.
78
77
  * If the Template File (`--template`) is not specified it defaults to a Linux distro (most likely Ubuntu).
79
78
 
80
- # Subcommands #
79
+ ## Subcommands
81
80
 
82
81
  This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` option.
83
82
 
84
- knife openstack server create
85
- -----------------------------
83
+ ### knife openstack server create
86
84
 
87
85
  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
86
 
89
- knife openstack server delete
90
- -----------------------------
87
+ ### knife openstack server delete
91
88
 
92
89
  Deletes an existing server in the currently configured OpenStack account. If a floating IP address has been assigned to the node, it is disassociated automatically by the OpenStack server. <b>PLEASE NOTE</b> - this does not delete the associated node and client objects from the Chef server without using the `-P` option to purge the client.
93
90
 
94
- knife openstack server list
95
- ---------------------------
91
+ ### knife openstack server list
96
92
 
97
93
  Outputs a list of all servers in the currently configured OpenStack account. <b>PLEASE NOTE</b> - this shows all instances associated with the account, some of which may not be currently managed by the Chef server.
98
94
 
99
- knife openstack flavor list
100
- ---------------------------
95
+ ### knife openstack flavor list
101
96
 
102
97
  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
98
 
104
- knife openstack volume list
105
- ---------------------------
99
+ ### knife openstack volume list
106
100
 
107
101
  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
102
 
109
- knife openstack image list
110
- --------------------------
103
+ ### knife openstack image list
111
104
 
112
105
  Lists all available images and snapshots available to the currently configured OpenStack account. An image is a collection of files used to create or rebuild a server. The retuned list filters out image names ending in 'initrd', 'kernel', 'loader', 'virtual' or 'vmlinuz' (this may be disabled with `--disable-filter`). This data may be useful when choosing an image to pass to the `knife openstack server create` subcommand.
113
106
 
114
- knife openstack group list
115
- --------------------
107
+ ### knife openstack group list
116
108
 
117
109
  Provides a list of the security groups available to the currently configured OpenStack account. Each group may have multiple rules. This data may be useful when choosing your security group(s) to pass to the `knife openstack server create` subcommand.
118
110
 
119
- knife openstack network list
120
- --------------------
111
+ ### knife openstack network list
121
112
 
122
113
  Lists the networks available to the currently configured OpenStack account. This data may be useful when choosing your networks to pass to the `knife openstack server create` subcommand. This command is only available with OpenStack deployments using the Neutron network service (not nova-network). Please see `knife openstack server create --help` for all of the supported options.
123
114
 
124
- # License #
115
+ ### knife openstack floating_ip list
116
+
117
+ Lists all of the available `floating-ips` you have associated with your account. You can ask for more via: `knife openstack floating_ip allocate --pool POOL` if you have run out. You can also `knife openstack floating_ip associate FLOATING_IP --instance-id INSTANCE_ID` and too. If you need to remove the `floating-ip` you can `disassociate` with the same command. If you would like to give back the `floating-ip` you can `knife openstack floating_ip release FLOATING_IP_ID`
118
+
119
+ # License
125
120
 
126
121
  Author:: Seth Chisamore (<schisamo@chef.io>)
127
122
 
@@ -5,6 +5,7 @@ require "knife-openstack/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "knife-openstack"
7
7
  s.version = Knife::OpenStack::VERSION
8
+ s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
8
9
  s.platform = Gem::Platform::RUBY
9
10
  s.has_rdoc = true
10
11
  s.extra_rdoc_files = ["README.md", "LICENSE" ]
@@ -21,7 +22,7 @@ Gem::Specification.new do |s|
21
22
 
22
23
  s.add_dependency "fog", "~> 1.23"
23
24
  s.add_dependency "chef", ">= 11"
24
- s.add_dependency "knife-cloud", "~> 1.1.0"
25
+ s.add_dependency "knife-cloud", "~> 1.2.0"
25
26
 
26
27
  %w(rake rspec-core rspec-expectations rspec-mocks rspec_junit_formatter).each { |gem| s.add_development_dependency gem }
27
28
  end
@@ -0,0 +1,38 @@
1
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
2
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+
4
+ require 'chef/knife/openstack_helpers'
5
+ require 'chef/knife/cloud/openstack_service_options'
6
+
7
+ class Chef
8
+ class Knife
9
+ class Cloud
10
+ class OpenstackFloatingIpAllocate < Command
11
+ include OpenstackHelpers
12
+ include OpenstackServiceOptions
13
+
14
+ banner 'knife openstack floating_ip allocate (options)'
15
+
16
+ option :pool,
17
+ :short => '-p POOL',
18
+ :long => '--pool POOL',
19
+ :description => 'Floating IP pool to allocate from.',
20
+ :proc => Proc.new { |key| Chef::Config[:knife][:pool] = key }
21
+
22
+ def execute_command
23
+ @resource = @service.allocate_address(locate_config_value(:pool))
24
+ end
25
+
26
+ def after_exec_command
27
+ @columns_with_info = [{ label: 'ID', value: @resource['floating_ip']['id'].to_s },
28
+ { label: 'Instance ID', value: @resource['floating_ip']['instance_id'].to_s },
29
+ { label: 'Floating IP', value: @resource['floating_ip']['ip'].to_s },
30
+ { label: 'Fixed IP', value: @resource['floating_ip']['fixed_ip'].to_s },
31
+ { label: 'Pool', value: @resource['floating_ip']['pool'].to_s }
32
+ ]
33
+ @service.server_summary(nil, @columns_with_info)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,40 @@
1
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
2
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+
4
+ require 'chef/knife/openstack_helpers'
5
+ require 'chef/knife/cloud/openstack_service_options'
6
+ require 'chef/knife/cloud/openstack_service'
7
+
8
+ class Chef
9
+ class Knife
10
+ class Cloud
11
+ class OpenstackFloatingIpAssociate < Command
12
+ include OpenstackHelpers
13
+ include OpenstackServiceOptions
14
+
15
+ banner 'knife openstack floating_ip associate IP (options)'
16
+
17
+ option :instance_id,
18
+ :long => '--instance-id ID',
19
+ :description => 'Instance id to associate it with.',
20
+ :proc => Proc.new { |key| Chef::Config[:knife][:instance_id] = key },
21
+ :required => true
22
+
23
+ def execute_command
24
+ if @name_args[0]
25
+ floating_ip = @name_args[0]
26
+ else
27
+ ui.error "Please provide Floating IP to associate with."
28
+ exit 1
29
+ end
30
+
31
+ instance_id = locate_config_value(:instance_id)
32
+ response = @service.associate_address(instance_id, floating_ip)
33
+ if response && response.status == 202
34
+ ui.info "Floating IP #{floating_ip} associated with Instance #{instance_id}"
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,39 @@
1
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
2
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+
4
+ require 'chef/knife/openstack_helpers'
5
+ require 'chef/knife/cloud/openstack_service_options'
6
+ require 'chef/knife/cloud/openstack_service'
7
+
8
+ class Chef
9
+ class Knife
10
+ class Cloud
11
+ class OpenstackFloatingIpDisassociate < Command
12
+ include OpenstackHelpers
13
+ include OpenstackServiceOptions
14
+
15
+ banner 'knife openstack floating_ip disassociate IP (options)'
16
+
17
+ option :instance_id,
18
+ :long => '--instance-id ID',
19
+ :description => 'Instance id to disassociate with.',
20
+ :proc => Proc.new { |key| Chef::Config[:knife][:instance_id] = key },
21
+ :required => true
22
+
23
+ def execute_command
24
+ if @name_args[0]
25
+ floating_ip = @name_args[0]
26
+ else
27
+ ui.error 'Please provide Floating IP to disassociate.'
28
+ exit 1
29
+ end
30
+ instance_id = locate_config_value(:instance_id)
31
+ response = @service.disassociate_address(instance_id, floating_ip)
32
+ if response && response.status == 202
33
+ ui.info "Floating IP #{floating_ip} disassociated with Instance #{instance_id}"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,34 @@
1
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
2
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+
4
+ require 'chef/knife/cloud/list_resource_command'
5
+ require 'chef/knife/openstack_helpers'
6
+ require 'chef/knife/cloud/openstack_service_options'
7
+
8
+ class Chef
9
+ class Knife
10
+ class Cloud
11
+ class OpenstackFloatingIpList < ResourceListCommand
12
+ include OpenstackHelpers
13
+ include OpenstackServiceOptions
14
+
15
+ banner 'knife openstack floating_ip list (options)'
16
+
17
+ def before_exec_command
18
+ # set columns_with_info map
19
+ @columns_with_info = [
20
+ { label: 'ID', key: 'id' },
21
+ { label: 'Instance ID', key: 'instance_id' },
22
+ { label: 'IP Address', key: 'ip' },
23
+ { label: 'Fixed IP', key: 'fixed_ip' },
24
+ { label: 'Floating IP Pool', key: 'pool' }
25
+ ]
26
+ end
27
+
28
+ def query_resource
29
+ @service.list_addresses
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ #
5
+ \
6
+ require 'chef/knife/openstack_helpers'
7
+ require 'chef/knife/cloud/openstack_service_options'
8
+
9
+ class Chef
10
+ class Knife
11
+ class Cloud
12
+ class OpenstackFloatingIpRelease < Command
13
+ include OpenstackServiceOptions
14
+ include OpenstackHelpers
15
+
16
+ banner 'knife openstack floating_ip release ID [ID] (options)'
17
+
18
+ def execute_command
19
+ if @name_args[0]
20
+ response = service.release_address(@name_args[0])
21
+ if response && response.status == 202
22
+ ui.info 'Floating IP released successfully.'
23
+ end
24
+ else
25
+ ui.error 'Please provide Floating IP to release.'
26
+ exit 1
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -22,27 +22,32 @@ class Chef
22
22
  end
23
23
 
24
24
  def list(security_groups)
25
- group_list = [
26
- ui.color('Name', :bold),
27
- ui.color('Protocol', :bold),
28
- ui.color('From', :bold),
29
- ui.color('To', :bold),
30
- ui.color('CIDR', :bold),
31
- ui.color('Description', :bold),
32
- ]
33
- security_groups.sort_by(&:name).each do |group|
34
- group.security_group_rules.each do |rule|
35
- unless rule.ip_protocol.nil?
36
- group_list << group.name
37
- group_list << rule.ip_protocol
38
- group_list << rule.from_port.to_s
39
- group_list << rule.to_port.to_s
40
- group_list << rule.ip_range['cidr']
41
- group_list << group.description
25
+ if(config[:format] == "summary")
26
+ group_list = [
27
+ ui.color('Name', :bold),
28
+ ui.color('Protocol', :bold),
29
+ ui.color('From', :bold),
30
+ ui.color('To', :bold),
31
+ ui.color('CIDR', :bold),
32
+ ui.color('Description', :bold),
33
+ ]
34
+ security_groups.sort_by(&:name).each do |group|
35
+ group.security_group_rules.each do |rule|
36
+ unless rule.ip_protocol.nil?
37
+ group_list << group.name
38
+ group_list << rule.ip_protocol
39
+ group_list << rule.from_port.to_s
40
+ group_list << rule.to_port.to_s
41
+ group_list << rule.ip_range['cidr']
42
+ group_list << group.description
43
+ end
42
44
  end
43
45
  end
46
+
47
+ puts ui.list(group_list, :uneven_columns_across, 6)
48
+ else
49
+ output(format_for_display(security_groups))
44
50
  end
45
- puts ui.list(group_list, :uneven_columns_across, 6)
46
51
  end
47
52
  end
48
53
  end
@@ -165,6 +165,9 @@ class Chef
165
165
  raise CloudExceptions::BootstrapError, error_message
166
166
  end
167
167
  config[:bootstrap_ip_address] = bootstrap_ip_address
168
+
169
+ config[:hints] ||= {}
170
+ config[:hints]["openstack"] ||= {}
168
171
  end
169
172
 
170
173
  def validate_params!
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module OpenStack
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.1"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
@@ -33,6 +33,7 @@ describe Chef::Knife::Cloud::OpenstackFlavorList do
33
33
  allow(instance).to receive(:puts)
34
34
  allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
35
35
  allow(instance).to receive(:validate!)
36
+ instance.config[:format] = "summary"
36
37
  end
37
38
 
38
39
  it "lists formatted list of resources" do
@@ -0,0 +1,47 @@
1
+ #
2
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
+ # Copyright:: Copyright (c) 2013-2014 Chef Software, 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
+ require 'spec_helper'
19
+ require 'chef/knife/openstack_floating_ip_list'
20
+ require 'chef/knife/cloud/openstack_service'
21
+ require 'support/shared_examples_for_command'
22
+
23
+ describe Chef::Knife::Cloud::OpenstackFloatingIpList do
24
+ let (:instance) {Chef::Knife::Cloud::OpenstackFloatingIpList.new}
25
+
26
+ context 'functionality' do
27
+ before do
28
+ resources = [ TestResource.new({ "id" => "floatingip1", "instance_id" => "daed9e86-4b69-4242-993a-926a39352783", "ip" => "173.236.251.98", "fixed_ip" => "", "pool" => "test-pool"}
29
+ ),
30
+ TestResource.new({ "id" => "floatingip2", "instance_id" => "", "ip" => "67.205.60.122", "fixed_ip" => "10.10.10.1", "pool" => "test-pool" }
31
+ )
32
+ ]
33
+ allow(instance).to receive(:query_resource).and_return(resources)
34
+ allow(instance).to receive(:puts)
35
+ allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
36
+ allow(instance).to receive(:validate!)
37
+ instance.config[:format] = "summary"
38
+ end
39
+
40
+ it "lists formatted list of resources" do
41
+ expect(instance.ui).to receive(:list).with(['ID', 'Instance ID', 'IP Address', 'Fixed IP', 'Floating IP Pool',
42
+ 'floatingip1', 'daed9e86-4b69-4242-993a-926a39352783', '173.236.251.98', '', 'test-pool',
43
+ 'floatingip2','', '67.205.60.122', '10.10.10.1', 'test-pool'], :uneven_columns_across, 5)
44
+ instance.run
45
+ end
46
+ end
47
+ end
@@ -55,6 +55,7 @@ describe Chef::Knife::Cloud::OpenstackGroupList do
55
55
  allow(instance).to receive(:puts)
56
56
  allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
57
57
  allow(instance).to receive(:validate!)
58
+ instance.config[:format] = "summary"
58
59
  end
59
60
 
60
61
  it "lists formatted list of resources" do
@@ -32,6 +32,7 @@ describe Chef::Knife::Cloud::OpenstackImageList do
32
32
  allow(instance).to receive(:puts)
33
33
  allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
34
34
  allow(instance).to receive(:validate!)
35
+ instance.config[:format] = "summary"
35
36
  end
36
37
 
37
38
  it "displays formatted list of images, filtered by default" do
@@ -32,6 +32,7 @@ describe Chef::Knife::Cloud::OpenstackNetworkList do
32
32
  allow(instance).to receive(:puts)
33
33
  allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
34
34
  allow(instance).to receive(:validate!)
35
+ instance.config[:format] = "summary"
35
36
  end
36
37
 
37
38
  it "lists formatted list of network resources" do
@@ -35,6 +35,7 @@ describe Chef::Knife::Cloud::OpenstackServerList do
35
35
  allow(instance).to receive(:puts)
36
36
  allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::FogService.new)
37
37
  allow(instance).to receive(:validate!)
38
+ instance.config[:format] = "summary"
38
39
  end
39
40
 
40
41
  it "lists formatted list of resources" do
@@ -0,0 +1,56 @@
1
+ #
2
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
+ # Copyright:: Copyright (c) 2013-2015 Chef Software, 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
+ require 'spec_helper'
19
+ require 'chef/knife/openstack_floating_ip_allocate'
20
+ require 'chef/knife/cloud/openstack_service'
21
+ require 'support/shared_examples_for_command'
22
+
23
+ describe Chef::Knife::Cloud::OpenstackFloatingIpAllocate do
24
+
25
+ it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
26
+ include_context '#validate!', Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
27
+
28
+ before(:each) do
29
+ @instance = Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new
30
+ allow(@instance.ui).to receive(:error)
31
+ end
32
+
33
+ describe 'create service instance' do
34
+ it 'return OpenstackService instance' do
35
+ expect(@instance.create_service_instance).to be_an_instance_of(Chef::Knife::Cloud::OpenstackService)
36
+ end
37
+ end
38
+
39
+ describe 'allocate floating ip' do
40
+ it 'calls allocate address' do
41
+ @instance.service = double
42
+ expect(@instance.service).to receive(:allocate_address).and_return(true)
43
+ @instance.execute_command
44
+ end
45
+ end
46
+
47
+ describe 'when user provides pool option ' do
48
+ it 'allocates floating ip in user specified pool' do
49
+ @instance = Chef::Knife::Cloud::OpenstackFloatingIpAllocate.new(["--pool", "test-pool"])
50
+ @instance.service = Chef::Knife::Cloud::Service.new
51
+ response = {:floating_ip => {'id' => 'test-id', 'instance_id' => 'test-instance-id', 'floating_ip' => '127.0.0.1', 'fixed_ip' => 'nil', 'pool' => 'test-pool' }}
52
+ expect(@instance.service).to receive(:allocate_address).and_return(response)
53
+ @instance.execute_command
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,39 @@
1
+ #
2
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
+ # Copyright:: Copyright (c) 2013-2015 Chef Software, 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
+ require 'spec_helper'
18
+ require 'chef/knife/openstack_floating_ip_associate'
19
+ require 'chef/knife/cloud/openstack_service'
20
+ require 'support/shared_examples_for_command'
21
+ require 'ostruct'
22
+
23
+ describe Chef::Knife::Cloud::OpenstackFloatingIpAssociate do
24
+ before(:each) do
25
+ @instance = Chef::Knife::Cloud::OpenstackFloatingIpAssociate.new(["--instance-id", "23849038438240934n3294839248"])
26
+ @instance.name_args = [ '127.0.0.1' ]
27
+ end
28
+
29
+ describe 'associate floating ip' do
30
+ it 'calls associate address' do
31
+ success_message = 'Floating IP 127.0.0.1 associated with Instance 23849038438240934n3294839248'
32
+ @instance.service = Chef::Knife::Cloud::Service.new
33
+ response = OpenStruct.new(status: 202)
34
+ expect(@instance.service).to receive(:associate_address).and_return(response)
35
+ expect(@instance.ui).to receive(:info).and_return(success_message)
36
+ @instance.execute_command
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,38 @@
1
+ #
2
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
+ # Copyright:: Copyright (c) 2013-2015 Chef Software, 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
+ require 'spec_helper'
18
+ require 'chef/knife/openstack_floating_ip_disassociate'
19
+ require 'chef/knife/cloud/openstack_service'
20
+ require 'support/shared_examples_for_command'
21
+ require 'ostruct'
22
+
23
+ describe Chef::Knife::Cloud::OpenstackFloatingIpDisassociate do
24
+ before(:each) do
25
+ @instance = Chef::Knife::Cloud::OpenstackFloatingIpDisassociate.new(["--instance-id", "23849038438240934n3294839248"])
26
+ @instance.name_args = [ '127.0.0.1' ]
27
+ end
28
+
29
+ describe 'associate floating ip' do
30
+ it 'calls associate address' do
31
+ @instance.service = Chef::Knife::Cloud::Service.new
32
+ response = OpenStruct.new(:status => 202)
33
+ expect(@instance.service).to receive(:disassociate_address).with('23849038438240934n3294839248', '127.0.0.1').and_return(response)
34
+ expect(@instance.ui).to receive(:info).and_return('Floating IP 127.0.0.1 disassociated with Instance 23849038438240934n3294839248')
35
+ @instance.execute_command
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
+ # Copyright:: Copyright (c) 2013-2015 Chef Software, 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
+ require 'spec_helper'
19
+ require 'chef/knife/openstack_floating_ip_list'
20
+ require 'chef/knife/cloud/openstack_service'
21
+ require 'support/shared_examples_for_command'
22
+
23
+ describe Chef::Knife::Cloud::OpenstackFloatingIpList do
24
+ it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFloatingIpList.new
25
+ include_context '#validate!', Chef::Knife::Cloud::OpenstackFloatingIpList.new
26
+ end
@@ -0,0 +1,48 @@
1
+ #
2
+ # Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
3
+ # Copyright:: Copyright (c) 2013-2015 Chef Software, 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
+ require 'spec_helper'
18
+ require 'chef/knife/openstack_floating_ip_release'
19
+ require 'chef/knife/cloud/openstack_service'
20
+ require 'support/shared_examples_for_command'
21
+
22
+ describe Chef::Knife::Cloud::OpenstackFloatingIpRelease do
23
+ it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
24
+ include_context '#validate!', Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
25
+
26
+ before(:each) do
27
+ @instance = Chef::Knife::Cloud::OpenstackFloatingIpRelease.new
28
+ allow(@instance.ui).to receive(:error)
29
+ @instance.name_args = [ '23849038438240934n3294839248' ]
30
+ end
31
+
32
+ describe 'create service instance' do
33
+ it 'return OpenstackService instance' do
34
+ expect(@instance.create_service_instance).to be_an_instance_of(Chef::Knife::Cloud::OpenstackService)
35
+ end
36
+ end
37
+
38
+ describe 'release floating ip' do
39
+ it 'calls release address' do
40
+ address_id = '23849038438240934n3294839248'
41
+ @instance.service = double
42
+ response = OpenStruct.new(status: 202)
43
+ expect(@instance.service).to receive(:release_address).and_return(response)
44
+ expect(@instance.ui).to receive(:info).and_return('Floating IP released successfully.')
45
+ @instance.execute_command
46
+ end
47
+ end
48
+ end
@@ -32,6 +32,7 @@ describe Chef::Knife::Cloud::OpenstackGroupList do
32
32
  context "#list" do
33
33
  before(:each) do
34
34
  @security_groups = [TestResource.new({ "name" => "Unrestricted","description" => "testdescription", "security_group_rules" => [TestResource.new({"from_port"=>636, "group"=>{}, "ip_protocol"=>"tcp", "to_port"=>636, "parent_group_id"=>14, "ip_range"=>{"cidr"=>"0.0.0.0/0"}, "id"=>183})]})]
35
+ instance.config[:format] = "summary"
35
36
  end
36
37
 
37
38
  it "returns group list" do
@@ -315,6 +315,12 @@ describe Chef::Knife::Cloud::OpenstackServerCreate do
315
315
  @instance.before_bootstrap
316
316
  expect(@instance.config[:bootstrap_network]).to be == 'secure'
317
317
  end
318
+
319
+ it "set openstack ohai hint" do
320
+ allow(@instance.server).to receive(:addresses).and_return({"public"=>[{"version"=>4, "addr"=>"127.0.0.1"}]})
321
+ @instance.before_bootstrap
322
+ expect(@instance.config[:hints]).to be == {'openstack' => {}}
323
+ end
318
324
  end
319
325
 
320
326
  describe "#post_connection_validations" do
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.2.0
4
+ version: 1.3.1
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-06-18 00:00:00.000000000 Z
11
+ date: 2015-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.1.0
47
+ version: 1.2.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.1.0
54
+ version: 1.2.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -143,6 +143,11 @@ files:
143
143
  - lib/chef/knife/cloud/openstack_service.rb
144
144
  - lib/chef/knife/cloud/openstack_service_options.rb
145
145
  - lib/chef/knife/openstack_flavor_list.rb
146
+ - lib/chef/knife/openstack_floating_ip_allocate.rb
147
+ - lib/chef/knife/openstack_floating_ip_associate.rb
148
+ - lib/chef/knife/openstack_floating_ip_disassociate.rb
149
+ - lib/chef/knife/openstack_floating_ip_list.rb
150
+ - lib/chef/knife/openstack_floating_ip_release.rb
146
151
  - lib/chef/knife/openstack_group_list.rb
147
152
  - lib/chef/knife/openstack_helpers.rb
148
153
  - lib/chef/knife/openstack_image_list.rb
@@ -154,6 +159,7 @@ files:
154
159
  - lib/chef/knife/openstack_volume_list.rb
155
160
  - lib/knife-openstack/version.rb
156
161
  - spec/functional/flavor_list_func_spec.rb
162
+ - spec/functional/floating_ip_list_func_spec.rb
157
163
  - spec/functional/group_list_func_spec.rb
158
164
  - spec/functional/image_list_func_spec.rb
159
165
  - spec/functional/network_list_func_spec.rb
@@ -169,6 +175,11 @@ files:
169
175
  - spec/spec_context.rb
170
176
  - spec/spec_helper.rb
171
177
  - spec/unit/openstack_flavor_list_spec.rb
178
+ - spec/unit/openstack_floating_ip_allocate_spec.rb
179
+ - spec/unit/openstack_floating_ip_associate_spec.rb
180
+ - spec/unit/openstack_floating_ip_disassociate_spec.rb
181
+ - spec/unit/openstack_floating_ip_list_spec.rb
182
+ - spec/unit/openstack_floating_ip_release_spec.rb
172
183
  - spec/unit/openstack_group_list_spec.rb
173
184
  - spec/unit/openstack_image_list_spec.rb
174
185
  - spec/unit/openstack_network_list_spec.rb
@@ -203,6 +214,7 @@ specification_version: 4
203
214
  summary: A Chef knife plugin for OpenStack clouds.
204
215
  test_files:
205
216
  - spec/functional/flavor_list_func_spec.rb
217
+ - spec/functional/floating_ip_list_func_spec.rb
206
218
  - spec/functional/group_list_func_spec.rb
207
219
  - spec/functional/image_list_func_spec.rb
208
220
  - spec/functional/network_list_func_spec.rb
@@ -218,6 +230,11 @@ test_files:
218
230
  - spec/spec_context.rb
219
231
  - spec/spec_helper.rb
220
232
  - spec/unit/openstack_flavor_list_spec.rb
233
+ - spec/unit/openstack_floating_ip_allocate_spec.rb
234
+ - spec/unit/openstack_floating_ip_associate_spec.rb
235
+ - spec/unit/openstack_floating_ip_disassociate_spec.rb
236
+ - spec/unit/openstack_floating_ip_list_spec.rb
237
+ - spec/unit/openstack_floating_ip_release_spec.rb
221
238
  - spec/unit/openstack_group_list_spec.rb
222
239
  - spec/unit/openstack_image_list_spec.rb
223
240
  - spec/unit/openstack_network_list_spec.rb
@@ -227,3 +244,4 @@ test_files:
227
244
  - spec/unit/openstack_server_show_spec.rb
228
245
  - spec/unit/openstack_service_spec.rb
229
246
  - spec/unit/openstack_volume_list_spec.rb
247
+ has_rdoc: true