knife-openstack 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/lib/chef/knife/cloud/openstack_server_create_options.rb +16 -1
  3. data/lib/chef/knife/cloud/openstack_service.rb +14 -2
  4. data/lib/chef/knife/cloud/openstack_service_options.rb +17 -1
  5. data/lib/chef/knife/openstack_flavor_list.rb +16 -2
  6. data/lib/chef/knife/openstack_floating_ip_allocate.rb +16 -2
  7. data/lib/chef/knife/openstack_floating_ip_associate.rb +17 -3
  8. data/lib/chef/knife/openstack_floating_ip_disassociate.rb +17 -3
  9. data/lib/chef/knife/openstack_floating_ip_list.rb +16 -2
  10. data/lib/chef/knife/openstack_floating_ip_release.rb +14 -2
  11. data/lib/chef/knife/openstack_group_list.rb +18 -1
  12. data/lib/chef/knife/openstack_helpers.rb +17 -1
  13. data/lib/chef/knife/openstack_image_list.rb +16 -2
  14. data/lib/chef/knife/openstack_network_list.rb +16 -2
  15. data/lib/chef/knife/openstack_server_create.rb +3 -4
  16. data/lib/chef/knife/openstack_server_delete.rb +14 -2
  17. data/lib/chef/knife/openstack_server_list.rb +3 -4
  18. data/lib/chef/knife/openstack_server_show.rb +1 -2
  19. data/lib/chef/knife/openstack_volume_list.rb +4 -4
  20. data/lib/knife-openstack/version.rb +2 -2
  21. metadata +8 -207
  22. data/.github/ISSUE_TEMPLATE.md +0 -21
  23. data/.gitignore +0 -32
  24. data/.travis.yml +0 -18
  25. data/CHANGELOG.md +0 -339
  26. data/CONTRIBUTING.MD +0 -164
  27. data/Gemfile +0 -5
  28. data/README.md +0 -179
  29. data/Rakefile +0 -29
  30. data/knife-openstack.gemspec +0 -41
  31. data/spec/functional/flavor_list_func_spec.rb +0 -47
  32. data/spec/functional/floating_ip_list_func_spec.rb +0 -48
  33. data/spec/functional/group_list_func_spec.rb +0 -65
  34. data/spec/functional/image_list_func_spec.rb +0 -53
  35. data/spec/functional/network_list_func_spec.rb +0 -46
  36. data/spec/functional/server_create_func_spec.rb +0 -118
  37. data/spec/functional/server_delete_func_spec.rb +0 -84
  38. data/spec/functional/server_list_func_spec.rb +0 -98
  39. data/spec/functional/server_show_func_spec.rb +0 -46
  40. data/spec/functional/volume_list_func_spec.rb +0 -46
  41. data/spec/integration/cleanup.rb +0 -89
  42. data/spec/integration/config/environment.yml.sample +0 -13
  43. data/spec/integration/openstack_spec.rb +0 -649
  44. data/spec/spec_context.rb +0 -56
  45. data/spec/spec_helper.rb +0 -128
  46. data/spec/unit/openstack_flavor_list_spec.rb +0 -30
  47. data/spec/unit/openstack_floating_ip_allocate_spec.rb +0 -56
  48. data/spec/unit/openstack_floating_ip_associate_spec.rb +0 -40
  49. data/spec/unit/openstack_floating_ip_disassociate_spec.rb +0 -39
  50. data/spec/unit/openstack_floating_ip_list_spec.rb +0 -27
  51. data/spec/unit/openstack_floating_ip_release_spec.rb +0 -49
  52. data/spec/unit/openstack_group_list_spec.rb +0 -44
  53. data/spec/unit/openstack_image_list_spec.rb +0 -32
  54. data/spec/unit/openstack_network_list_spec.rb +0 -39
  55. data/spec/unit/openstack_server_create_spec.rb +0 -449
  56. data/spec/unit/openstack_server_delete_spec.rb +0 -43
  57. data/spec/unit/openstack_server_list_spec.rb +0 -32
  58. data/spec/unit/openstack_server_show_spec.rb +0 -42
  59. data/spec/unit/openstack_service_spec.rb +0 -128
  60. data/spec/unit/openstack_volume_list_spec.rb +0 -30
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
- source "https://rubygems.org"
3
-
4
- # Specify your gem's dependencies in knife-openstack.gemspec
5
- gemspec
data/README.md DELETED
@@ -1,179 +0,0 @@
1
- # Knife OpenStack
2
-
3
- [![Gem Version](https://badge.fury.io/rb/knife-openstack.svg)](https://rubygems.org/gems/knife-openstack) [![Build Status](https://travis-ci.org/chef/knife-openstack.svg?branch=master)](https://travis-ci.org/chef/knife-openstack) [![Dependency Status](https://gemnasium.com/chef/knife-openstack.svg)](https://gemnasium.com/chef/knife-openstack)
4
-
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).
6
-
7
- Please refer to the [CHANGELOG](CHANGELOG.md) for version history and known issues.
8
-
9
- - Documentation: <https://github.com/chef/knife-openstack/blob/master/README.md>
10
- - Source: <http://github.com/chef/knife-openstack/tree/master>
11
- - Issues: <https://github.com/chef/knife-openstack/issues>
12
- - Slack: <http://community-slack.chef.io/>
13
- - Mailing list: <https://discourse.chef.io/>
14
-
15
- Note: Documentation needs to be updated in chef docs
16
-
17
- ## Requirements
18
-
19
- - Chef 12.0 higher
20
- - Ruby 2.2.2 or higher
21
-
22
- ## Installation
23
-
24
- Using [ChefDK](https://downloads.chef.io/chef-dk/), simply install the Gem:
25
-
26
- ```bash
27
- chef gem install knife-openstack
28
- ```
29
-
30
- ## Configuration
31
-
32
- 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:
33
-
34
- ```ruby
35
- ### Note: If you are not proxying HTTPS to the OpenStack auth port, the scheme should be HTTP
36
- knife[:openstack_auth_url] = "http://cloud.mycompany.com:5000/v2.0/tokens"
37
- knife[:openstack_username] = "Your OpenStack Dashboard username"
38
- knife[:openstack_password] = "Your OpenStack Dashboard password"
39
- knife[:openstack_tenant] = "Your OpenStack tenant name"
40
- knife[:openstack_region] = "Your OpenStack Region"
41
- ```
42
-
43
- All of Fog's `openstack` options (`openstack_domain_name`, `openstack_project_name`, ...) are supported. This includes support for the OpenStack Identity v3
44
-
45
- ```ruby
46
- knife[:openstack_auth_url] = "http://cloud.mycompany.com:5000/v3/auth/tokens"
47
- knife[:openstack_username] = "Your OpenStack Dashboard username"
48
- knife[:openstack_password] = "Your OpenStack Dashboard password"
49
- knife[:openstack_project_name] = "Your OpenStack project"
50
- knife[:openstack_domain_name] = "Your OpenStack domain"
51
- ```
52
-
53
- 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. For example, using the conventions of [OpenStack's RC file](http://docs.openstack.org/user-guide/content/cli_openrc.html) (note the `openstack_auth_url`):
54
-
55
- ```ruby
56
- knife[:openstack_auth_url] = "#{ENV['OS_AUTH_URL']}/tokens"
57
- knife[:openstack_username] = "#{ENV['OS_USERNAME']}"
58
- knife[:openstack_password] = "#{ENV['OS_PASSWORD']}"
59
- knife[:openstack_tenant] = "#{ENV['OS_TENANT_NAME']}"
60
- knife[:openstack_region] = "#{ENV['OS_REGION_NAME']}"
61
- ```
62
-
63
- If your OpenStack deployment is over SSL, but does not have a valid certificate, you can add the following option to bypass SSL check:
64
-
65
- ```ruby
66
- knife[:openstack_insecure] = true
67
- ```
68
-
69
- If you need to use alternate service endpoints for communicating with OpenStack, you can set the following option:
70
-
71
- ```ruby
72
- knife[:openstack_endpoint_type] = "internalURL"
73
- ```
74
-
75
- You also have the option of passing your OpenStack API Username/Password into the individual knife subcommands using the `-A` (or `--openstack-username`) `-K` (or `--openstack-password`) command options
76
-
77
- ```bash
78
- # provision a new image named kb01
79
- knife openstack server create -A 'MyUsername' -K 'MyPassword' --openstack-api-endpoint 'http://cloud.mycompany.com:5000/v2.0/tokens' -f 1 -I 13 -S trystack -i ~/.ssh/trystack.pem -r 'role[webserver]'
80
- ```
81
-
82
- Additionally the following options may be set in your `knife.rb`:
83
-
84
- - flavor
85
- - image
86
- - openstack_ssh_key_id
87
- - template_file
88
-
89
- ## Subcommands
90
-
91
- This plugin provides the following Knife subcommands. Specific command options can be found by invoking the subcommand with a `--help` option.
92
-
93
- ### `knife openstack server create`
94
-
95
- 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.
96
-
97
- #### Working with Windows Images
98
-
99
- 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.
100
-
101
- Example:
102
-
103
- ```bash
104
- $ knife openstack server create -I <Image> -f <Flavor> -S <keypair_name> --bootstrap-protocol winrm -P <Administrator_Password> -x Administrator -N <chef_node_name> --bootstrap-template windows-chef-client-msi.erb
105
- ```
106
-
107
- NOTE:
108
-
109
- - Bootstrap Protocol (`--bootstrap-protocol`) is required to be set to `winrm`.
110
- - Administrator Username (`--winrm-user` or `-x`) and Password (`-P`) are required parameters.
111
- - If the Template File (`--template`) is not specified it defaults to a Linux distro (most likely Ubuntu).
112
-
113
- #### Working with Floating IPs
114
-
115
- To use a floating IP address while bootstrapping nodes, use the `-a` or `--openstack-floating-ip` option.
116
-
117
- ### `knife openstack server delete`
118
-
119
- 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. **PLEASE NOTE** - this does not delete the associated node and client objects from the Chef server without using the `-P` option to purge the client.
120
-
121
- ### `knife openstack server list`
122
-
123
- Outputs a list of all servers in the currently configured OpenStack account. **PLEASE NOTE** - this shows all instances associated with the account, some of which may not be currently managed by the Chef server.
124
-
125
- ### `knife openstack flavor list`
126
-
127
- 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.
128
-
129
- ### `knife openstack volume list`
130
-
131
- 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.
132
-
133
- ### `knife openstack image list`
134
-
135
- 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.
136
-
137
- ### `knife openstack group list`
138
-
139
- 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.
140
-
141
- ### `knife openstack network list`
142
-
143
- 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.
144
-
145
- ### `knife openstack floating_ip list`
146
-
147
- 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`
148
-
149
- ## Contributing
150
-
151
- For information on contributing to this project see <https://github.com/chef/chef/blob/master/CONTRIBUTING.md>
152
-
153
- ## License
154
-
155
- Author:: Seth Chisamore ([schisamo@chef.io](mailto:schisamo@chef.io))
156
-
157
- Author:: Matt Ray ([matt@chef.io](mailto:matt@chef.io))
158
-
159
- Author:: Chirag Jog ([chirag@clogeny.com](mailto:chirag@clogeny.com))
160
-
161
- Author:: JJ Asghar ([jj@chef.io](mailto:jj@chef.io))
162
-
163
- Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
164
-
165
- License:: Apache License, Version 2.0
166
-
167
- ```text
168
- Licensed under the Apache License, Version 2.0 (the "License");
169
- you may not use this file except in compliance with the License.
170
- You may obtain a copy of the License at
171
-
172
- http://www.apache.org/licenses/LICENSE-2.0
173
-
174
- Unless required by applicable law or agreed to in writing, software
175
- distributed under the License is distributed on an "AS IS" BASIS,
176
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
177
- See the License for the specific language governing permissions and
178
- limitations under the License.
179
- ```
data/Rakefile DELETED
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
- # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
3
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
-
5
- require "bundler"
6
- require "bundler/setup"
7
- require "bundler/gem_tasks"
8
- require "chefstyle"
9
- require "rubocop/rake_task"
10
- require "rspec/core/rake_task"
11
- require "github_changelog_generator/task"
12
- require "knife-openstack/version"
13
-
14
- RuboCop::RakeTask.new
15
-
16
- RSpec::Core::RakeTask.new(:spec)
17
-
18
- task default: [:rubocop, :spec]
19
-
20
- begin
21
- require 'github_changelog_generator/task'
22
-
23
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
24
- config.future_release = Knife::OpenStack::VERSION
25
- config.issues = true
26
- end
27
- rescue LoadError
28
- puts 'github_changelog_generator is not available. gem install github_changelog_generator to generate changelogs'
29
- end
@@ -1,41 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- # frozen_string_literal: true
3
- $LOAD_PATH.push File.expand_path("../lib", __FILE__)
4
- require "knife-openstack/version"
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "knife-openstack"
8
- s.version = Knife::OpenStack::VERSION
9
- s.version = "#{s.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV["TRAVIS"]
10
- s.platform = Gem::Platform::RUBY
11
- s.has_rdoc = true
12
- s.extra_rdoc_files = ["README.md", "LICENSE"]
13
- s.authors = ["JJ Asghar"]
14
- s.email = ["jj@chef.io"]
15
- s.homepage = "https://github.com/chef/knife-openstack"
16
- s.summary = "A Chef knife plugin for OpenStack clouds."
17
- s.description = "A Chef knife plugin for OpenStack clouds."
18
- s.license = "Apache-2.0"
19
-
20
- s.files = `git ls-files`.split("\n")
21
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
23
- s.require_paths = ["lib"]
24
-
25
- s.required_ruby_version = ">= 2.2.2"
26
-
27
- s.add_dependency "fog", "~> 1.23"
28
- s.add_dependency "chef", ">= 12"
29
- s.add_dependency "knife-cloud", "~> 1.2.0"
30
-
31
- s.add_development_dependency "chefstyle"
32
- s.add_development_dependency "github_changelog_generator"
33
- s.add_development_dependency "guard-rspec"
34
- s.add_development_dependency "mixlib-shellout"
35
- s.add_development_dependency "rake"
36
- s.add_development_dependency "rspec", "~> 3.0"
37
- s.add_development_dependency "rspec-expectations"
38
- s.add_development_dependency "rspec-mocks"
39
- s.add_development_dependency "rspec_junit_formatter"
40
-
41
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Mukta Aphale (<mukta.aphale@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_flavor_list"
22
- require "chef/knife/cloud/openstack_service"
23
- require "support/shared_examples_for_command"
24
-
25
- describe Chef::Knife::Cloud::OpenstackFlavorList do
26
- let (:instance) { Chef::Knife::Cloud::OpenstackFlavorList.new }
27
-
28
- context "functionality" do
29
- before do
30
- resources = [TestResource.new(id: "resource-1", name: "m1.tiny", vcpus: "1", ram: 512, disk: 0),
31
- TestResource.new(id: "resource-2", name: "m1-xlarge-bigdisk", vcpus: "8", ram: 16_384, disk: 50),
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(["Name", "ID", "Virtual CPUs", "RAM", "Disk",
42
- "m1-xlarge-bigdisk", "resource-2", "8", "16384 MB", "50 GB",
43
- "m1.tiny", "resource-1", "1", "512 MB", "0 GB"], :uneven_columns_across, 5)
44
- instance.run
45
- end
46
- end
47
- end
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Vasundhara Jagdale (<vasundhara.jagdale@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_floating_ip_list"
21
- require "chef/knife/cloud/openstack_service"
22
- require "support/shared_examples_for_command"
23
-
24
- describe Chef::Knife::Cloud::OpenstackFloatingIpList do
25
- let (:instance) { Chef::Knife::Cloud::OpenstackFloatingIpList.new }
26
-
27
- context "functionality" do
28
- before do
29
- resources = [TestResource.new("id" => "floatingip1", "instance_id" => "daed9e86-4b69-4242-993a-926a39352783", "ip" => "173.236.251.98", "fixed_ip" => "", "pool" => "test-pool"
30
- ),
31
- TestResource.new("id" => "floatingip2", "instance_id" => "", "ip" => "67.205.60.122", "fixed_ip" => "10.10.10.1", "pool" => "test-pool"
32
- ),
33
- ]
34
- allow(instance).to receive(:query_resource).and_return(resources)
35
- allow(instance).to receive(:puts)
36
- allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
37
- allow(instance).to receive(:validate!)
38
- instance.config[:format] = "summary"
39
- end
40
-
41
- it "lists formatted list of resources" do
42
- expect(instance.ui).to receive(:list).with(["ID", "Instance ID", "IP Address", "Fixed IP", "Floating IP Pool",
43
- "floatingip1", "daed9e86-4b69-4242-993a-926a39352783", "173.236.251.98", "", "test-pool",
44
- "floatingip2", "", "67.205.60.122", "10.10.10.1", "test-pool"], :uneven_columns_across, 5)
45
- instance.run
46
- end
47
- end
48
- end
@@ -1,65 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
4
- # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
5
- # Author:: Ameya Varade (<ameya.varade@clogeny.com>)
6
- # Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
7
- # License:: Apache License, Version 2.0
8
- #
9
- # Licensed under the Apache License, Version 2.0 (the "License");
10
- # you may not use this file except in compliance with the License.
11
- # You may obtain a copy of the License at
12
- #
13
- # http://www.apache.org/licenses/LICENSE-2.0
14
- #
15
- # Unless required by applicable law or agreed to in writing, software
16
- # distributed under the License is distributed on an "AS IS" BASIS,
17
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
-
21
- require "spec_helper"
22
- require "chef/knife/openstack_group_list"
23
- require "chef/knife/cloud/openstack_service"
24
-
25
- describe Chef::Knife::Cloud::OpenstackGroupList do
26
- let (:instance) { Chef::Knife::Cloud::OpenstackGroupList.new }
27
-
28
- context "functionality" do
29
- before do
30
- resources = [TestResource.new("name" => "Unrestricted",
31
- "description" => "All ports open",
32
- "security_group_rules" => [TestResource.new("from_port" => 1,
33
- "group" => {},
34
- "ip_protocol" => "tcp",
35
- "to_port" => 636,
36
- "parent_group_id" => 14,
37
- "ip_range" => { "cidr" => "0.0.0.0/0" },
38
- "id" => 1),
39
- ]),
40
- TestResource.new("name" => "WindowsDomain",
41
- "description" => "Allows common protocols useful in a Windows domain",
42
- "security_group_rules" => [TestResource.new("from_port" => 22,
43
- "group" => {},
44
- "ip_protocol" => "tcp",
45
- "to_port" => 636,
46
- "parent_group_id" => 14,
47
- "ip_range" => { "cidr" => "0.0.0.0/0" },
48
- "id" => 2),
49
- ]),
50
- ]
51
- allow(instance).to receive(:query_resource).and_return(resources)
52
- allow(instance).to receive(:puts)
53
- allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
54
- allow(instance).to receive(:validate!)
55
- instance.config[:format] = "summary"
56
- end
57
-
58
- it "lists formatted list of resources" do
59
- expect(instance.ui).to receive(:list).with(["Name", "Protocol", "From", "To", "CIDR", "Description",
60
- "Unrestricted", "tcp", "1", "636", "0.0.0.0/0", "All ports open",
61
- "WindowsDomain", "tcp", "22", "636", "0.0.0.0/0", "Allows common protocols useful in a Windows domain"], :uneven_columns_across, 6)
62
- instance.run
63
- end
64
- end
65
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- # Author:: Mukta Aphale (<mukta.aphale@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_image_list"
22
- require "chef/knife/cloud/openstack_service"
23
-
24
- describe Chef::Knife::Cloud::OpenstackImageList do
25
- let (:instance) { Chef::Knife::Cloud::OpenstackImageList.new }
26
-
27
- context "functionality" do
28
- before do
29
- resources = [TestResource.new(id: "resource-1", name: "image01", metadata: {}),
30
- TestResource.new(id: "resource-2", name: "initrd", metadata: {}),
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
- instance.config[:format] = "summary"
37
- end
38
-
39
- it "displays formatted list of images, filtered by default" do
40
- expect(instance.ui).to receive(:list).with(["Name", "ID", "Snapshot",
41
- "image01", "resource-1", "no"], :uneven_columns_across, 3)
42
- instance.run
43
- end
44
-
45
- it "lists all images when disable_filter = true" do
46
- instance.config[:disable_filter] = true
47
- expect(instance.ui).to receive(:list).with(["Name", "ID", "Snapshot",
48
- "image01", "resource-1", "no",
49
- "initrd", "resource-2", "no"], :uneven_columns_across, 3)
50
- instance.run
51
- end
52
- end
53
- end