knife-openstack 1.3.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +21 -0
- data/.gitignore +5 -0
- data/.travis.yml +9 -7
- data/CHANGELOG.md +174 -92
- data/Gemfile +15 -3
- data/README.md +96 -68
- data/Rakefile +19 -6
- data/knife-openstack.gemspec +17 -15
- data/lib/chef/knife/cloud/openstack_server_create_options.rb +36 -35
- data/lib/chef/knife/cloud/openstack_service.rb +7 -6
- data/lib/chef/knife/cloud/openstack_service_options.rb +18 -17
- data/lib/chef/knife/openstack_flavor_list.rb +11 -10
- data/lib/chef/knife/openstack_floating_ip_allocate.rb +13 -12
- data/lib/chef/knife/openstack_floating_ip_associate.rb +9 -8
- data/lib/chef/knife/openstack_floating_ip_disassociate.rb +9 -8
- data/lib/chef/knife/openstack_floating_ip_list.rb +10 -9
- data/lib/chef/knife/openstack_floating_ip_release.rb +7 -6
- data/lib/chef/knife/openstack_group_list.rb +13 -12
- data/lib/chef/knife/openstack_helpers.rb +8 -7
- data/lib/chef/knife/openstack_image_list.rb +14 -13
- data/lib/chef/knife/openstack_network_list.rb +10 -9
- data/lib/chef/knife/openstack_server_create.rb +57 -56
- data/lib/chef/knife/openstack_server_delete.rb +7 -6
- data/lib/chef/knife/openstack_server_list.rb +16 -15
- data/lib/chef/knife/openstack_server_show.rb +17 -16
- data/lib/chef/knife/openstack_volume_list.rb +10 -9
- data/lib/knife-openstack/version.rb +3 -2
- data/spec/functional/flavor_list_func_spec.rb +13 -12
- data/spec/functional/floating_ip_list_func_spec.rb +14 -13
- data/spec/functional/group_list_func_spec.rb +29 -28
- data/spec/functional/image_list_func_spec.rb +15 -14
- data/spec/functional/network_list_func_spec.rb +13 -12
- data/spec/functional/server_create_func_spec.rb +29 -28
- data/spec/functional/server_delete_func_spec.rb +18 -17
- data/spec/functional/server_list_func_spec.rb +43 -42
- data/spec/functional/server_show_func_spec.rb +7 -6
- data/spec/functional/volume_list_func_spec.rb +12 -11
- data/spec/integration/cleanup.rb +6 -5
- data/spec/integration/openstack_spec.rb +287 -286
- data/spec/spec_context.rb +10 -9
- data/spec/spec_helper.rb +38 -37
- data/spec/unit/openstack_flavor_list_spec.rb +6 -5
- data/spec/unit/openstack_floating_ip_allocate_spec.rb +14 -13
- data/spec/unit/openstack_floating_ip_associate_spec.rb +11 -10
- data/spec/unit/openstack_floating_ip_disassociate_spec.rb +12 -11
- data/spec/unit/openstack_floating_ip_list_spec.rb +6 -5
- data/spec/unit/openstack_floating_ip_release_spec.rb +13 -12
- data/spec/unit/openstack_group_list_spec.rb +11 -10
- data/spec/unit/openstack_image_list_spec.rb +6 -5
- data/spec/unit/openstack_network_list_spec.rb +8 -7
- data/spec/unit/openstack_server_create_spec.rb +131 -130
- data/spec/unit/openstack_server_delete_spec.rb +8 -7
- data/spec/unit/openstack_server_list_spec.rb +6 -5
- data/spec/unit/openstack_server_show_spec.rb +10 -9
- data/spec/unit/openstack_service_spec.rb +26 -25
- data/spec/unit/openstack_volume_list_spec.rb +6 -5
- metadata +9 -105
@@ -1,14 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
3
4
|
# Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
|
4
5
|
# Copyright:: Copyright (c) 2013 Chef Software, Inc.
|
5
6
|
#
|
6
7
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
8
|
+
require "chef/knife/cloud/server/delete_options"
|
9
|
+
require "chef/knife/cloud/server/delete_command"
|
10
|
+
require "chef/knife/cloud/openstack_service"
|
11
|
+
require "chef/knife/cloud/openstack_service_options"
|
12
|
+
require "chef/knife/openstack_helpers"
|
12
13
|
|
13
14
|
class Chef
|
14
15
|
class Knife
|
@@ -18,7 +19,7 @@ class Chef
|
|
18
19
|
include OpenstackServiceOptions
|
19
20
|
include OpenstackHelpers
|
20
21
|
|
21
|
-
banner
|
22
|
+
banner "knife openstack server delete INSTANCEID [INSTANCEID] (options)"
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Seth Chisamore (<schisamo@getchef.com>)
|
3
4
|
# Author:: Matt Ray (<matt@getchef.com>)
|
@@ -19,10 +20,10 @@
|
|
19
20
|
# limitations under the License.
|
20
21
|
#
|
21
22
|
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
23
|
+
require "chef/knife/cloud/server/list_command"
|
24
|
+
require "chef/knife/openstack_helpers"
|
25
|
+
require "chef/knife/cloud/openstack_service_options"
|
26
|
+
require "chef/knife/cloud/server/list_options"
|
26
27
|
|
27
28
|
class Chef
|
28
29
|
class Knife
|
@@ -32,21 +33,21 @@ class Chef
|
|
32
33
|
include OpenstackServiceOptions
|
33
34
|
include ServerListOptions
|
34
35
|
|
35
|
-
banner
|
36
|
+
banner "knife openstack server list (options)"
|
36
37
|
|
37
38
|
def before_exec_command
|
38
39
|
# set columns_with_info map
|
39
40
|
@columns_with_info = [
|
40
|
-
{ label:
|
41
|
-
{ label:
|
42
|
-
{ label:
|
43
|
-
{ label:
|
44
|
-
{ label:
|
45
|
-
{ label:
|
46
|
-
{ label:
|
47
|
-
{ label:
|
41
|
+
{ label: "Name", key: "name" },
|
42
|
+
{ label: "Instance ID", key: "id" },
|
43
|
+
{ label: "Addresses", key: "addresses", value_callback: method(:addresses) },
|
44
|
+
{ label: "Flavor", key: "flavor", value_callback: method(:get_id) },
|
45
|
+
{ label: "Image", key: "image", value_callback: method(:get_id) },
|
46
|
+
{ label: "Keypair", key: "key_name" },
|
47
|
+
{ label: "State", key: "state" },
|
48
|
+
{ label: "Availability Zone", key: "availability_zone" },
|
48
49
|
]
|
49
|
-
@sort_by_field =
|
50
|
+
@sort_by_field = "name"
|
50
51
|
super
|
51
52
|
end
|
52
53
|
|
@@ -55,7 +56,7 @@ class Chef
|
|
55
56
|
end
|
56
57
|
|
57
58
|
def get_id(value)
|
58
|
-
value[
|
59
|
+
value["id"]
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Copyright:: Copyright (c) 2011-2013 Chef Software, Inc.
|
3
4
|
# License:: Apache License, Version 2.0
|
@@ -15,12 +16,12 @@
|
|
15
16
|
# limitations under the License.
|
16
17
|
#
|
17
18
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
19
|
+
require "chef/knife/cloud/server/show_command"
|
20
|
+
require "chef/knife/openstack_helpers"
|
21
|
+
require "chef/knife/cloud/server/show_options"
|
22
|
+
require "chef/knife/cloud/openstack_service"
|
23
|
+
require "chef/knife/cloud/openstack_service_options"
|
24
|
+
require "chef/knife/cloud/exceptions"
|
24
25
|
|
25
26
|
class Chef
|
26
27
|
class Knife
|
@@ -30,25 +31,25 @@ class Chef
|
|
30
31
|
include OpenstackServiceOptions
|
31
32
|
include ServerShowOptions
|
32
33
|
|
33
|
-
banner
|
34
|
+
banner "knife openstack server show (options)"
|
34
35
|
|
35
36
|
def before_exec_command
|
36
37
|
# set columns_with_info map
|
37
38
|
@columns_with_info = [
|
38
|
-
{ label:
|
39
|
-
{ label:
|
40
|
-
{ label:
|
41
|
-
{ label:
|
42
|
-
{ label:
|
43
|
-
{ label:
|
44
|
-
{ label:
|
45
|
-
{ label:
|
39
|
+
{ label: "Instance ID", key: "id" },
|
40
|
+
{ label: "Name", key: "name" },
|
41
|
+
{ label: "Addresses", key: "addresses", value_callback: method(:instance_addresses) },
|
42
|
+
{ label: "Flavor", key: "flavor", value_callback: method(:get_id) },
|
43
|
+
{ label: "Image", key: "image", value_callback: method(:get_id) },
|
44
|
+
{ label: "Keypair", key: "key_name" },
|
45
|
+
{ label: "State", key: "state" },
|
46
|
+
{ label: "Availability Zone", key: "availability_zone" },
|
46
47
|
]
|
47
48
|
super
|
48
49
|
end
|
49
50
|
|
50
51
|
def get_id(value)
|
51
|
-
value[
|
52
|
+
value["id"]
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Seth Chisamore (<schisamo@getchef.com>)
|
3
4
|
# Author:: Matt Ray (<matt@getchef.com>)
|
@@ -18,9 +19,9 @@
|
|
18
19
|
# limitations under the License.
|
19
20
|
#
|
20
21
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
22
|
+
require "chef/knife/cloud/list_resource_command"
|
23
|
+
require "chef/knife/openstack_helpers"
|
24
|
+
require "chef/knife/cloud/openstack_service_options"
|
24
25
|
|
25
26
|
class Chef
|
26
27
|
class Knife
|
@@ -29,7 +30,7 @@ class Chef
|
|
29
30
|
include OpenstackHelpers
|
30
31
|
include OpenstackServiceOptions
|
31
32
|
|
32
|
-
banner
|
33
|
+
banner "knife openstack volume list (options)"
|
33
34
|
|
34
35
|
def query_resource
|
35
36
|
@service.connection.volumes
|
@@ -41,11 +42,11 @@ class Chef
|
|
41
42
|
|
42
43
|
def list(volumes)
|
43
44
|
volume_list = [
|
44
|
-
ui.color(
|
45
|
-
ui.color(
|
46
|
-
ui.color(
|
47
|
-
ui.color(
|
48
|
-
ui.color(
|
45
|
+
ui.color("Name", :bold),
|
46
|
+
ui.color("ID", :bold),
|
47
|
+
ui.color("Status", :bold),
|
48
|
+
ui.color("Size", :bold),
|
49
|
+
ui.color("Description", :bold),
|
49
50
|
]
|
50
51
|
begin
|
51
52
|
volumes.sort_by(&:name).each do |volume|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
|
3
4
|
# Author:: Ameya Varade (<ameya.varade@clogeny.com>)
|
@@ -16,30 +17,30 @@
|
|
16
17
|
# See the License for the specific language governing permissions and
|
17
18
|
# limitations under the License.
|
18
19
|
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
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"
|
23
24
|
|
24
25
|
describe Chef::Knife::Cloud::OpenstackFlavorList do
|
25
26
|
let (:instance) { Chef::Knife::Cloud::OpenstackFlavorList.new }
|
26
27
|
|
27
|
-
context
|
28
|
+
context "functionality" do
|
28
29
|
before do
|
29
|
-
resources = [TestResource.new(id:
|
30
|
-
TestResource.new(id:
|
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),
|
31
32
|
]
|
32
33
|
allow(instance).to receive(:query_resource).and_return(resources)
|
33
34
|
allow(instance).to receive(:puts)
|
34
35
|
allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
|
35
36
|
allow(instance).to receive(:validate!)
|
36
|
-
instance.config[:format] =
|
37
|
+
instance.config[:format] = "summary"
|
37
38
|
end
|
38
39
|
|
39
|
-
it
|
40
|
-
expect(instance.ui).to receive(:list).with([
|
41
|
-
|
42
|
-
|
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)
|
43
44
|
instance.run
|
44
45
|
end
|
45
46
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Vasundhara Jagdale (<vasundhara.jagdale@clogeny.com>)
|
3
4
|
# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
|
@@ -15,32 +16,32 @@
|
|
15
16
|
# See the License for the specific language governing permissions and
|
16
17
|
# limitations under the License.
|
17
18
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
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"
|
22
23
|
|
23
24
|
describe Chef::Knife::Cloud::OpenstackFloatingIpList do
|
24
25
|
let (:instance) { Chef::Knife::Cloud::OpenstackFloatingIpList.new }
|
25
26
|
|
26
|
-
context
|
27
|
+
context "functionality" do
|
27
28
|
before do
|
28
|
-
resources = [TestResource.new(
|
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"
|
29
32
|
),
|
30
|
-
TestResource.new('id' => 'floatingip2', 'instance_id' => '', 'ip' => '67.205.60.122', 'fixed_ip' => '10.10.10.1', 'pool' => 'test-pool'
|
31
|
-
)
|
32
33
|
]
|
33
34
|
allow(instance).to receive(:query_resource).and_return(resources)
|
34
35
|
allow(instance).to receive(:puts)
|
35
36
|
allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
|
36
37
|
allow(instance).to receive(:validate!)
|
37
|
-
instance.config[:format] =
|
38
|
+
instance.config[:format] = "summary"
|
38
39
|
end
|
39
40
|
|
40
|
-
it
|
41
|
-
expect(instance.ui).to receive(:list).with([
|
42
|
-
|
43
|
-
|
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)
|
44
45
|
instance.run
|
45
46
|
end
|
46
47
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
|
3
4
|
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
@@ -17,47 +18,47 @@
|
|
17
18
|
# See the License for the specific language governing permissions and
|
18
19
|
# limitations under the License.
|
19
20
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
21
|
+
require "spec_helper"
|
22
|
+
require "chef/knife/openstack_group_list"
|
23
|
+
require "chef/knife/cloud/openstack_service"
|
23
24
|
|
24
25
|
describe Chef::Knife::Cloud::OpenstackGroupList do
|
25
26
|
let (:instance) { Chef::Knife::Cloud::OpenstackGroupList.new }
|
26
27
|
|
27
|
-
context
|
28
|
+
context "functionality" do
|
28
29
|
before do
|
29
|
-
resources = [TestResource.new(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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),
|
38
49
|
]),
|
39
|
-
TestResource.new('name' => 'WindowsDomain',
|
40
|
-
'description' => 'Allows common protocols useful in a Windows domain',
|
41
|
-
'security_group_rules' => [TestResource.new('from_port' => 22,
|
42
|
-
'group' => {},
|
43
|
-
'ip_protocol' => 'tcp',
|
44
|
-
'to_port' => 636,
|
45
|
-
'parent_group_id' => 14,
|
46
|
-
'ip_range' => { 'cidr' => '0.0.0.0/0' },
|
47
|
-
'id' => 2)
|
48
|
-
])
|
49
50
|
]
|
50
51
|
allow(instance).to receive(:query_resource).and_return(resources)
|
51
52
|
allow(instance).to receive(:puts)
|
52
53
|
allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
|
53
54
|
allow(instance).to receive(:validate!)
|
54
|
-
instance.config[:format] =
|
55
|
+
instance.config[:format] = "summary"
|
55
56
|
end
|
56
57
|
|
57
|
-
it
|
58
|
-
expect(instance.ui).to receive(:list).with([
|
59
|
-
|
60
|
-
|
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)
|
61
62
|
instance.run
|
62
63
|
end
|
63
64
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
|
3
4
|
# Author:: Ameya Varade (<ameya.varade@clogeny.com>)
|
@@ -16,36 +17,36 @@
|
|
16
17
|
# See the License for the specific language governing permissions and
|
17
18
|
# limitations under the License.
|
18
19
|
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
20
|
+
require "spec_helper"
|
21
|
+
require "chef/knife/openstack_image_list"
|
22
|
+
require "chef/knife/cloud/openstack_service"
|
22
23
|
|
23
24
|
describe Chef::Knife::Cloud::OpenstackImageList do
|
24
25
|
let (:instance) { Chef::Knife::Cloud::OpenstackImageList.new }
|
25
26
|
|
26
|
-
context
|
27
|
+
context "functionality" do
|
27
28
|
before do
|
28
|
-
resources = [TestResource.new(id:
|
29
|
-
TestResource.new(id:
|
29
|
+
resources = [TestResource.new(id: "resource-1", name: "image01", metadata: {}),
|
30
|
+
TestResource.new(id: "resource-2", name: "initrd", metadata: {}),
|
30
31
|
]
|
31
32
|
allow(instance).to receive(:query_resource).and_return(resources)
|
32
33
|
allow(instance).to receive(:puts)
|
33
34
|
allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
|
34
35
|
allow(instance).to receive(:validate!)
|
35
|
-
instance.config[:format] =
|
36
|
+
instance.config[:format] = "summary"
|
36
37
|
end
|
37
38
|
|
38
|
-
it
|
39
|
-
expect(instance.ui).to receive(:list).with([
|
40
|
-
|
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)
|
41
42
|
instance.run
|
42
43
|
end
|
43
44
|
|
44
|
-
it
|
45
|
+
it "lists all images when disable_filter = true" do
|
45
46
|
instance.config[:disable_filter] = true
|
46
|
-
expect(instance.ui).to receive(:list).with([
|
47
|
-
|
48
|
-
|
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)
|
49
50
|
instance.run
|
50
51
|
end
|
51
52
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Ameya Varade (<ameya.varade@clogeny.com>)
|
3
4
|
# Copyright:: Copyright (c) 2014 Chef Software, Inc.
|
@@ -15,30 +16,30 @@
|
|
15
16
|
# See the License for the specific language governing permissions and
|
16
17
|
# limitations under the License.
|
17
18
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
19
|
+
require "spec_helper"
|
20
|
+
require "chef/knife/openstack_network_list"
|
21
|
+
require "chef/knife/cloud/openstack_service"
|
22
|
+
require "support/shared_examples_for_command"
|
22
23
|
|
23
24
|
describe Chef::Knife::Cloud::OpenstackNetworkList do
|
24
25
|
let (:instance) { Chef::Knife::Cloud::OpenstackNetworkList.new }
|
25
26
|
|
26
|
-
context
|
27
|
+
context "functionality" do
|
27
28
|
before do
|
28
|
-
resources = [TestResource.new(id:
|
29
|
-
TestResource.new(id:
|
29
|
+
resources = [TestResource.new(id: "resource-1", name: "external", tenant_id: "1", shared: true),
|
30
|
+
TestResource.new(id: "resource-2", name: "internal", tenant_id: "2", shared: false),
|
30
31
|
]
|
31
32
|
allow(instance).to receive(:query_resource).and_return(resources)
|
32
33
|
allow(instance).to receive(:puts)
|
33
34
|
allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new)
|
34
35
|
allow(instance).to receive(:validate!)
|
35
|
-
instance.config[:format] =
|
36
|
+
instance.config[:format] = "summary"
|
36
37
|
end
|
37
38
|
|
38
|
-
it
|
39
|
-
expect(instance.ui).to receive(:list).with([
|
40
|
-
|
41
|
-
|
39
|
+
it "lists formatted list of network resources" do
|
40
|
+
expect(instance.ui).to receive(:list).with(["Name", "ID", "Tenant", "Shared",
|
41
|
+
"external", "resource-1", "1", "true",
|
42
|
+
"internal", "resource-2", "2", "false"], :uneven_columns_across, 4)
|
42
43
|
instance.run
|
43
44
|
end
|
44
45
|
end
|