knife-openstack 1.3.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
|
3
4
|
# Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
|
@@ -19,17 +20,17 @@
|
|
19
20
|
# See the License for the specific language governing permissions and
|
20
21
|
# limitations under the License.
|
21
22
|
|
22
|
-
require File.expand_path(
|
23
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
23
24
|
|
24
25
|
describe Chef::Knife::Cloud::OpenstackServerCreate do
|
25
26
|
before do
|
26
27
|
@knife_openstack_create = Chef::Knife::Cloud::OpenstackServerCreate.new
|
27
28
|
{
|
28
|
-
image:
|
29
|
-
openstack_username:
|
30
|
-
openstack_password:
|
31
|
-
openstack_auth_url:
|
32
|
-
server_create_timeout: 1000
|
29
|
+
image: "image",
|
30
|
+
openstack_username: "openstack_username",
|
31
|
+
openstack_password: "openstack_password",
|
32
|
+
openstack_auth_url: "openstack_auth_url",
|
33
|
+
server_create_timeout: 1000,
|
33
34
|
}.each do |key, value|
|
34
35
|
Chef::Config[:knife][key] = value
|
35
36
|
end
|
@@ -38,26 +39,26 @@ describe Chef::Knife::Cloud::OpenstackServerCreate do
|
|
38
39
|
allow(@openstack_service).to receive(:msg_pair)
|
39
40
|
allow(@openstack_service).to receive(:print)
|
40
41
|
image = Object.new
|
41
|
-
allow(image).to receive(:id).and_return(
|
42
|
+
allow(image).to receive(:id).and_return("image_id")
|
42
43
|
allow(@openstack_service).to receive(:get_image).and_return(image)
|
43
44
|
flavor = Object.new
|
44
|
-
allow(flavor).to receive(:id).and_return(
|
45
|
+
allow(flavor).to receive(:id).and_return("flavor_id")
|
45
46
|
allow(@openstack_service).to receive(:get_flavor).and_return(flavor)
|
46
47
|
|
47
48
|
allow(@knife_openstack_create).to receive(:create_service_instance).and_return(@openstack_service)
|
48
49
|
allow(@knife_openstack_create).to receive(:puts)
|
49
50
|
@new_openstack_server = double
|
50
51
|
|
51
|
-
@openstack_server_attribs = { name:
|
52
|
-
id:
|
53
|
-
key_name:
|
54
|
-
flavor:
|
55
|
-
image:
|
52
|
+
@openstack_server_attribs = { name: "Mock Server",
|
53
|
+
id: "id-123456",
|
54
|
+
key_name: "key_name",
|
55
|
+
flavor: "flavor_id",
|
56
|
+
image: "image_id",
|
56
57
|
addresses: {
|
57
|
-
|
58
|
-
|
58
|
+
"public" => [{ "addr" => "75.101.253.10" }],
|
59
|
+
"private" => [{ "addr" => "10.251.75.20" }],
|
59
60
|
},
|
60
|
-
password:
|
61
|
+
password: "password",
|
61
62
|
}
|
62
63
|
|
63
64
|
@openstack_server_attribs.each_pair do |attrib, value|
|
@@ -65,25 +66,25 @@ describe Chef::Knife::Cloud::OpenstackServerCreate do
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
|
-
describe
|
69
|
+
describe "run" do
|
69
70
|
before(:each) do
|
70
71
|
allow(@knife_openstack_create).to receive(:validate_params!)
|
71
72
|
allow(Fog::Compute::OpenStack).to receive_message_chain(:new, :servers, :create).and_return(@new_openstack_server)
|
72
|
-
@knife_openstack_create.config[:openstack_floating_ip] =
|
73
|
+
@knife_openstack_create.config[:openstack_floating_ip] = "-1"
|
73
74
|
allow(@new_openstack_server).to receive(:wait_for)
|
74
75
|
end
|
75
76
|
|
76
|
-
context
|
77
|
+
context "for Linux" do
|
77
78
|
before do
|
78
|
-
@config = { openstack_floating_ip:
|
79
|
-
@knife_openstack_create.config[:distro] =
|
79
|
+
@config = { openstack_floating_ip: "-1", bootstrap_ip_address: "75.101.253.10", ssh_password: "password", hints: { "openstack" => {} } }
|
80
|
+
@knife_openstack_create.config[:distro] = "chef-full"
|
80
81
|
@bootstrapper = Chef::Knife::Cloud::Bootstrapper.new(@config)
|
81
82
|
@ssh_bootstrap_protocol = Chef::Knife::Cloud::SshBootstrapProtocol.new(@config)
|
82
83
|
@unix_distribution = Chef::Knife::Cloud::UnixDistribution.new(@config)
|
83
84
|
allow(@ssh_bootstrap_protocol).to receive(:send_bootstrap_command)
|
84
85
|
end
|
85
86
|
|
86
|
-
it
|
87
|
+
it "Creates an OpenStack instance and bootstraps it" do
|
87
88
|
expect(Chef::Knife::Cloud::Bootstrapper).to receive(:new).with(@config).and_return(@bootstrapper)
|
88
89
|
allow(@bootstrapper).to receive(:bootstrap).and_call_original
|
89
90
|
expect(@bootstrapper).to receive(:create_bootstrap_protocol).and_return(@ssh_bootstrap_protocol)
|
@@ -93,17 +94,17 @@ describe Chef::Knife::Cloud::OpenstackServerCreate do
|
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
96
|
-
context
|
97
|
+
context "for Windows" do
|
97
98
|
before do
|
98
|
-
@config = { openstack_floating_ip:
|
99
|
-
@knife_openstack_create.config[:image_os_type] =
|
100
|
-
@knife_openstack_create.config[:bootstrap_protocol] =
|
101
|
-
@knife_openstack_create.config[:distro] =
|
99
|
+
@config = { openstack_floating_ip: "-1", image_os_type: "windows", bootstrap_ip_address: "75.101.253.10", bootstrap_protocol: "winrm", ssh_password: "password", hints: { "openstack" => {} } }
|
100
|
+
@knife_openstack_create.config[:image_os_type] = "windows"
|
101
|
+
@knife_openstack_create.config[:bootstrap_protocol] = "winrm"
|
102
|
+
@knife_openstack_create.config[:distro] = "windows-chef-client-msi"
|
102
103
|
@bootstrapper = Chef::Knife::Cloud::Bootstrapper.new(@config)
|
103
104
|
@winrm_bootstrap_protocol = Chef::Knife::Cloud::WinrmBootstrapProtocol.new(@config)
|
104
105
|
@windows_distribution = Chef::Knife::Cloud::WindowsDistribution.new(@config)
|
105
106
|
end
|
106
|
-
it
|
107
|
+
it "Creates an OpenStack instance for Windows and bootstraps it" do
|
107
108
|
expect(Chef::Knife::Cloud::Bootstrapper).to receive(:new).with(@config).and_return(@bootstrapper)
|
108
109
|
allow(@bootstrapper).to receive(:bootstrap).and_call_original
|
109
110
|
expect(@bootstrapper).to receive(:create_bootstrap_protocol).and_return(@winrm_bootstrap_protocol)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
3
4
|
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
@@ -17,9 +18,9 @@
|
|
17
18
|
# See the License for the specific language governing permissions and
|
18
19
|
# limitations under the License.
|
19
20
|
|
20
|
-
require File.expand_path(
|
21
|
-
require
|
22
|
-
require
|
21
|
+
require File.expand_path("../../spec_helper", __FILE__)
|
22
|
+
require "chef/knife/openstack_server_delete"
|
23
|
+
require "chef/knife/cloud/openstack_service"
|
23
24
|
|
24
25
|
describe Chef::Knife::Cloud::OpenstackServerDelete do
|
25
26
|
before do
|
@@ -28,9 +29,9 @@ describe Chef::Knife::Cloud::OpenstackServerDelete do
|
|
28
29
|
@chef_client = double(Chef::ApiClient)
|
29
30
|
@knife_openstack_delete = Chef::Knife::Cloud::OpenstackServerDelete.new
|
30
31
|
{
|
31
|
-
openstack_username:
|
32
|
-
openstack_password:
|
33
|
-
openstack_auth_url:
|
32
|
+
openstack_username: "openstack_username",
|
33
|
+
openstack_password: "openstack_password",
|
34
|
+
openstack_auth_url: "openstack_auth_url",
|
34
35
|
}.each do |key, value|
|
35
36
|
Chef::Config[:knife][key] = value
|
36
37
|
end
|
@@ -42,24 +43,24 @@ describe Chef::Knife::Cloud::OpenstackServerDelete do
|
|
42
43
|
allow(@knife_openstack_delete.ui).to receive(:confirm)
|
43
44
|
@openstack_servers = double
|
44
45
|
@running_openstack_server = double
|
45
|
-
@openstack_server_attribs = { name:
|
46
|
-
id:
|
47
|
-
flavor:
|
48
|
-
image:
|
46
|
+
@openstack_server_attribs = { name: "Mock Server",
|
47
|
+
id: "id-123456",
|
48
|
+
flavor: "flavor_id",
|
49
|
+
image: "image_id",
|
49
50
|
addresses: {
|
50
|
-
|
51
|
-
|
52
|
-
}
|
51
|
+
"public" => [{ "addr" => "75.101.253.10" }],
|
52
|
+
"private" => [{ "addr" => "10.251.75.20" }],
|
53
|
+
},
|
53
54
|
}
|
54
55
|
|
55
56
|
@openstack_server_attribs.each_pair do |attrib, value|
|
56
57
|
allow(@running_openstack_server).to receive(attrib).and_return(value)
|
57
58
|
end
|
58
|
-
@knife_openstack_delete.name_args = [
|
59
|
+
@knife_openstack_delete.name_args = ["test001"]
|
59
60
|
end
|
60
61
|
|
61
|
-
describe
|
62
|
-
it
|
62
|
+
describe "run" do
|
63
|
+
it "deletes an OpenStack instance." do
|
63
64
|
expect(@openstack_servers).to receive(:get).and_return(@running_openstack_server)
|
64
65
|
expect(@openstack_connection).to receive(:servers).and_return(@openstack_servers)
|
65
66
|
expect(Fog::Compute::OpenStack).to receive(:new).and_return(@openstack_connection)
|
@@ -67,7 +68,7 @@ describe Chef::Knife::Cloud::OpenstackServerDelete do
|
|
67
68
|
@knife_openstack_delete.run
|
68
69
|
end
|
69
70
|
|
70
|
-
it
|
71
|
+
it "deletes the instance along with the node and client on the chef-server when --purge is given as an option." do
|
71
72
|
@knife_openstack_delete.config[:purge] = true
|
72
73
|
expect(Chef::Node).to receive(:load).and_return(@chef_node)
|
73
74
|
expect(@chef_node).to receive(:destroy)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# Author:: Mukta Aphale (<mukta.aphale@clogeny.com>)
|
3
4
|
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
@@ -18,78 +19,78 @@
|
|
18
19
|
# See the License for the specific language governing permissions and
|
19
20
|
# limitations under the License.
|
20
21
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
22
|
+
require "spec_helper"
|
23
|
+
require "chef/knife/openstack_server_list"
|
24
|
+
require "chef/knife/cloud/openstack_service"
|
24
25
|
|
25
26
|
describe Chef::Knife::Cloud::OpenstackServerList do
|
26
27
|
let (:instance) { Chef::Knife::Cloud::OpenstackServerList.new }
|
27
28
|
|
28
|
-
context
|
29
|
+
context "functionality" do
|
29
30
|
before do
|
30
|
-
@resources = [TestResource.new(id:
|
31
|
-
TestResource.new(id:
|
32
|
-
TestResource.new(id:
|
31
|
+
@resources = [TestResource.new(id: "resource-1", name: "ubuntu01", availability_zone: "test zone", addresses: { "public" => [{ "version" => 4, "addr" => "172.31.6.132" }], "private" => [{ "version" => 4, "addr" => "172.31.6.133" }] }, flavor: { "id" => "1" }, image: { "id" => "image1" }, key_name: "keypair", state: "ACTIVE"),
|
32
|
+
TestResource.new(id: "resource-2", name: "windows2008", availability_zone: "test zone", addresses: { "public" => [{ "version" => 4, "addr" => "172.31.6.132" }] }, flavor: { "id" => "id2" }, image: { "id" => "image2" }, key_name: "keypair", state: "ACTIVE"),
|
33
|
+
TestResource.new(id: "resource-3-err", name: "windows2008", availability_zone: "test zone", addresses: { "public" => [], "private" => [] }, flavor: { "id" => "id2" }, image: { "id" => "image2" }, key_name: "keypair", state: "ERROR"),
|
33
34
|
]
|
34
35
|
allow(instance).to receive(:query_resource).and_return(@resources)
|
35
36
|
allow(instance).to receive(:puts)
|
36
37
|
allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::FogService.new)
|
37
38
|
allow(instance).to receive(:validate!)
|
38
|
-
instance.config[:format] =
|
39
|
+
instance.config[:format] = "summary"
|
39
40
|
end
|
40
41
|
|
41
|
-
it
|
42
|
-
expect(instance.ui).to receive(:list).with([
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
it "lists formatted list of resources" do
|
43
|
+
expect(instance.ui).to receive(:list).with(["Name", "Instance ID", "Addresses", "Flavor", "Image", "Keypair", "State", "Availability Zone",
|
44
|
+
"ubuntu01", "resource-1", "public:IPv4: 172.31.6.132", "1", "image1", "keypair", "ACTIVE", "test zone",
|
45
|
+
"windows2008", "resource-2", "public:IPv4: 172.31.6.132", "id2", "image2", "keypair", "ACTIVE", "test zone",
|
46
|
+
"windows2008", "resource-3-err", "", "id2", "image2", "keypair", "ERROR", "test zone"], :uneven_columns_across, 8)
|
46
47
|
instance.run
|
47
48
|
end
|
48
49
|
|
49
|
-
context
|
50
|
+
context "when chef-data and chef-node-attribute set" do
|
50
51
|
before(:each) do
|
51
|
-
@resources.push(TestResource.new(id:
|
52
|
-
@node = TestResource.new(id:
|
53
|
-
allow(Chef::Node).to receive(:list).and_return(
|
52
|
+
@resources.push(TestResource.new(id: "server-4", name: "server-4", availability_zone: "test zone", addresses: { "public" => [{ "version" => 4, "addr" => "172.31.6.132" }], "private" => [{ "version" => 4, "addr" => "172.31.6.133" }] }, flavor: { "id" => "1" }, image: { "id" => "image1" }, key_name: "keypair", state: "ACTIVE"))
|
53
|
+
@node = TestResource.new(id: "server-4", name: "server-4", chef_environment: "_default", fqdn: "testfqdnnode.us", run_list: [], tags: [], platform: "ubuntu", platform_family: "debian")
|
54
|
+
allow(Chef::Node).to receive(:list).and_return("server-4" => @node)
|
54
55
|
instance.config[:chef_data] = true
|
55
56
|
end
|
56
57
|
|
57
|
-
it
|
58
|
-
expect(instance.ui).to receive(:list).with([
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
it "lists formatted list of resources on chef data option set" do
|
59
|
+
expect(instance.ui).to receive(:list).with(["Name", "Instance ID", "Addresses", "Flavor", "Image", "Keypair", "State", "Availability Zone", "Chef Node Name", "Environment", "FQDN", "Runlist", "Tags", "Platform",
|
60
|
+
"server-4", "server-4", "public:IPv4: 172.31.6.132", "1", "image1", "keypair", "ACTIVE", "test zone", "server-4", "_default", "testfqdnnode.us", "[]", "[]", "ubuntu",
|
61
|
+
"ubuntu01", "resource-1", "public:IPv4: 172.31.6.132", "1", "image1", "keypair", "ACTIVE", "test zone", "", "", "", "", "", "",
|
62
|
+
"windows2008", "resource-2", "public:IPv4: 172.31.6.132", "id2", "image2", "keypair", "ACTIVE", "test zone", "", "", "", "", "", "",
|
63
|
+
"windows2008", "resource-3-err", "", "id2", "image2", "keypair", "ERROR", "test zone", "", "", "", "", "", ""], :uneven_columns_across, 14)
|
63
64
|
instance.run
|
64
65
|
end
|
65
66
|
|
66
|
-
it
|
67
|
-
instance.config[:chef_node_attribute] =
|
68
|
-
expect(@node).to receive(:attribute?).with(
|
69
|
-
expect(instance.ui).to receive(:list).with([
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
67
|
+
it "lists formatted list of resources on chef-data and chef-node-attribute option set" do
|
68
|
+
instance.config[:chef_node_attribute] = "platform_family"
|
69
|
+
expect(@node).to receive(:attribute?).with("platform_family").and_return(true)
|
70
|
+
expect(instance.ui).to receive(:list).with(["Name", "Instance ID", "Addresses", "Flavor", "Image", "Keypair", "State", "Availability Zone", "Chef Node Name", "Environment", "FQDN", "Runlist", "Tags", "Platform", "platform_family",
|
71
|
+
"server-4", "server-4", "public:IPv4: 172.31.6.132", "1", "image1", "keypair", "ACTIVE", "test zone", "server-4", "_default", "testfqdnnode.us", "[]", "[]", "ubuntu", "debian",
|
72
|
+
"ubuntu01", "resource-1", "public:IPv4: 172.31.6.132", "1", "image1", "keypair", "ACTIVE", "test zone", "", "", "", "", "", "", "",
|
73
|
+
"windows2008", "resource-2", "public:IPv4: 172.31.6.132", "id2", "image2", "keypair", "ACTIVE", "test zone", "", "", "", "", "", "", "",
|
74
|
+
"windows2008", "resource-3-err", "", "id2", "image2", "keypair", "ERROR", "test zone", "", "", "", "", "", "", ""], :uneven_columns_across, 15)
|
74
75
|
instance.run
|
75
76
|
end
|
76
77
|
|
77
|
-
it
|
78
|
-
instance.config[:chef_node_attribute] =
|
78
|
+
it "raise error on invalid chef-node-attribute set" do
|
79
|
+
instance.config[:chef_node_attribute] = "invalid_attribute"
|
79
80
|
expect(instance.ui).to receive(:fatal)
|
80
|
-
expect(@node).to receive(:attribute?).with(
|
81
|
-
expect(instance.ui).to receive(:error).with(
|
81
|
+
expect(@node).to receive(:attribute?).with("invalid_attribute").and_return(false)
|
82
|
+
expect(instance.ui).to receive(:error).with("The Node does not have a invalid_attribute attribute.")
|
82
83
|
expect { instance.run }.to raise_error
|
83
84
|
end
|
84
85
|
|
85
|
-
it
|
86
|
+
it "not display chef-data on chef-node-attribute set but chef-data option missing" do
|
86
87
|
instance.config[:chef_data] = false
|
87
|
-
instance.config[:chef_node_attribute] =
|
88
|
-
expect(instance.ui).to receive(:list).with([
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
88
|
+
instance.config[:chef_node_attribute] = "platform_family"
|
89
|
+
expect(instance.ui).to receive(:list).with(["Name", "Instance ID", "Addresses", "Flavor", "Image", "Keypair", "State", "Availability Zone",
|
90
|
+
"server-4", "server-4", "public:IPv4: 172.31.6.132", "1", "image1", "keypair", "ACTIVE", "test zone",
|
91
|
+
"ubuntu01", "resource-1", "public:IPv4: 172.31.6.132", "1", "image1", "keypair", "ACTIVE", "test zone",
|
92
|
+
"windows2008", "resource-2", "public:IPv4: 172.31.6.132", "id2", "image2", "keypair", "ACTIVE", "test zone",
|
93
|
+
"windows2008", "resource-3-err", "", "id2", "image2", "keypair", "ERROR", "test zone"], :uneven_columns_across, 8)
|
93
94
|
instance.run
|
94
95
|
end
|
95
96
|
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) 2013-2014 Chef Software, Inc.
|
@@ -15,15 +16,15 @@
|
|
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
|
19
|
+
require "spec_helper"
|
20
|
+
require "chef/knife/openstack_server_show"
|
21
|
+
require "chef/knife/cloud/openstack_service"
|
21
22
|
|
22
23
|
describe Chef::Knife::Cloud::OpenstackServerShow do
|
23
|
-
context
|
24
|
+
context "functionality" do
|
24
25
|
before do
|
25
26
|
@instance = Chef::Knife::Cloud::OpenstackServerShow.new
|
26
|
-
Chef::Config[:knife][:instance_id] =
|
27
|
+
Chef::Config[:knife][:instance_id] = "instance_id"
|
27
28
|
@openstack_service = Chef::Knife::Cloud::OpenstackService.new
|
28
29
|
allow(@openstack_service).to receive(:msg_pair)
|
29
30
|
allow(@openstack_service).to receive(:print)
|
@@ -38,7 +39,7 @@ describe Chef::Knife::Cloud::OpenstackServerShow do
|
|
38
39
|
expect(@openstack_service).to receive(:server_summary)
|
39
40
|
end
|
40
41
|
|
41
|
-
it
|
42
|
+
it "runs server show successfully" do
|
42
43
|
@instance.run
|
43
44
|
end
|
44
45
|
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,18 +17,18 @@
|
|
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_volume_list"
|
22
|
+
require "chef/knife/cloud/openstack_service"
|
23
|
+
require "support/shared_examples_for_command"
|
23
24
|
|
24
25
|
describe Chef::Knife::Cloud::OpenstackVolumeList do
|
25
26
|
let (:instance) { Chef::Knife::Cloud::OpenstackVolumeList.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: "volume-1", name: "big-disk-volume", status: "available", size: 1024, description: "This is the big disk"),
|
31
|
+
TestResource.new(id: "volume-2", name: "little-disk-volume", status: "in-use", size: 8, description: "This is the little disk"),
|
31
32
|
]
|
32
33
|
allow(instance).to receive(:query_resource).and_return(resources)
|
33
34
|
allow(instance).to receive(:puts)
|
@@ -35,10 +36,10 @@ describe Chef::Knife::Cloud::OpenstackVolumeList do
|
|
35
36
|
allow(instance).to receive(:validate!)
|
36
37
|
end
|
37
38
|
|
38
|
-
it
|
39
|
-
expect(instance.ui).to receive(:list).with([
|
40
|
-
|
41
|
-
|
39
|
+
it "lists formatted list of resources" do
|
40
|
+
expect(instance.ui).to receive(:list).with(["Name", "ID", "Status", "Size", "Description",
|
41
|
+
"big-disk-volume", "volume-1", "available", "1024 GB", "This is the big disk",
|
42
|
+
"little-disk-volume", "volume-2", "in-use", "8 GB", "This is the little disk"], :uneven_columns_across, 5)
|
42
43
|
instance.run
|
43
44
|
end
|
44
45
|
end
|
data/spec/integration/cleanup.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Copyright: Copyright (c) 2013-2014 Chef Software, Inc.
|
2
3
|
# License: Apache License, Version 2.0
|
3
4
|
#
|
@@ -15,19 +16,19 @@
|
|
15
16
|
|
16
17
|
# Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
|
17
18
|
|
18
|
-
require
|
19
|
+
require "mixlib/shellout"
|
19
20
|
|
20
21
|
module CleanupTestResources
|
21
22
|
def self.validate_params
|
22
23
|
unset_env_var = []
|
23
24
|
|
24
25
|
# OPENSTACK_USERNAME, OPENSTACK_PASSWORD and OPENSTACK_AUTH_URL are mandatory params to run knife openstack commands.
|
25
|
-
%w
|
26
|
+
%w{OPENSTACK_USERNAME OPENSTACK_PASSWORD OPENSTACK_AUTH_URL}.each do |os_env_var|
|
26
27
|
unset_env_var << os_env_var if ENV[os_env_var].nil?
|
27
28
|
end
|
28
29
|
|
29
30
|
err_msg = "\nPlease set #{unset_env_var.join(', ')} environment"
|
30
|
-
err_msg = err_msg + (unset_env_var.length > 1 ?
|
31
|
+
err_msg = err_msg + (unset_env_var.length > 1 ? " variables " : " variable ") + "to cleanup test resources."
|
31
32
|
unless unset_env_var.empty?
|
32
33
|
puts err_msg
|
33
34
|
exit 1
|
@@ -63,9 +64,9 @@ module CleanupTestResources
|
|
63
64
|
|
64
65
|
# We use "os-integration-test-<platform>-<randomNumber>" pattern for server name during integration tests run. So use "os-integration-test-" pattern to find out servers created during integration tests run.
|
65
66
|
servers.each_line do |line|
|
66
|
-
if line.include?(
|
67
|
+
if line.include?("os-integration-test-") || (line.include?("openstack-") && line.include?("opscode-ci-ssh"))
|
67
68
|
# Extract and add instance id of server to delete_resources list.
|
68
|
-
delete_resources << {
|
69
|
+
delete_resources << { "id" => line.split(" ").first, "name" => line.split(" ")[1] }
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
|
2
3
|
# License: Apache License, Version 2.0
|
3
4
|
#
|
@@ -17,7 +18,7 @@
|
|
17
18
|
# Author:: Ameya Varade (<ameya.varade@clogeny.com>)
|
18
19
|
# Author:: Prabhu Das (<prabhu.das@clogeny.com>)
|
19
20
|
|
20
|
-
require File.expand_path(File.dirname(__FILE__) +
|
21
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
21
22
|
|
22
23
|
def append_openstack_creds(is_list_cmd = false)
|
23
24
|
openstack_creds_cmd = " --openstack-username '#{ENV['OPENSTACK_USERNAME']}' --openstack-password '#{ENV['OPENSTACK_PASSWORD']}' --openstack-api-endpoint #{ENV['OPENSTACK_AUTH_URL']}"
|
@@ -54,7 +55,7 @@ end
|
|
54
55
|
|
55
56
|
# get openstack active instance_id for knife openstack show command run
|
56
57
|
def get_active_instance_id
|
57
|
-
server_list_output = run(
|
58
|
+
server_list_output = run("knife openstack server list " + append_openstack_creds(is_list_cmd = true))
|
58
59
|
# Check command exitstatus. Non zero exitstatus indicates command execution fails.
|
59
60
|
if server_list_output.exitstatus != 0
|
60
61
|
puts "Please check Openstack user name, password and auth url are correct. Error: #{list_output.stderr}."
|
@@ -64,20 +65,20 @@ def get_active_instance_id
|
|
64
65
|
end
|
65
66
|
|
66
67
|
servers.each_line do |line|
|
67
|
-
if line.include?(
|
68
|
-
instance_id = line.split(
|
68
|
+
if line.include?("ACTIVE")
|
69
|
+
instance_id = line.split(" ").first
|
69
70
|
return instance_id
|
70
71
|
end
|
71
72
|
end
|
72
73
|
false
|
73
74
|
end
|
74
75
|
|
75
|
-
describe
|
76
|
+
describe "knife-openstack integration test", if: is_config_present do
|
76
77
|
include KnifeTestBed
|
77
78
|
include RSpec::KnifeTestUtils
|
78
79
|
|
79
80
|
before(:all) do
|
80
|
-
expect(run(
|
81
|
+
expect(run("gem build knife-openstack.gemspec").exitstatus).to be(0)
|
81
82
|
expect(run("gem install #{get_gem_file_name}").exitstatus).to be(0)
|
82
83
|
init_openstack_test
|
83
84
|
end
|
@@ -87,350 +88,350 @@ describe 'knife-openstack integration test', if: is_config_present do
|
|
87
88
|
cleanup_test_data
|
88
89
|
end
|
89
90
|
|
90
|
-
describe
|
91
|
-
%w
|
91
|
+
describe "display help for command" do
|
92
|
+
%w{flavor\ list server\ create server\ delete server\ list group\ list image\ list network\ list }.each do |command|
|
92
93
|
context "when --help option used with #{command} command" do
|
93
94
|
let(:command) { "knife openstack #{command} --help" }
|
94
|
-
run_cmd_check_stdout(
|
95
|
+
run_cmd_check_stdout("--help")
|
95
96
|
end
|
96
97
|
end
|
97
98
|
end
|
98
99
|
|
99
|
-
describe
|
100
|
-
context
|
101
|
-
let(:command) {
|
102
|
-
run_cmd_check_status_and_output(
|
100
|
+
describe "display server list" do
|
101
|
+
context "when standard options specified" do
|
102
|
+
let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) }
|
103
|
+
run_cmd_check_status_and_output("succeed", "Instance ID")
|
103
104
|
end
|
104
105
|
|
105
|
-
context
|
106
|
-
let(:command) {
|
107
|
-
it { skip(
|
106
|
+
context "when --chef-data CLI option specified" do
|
107
|
+
let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) + " --chef-data" }
|
108
|
+
it { skip("setup a chef-zero on workspace node") }
|
108
109
|
end
|
109
110
|
|
110
|
-
context
|
111
|
-
let(:command) {
|
112
|
-
it { skip(
|
111
|
+
context "when --chef-data and valid --chef-node-attribute CLI option specified" do
|
112
|
+
let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute platform_family" }
|
113
|
+
it { skip("setup a chef-zero on workspace node") }
|
113
114
|
end
|
114
115
|
|
115
|
-
context
|
116
|
-
let(:command) {
|
117
|
-
it { skip(
|
116
|
+
context "when --chef-data and In valid --chef-node-attribute CLI option specified" do
|
117
|
+
let(:command) { "knife openstack server list" + append_openstack_creds(is_list_cmd = true) + " --chef-data --chef-node-attribute invalid" }
|
118
|
+
it { skip("setup a chef-zero on workspace node") }
|
118
119
|
end
|
119
120
|
end
|
120
121
|
|
121
|
-
describe
|
122
|
-
context
|
123
|
-
let(:command) {
|
124
|
-
run_cmd_check_status_and_output(
|
122
|
+
describe "display flavor list" do
|
123
|
+
context "when standard options specified" do
|
124
|
+
let(:command) { "knife openstack flavor list" + append_openstack_creds(is_list_cmd = true) }
|
125
|
+
run_cmd_check_status_and_output("succeed", "ID")
|
125
126
|
end
|
126
127
|
end
|
127
128
|
|
128
|
-
describe
|
129
|
-
context
|
130
|
-
let(:command) {
|
131
|
-
run_cmd_check_status_and_output(
|
129
|
+
describe "display image list" do
|
130
|
+
context "when standard options specified" do
|
131
|
+
let(:command) { "knife openstack image list" + append_openstack_creds(is_list_cmd = true) }
|
132
|
+
run_cmd_check_status_and_output("succeed", "ID")
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
135
|
-
describe
|
136
|
-
context
|
137
|
-
let(:command) {
|
138
|
-
run_cmd_check_status_and_output(
|
136
|
+
describe "display group list" do
|
137
|
+
context "when standard options specified" do
|
138
|
+
let(:command) { "knife openstack group list" + append_openstack_creds(is_list_cmd = true) }
|
139
|
+
run_cmd_check_status_and_output("succeed", "Name")
|
139
140
|
end
|
140
141
|
end
|
141
142
|
|
142
|
-
describe
|
143
|
-
context
|
144
|
-
let(:command) {
|
145
|
-
it { skip
|
143
|
+
describe "display network list" do
|
144
|
+
context "when standard options specified" do
|
145
|
+
let(:command) { "knife openstack network list" + append_openstack_creds(is_list_cmd = true) }
|
146
|
+
it { skip "Chef openstack setup not support this functionality" }
|
146
147
|
end
|
147
148
|
end
|
148
149
|
|
149
|
-
describe
|
150
|
-
context
|
150
|
+
describe "server show" do
|
151
|
+
context "with valid instance_id" do
|
151
152
|
before(:each) do
|
152
153
|
@instance_id = get_active_instance_id
|
153
154
|
end
|
154
155
|
let(:command) { "knife openstack server show #{@instance_id}" + append_openstack_creds(is_list_cmd = true) }
|
155
|
-
run_cmd_check_status_and_output(
|
156
|
+
run_cmd_check_status_and_output("succeed", "Instance ID")
|
156
157
|
end
|
157
158
|
|
158
|
-
context
|
159
|
-
let(:command) {
|
159
|
+
context "with invalid instance_id" do
|
160
|
+
let(:command) { "knife openstack server show invalid_instance_id" + append_openstack_creds(is_list_cmd = true) }
|
160
161
|
|
161
|
-
run_cmd_check_status_and_output(
|
162
|
+
run_cmd_check_status_and_output("fail", "ERROR: Server doesn't exists for this invalid_instance_id instance id")
|
162
163
|
end
|
163
164
|
end
|
164
165
|
|
165
|
-
describe
|
166
|
+
describe "create and bootstrap Linux Server" do
|
166
167
|
before(:each) { rm_known_host }
|
167
|
-
context
|
168
|
-
cmd_out =
|
168
|
+
context "when standard options specified" do
|
169
|
+
cmd_out = ""
|
169
170
|
|
170
|
-
before(:each) { create_node_name(
|
171
|
+
before(:each) { create_node_name("linux") }
|
171
172
|
|
172
173
|
after { cmd_out = "#{cmd_output}" }
|
173
174
|
|
174
|
-
let(:command)
|
175
|
+
let(:command) do
|
175
176
|
"knife openstack server create -N #{@name_node}"\
|
176
177
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
177
|
-
|
178
|
-
|
179
|
-
|
178
|
+
" --template-file " + get_linux_template_file_path +
|
179
|
+
" --server-url http://localhost:8889" \
|
180
|
+
" --yes --server-create-timeout 1800" +
|
180
181
|
get_ssh_credentials +
|
181
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
182
|
-
|
182
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
183
|
+
end
|
183
184
|
|
184
|
-
run_cmd_check_status_and_output(
|
185
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
185
186
|
|
186
|
-
context
|
187
|
+
context "delete server after create" do
|
187
188
|
let(:command) { delete_instance_cmd(cmd_out) }
|
188
|
-
run_cmd_check_status_and_output(
|
189
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
189
190
|
end
|
190
191
|
end
|
191
192
|
|
192
|
-
context
|
193
|
-
let(:command)
|
194
|
-
|
193
|
+
context "when standard options and chef node name prefix is default value(i.e openstack)" do
|
194
|
+
let(:command) do
|
195
|
+
"knife openstack server create "\
|
195
196
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
196
|
-
|
197
|
-
|
198
|
-
|
197
|
+
" --template-file " + get_linux_template_file_path +
|
198
|
+
" --server-url http://localhost:8889" \
|
199
|
+
" --yes --server-create-timeout 1800" +
|
199
200
|
get_ssh_credentials +
|
200
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
201
|
-
|
201
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
202
|
+
end
|
202
203
|
|
203
204
|
after { run(delete_instance_cmd("#{cmd_output}")) }
|
204
205
|
|
205
|
-
run_cmd_check_status_and_output(
|
206
|
+
run_cmd_check_status_and_output("succeed", "Bootstrapping Chef on")
|
206
207
|
end
|
207
208
|
|
208
|
-
context
|
209
|
-
let(:command)
|
210
|
-
|
209
|
+
context "when standard options and chef node name prefix is user specified value" do
|
210
|
+
let(:command) do
|
211
|
+
"knife openstack server create "\
|
211
212
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
213
|
+
" --template-file " + get_linux_template_file_path +
|
214
|
+
" --server-url http://localhost:8889" \
|
215
|
+
" --yes --server-create-timeout 1800" \
|
216
|
+
" --chef-node-name-prefix os-integration-test-" +
|
216
217
|
get_ssh_credentials +
|
217
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
218
|
-
|
218
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
219
|
+
end
|
219
220
|
|
220
221
|
after { run(delete_instance_cmd("#{cmd_output}")) }
|
221
222
|
|
222
|
-
run_cmd_check_status_and_output(
|
223
|
+
run_cmd_check_status_and_output("succeed", "os-integration-test-")
|
223
224
|
end
|
224
225
|
|
225
|
-
context
|
226
|
-
nodename =
|
227
|
-
before(:each) { create_node_name(
|
226
|
+
context "when standard options and delete-server-on-failure specified" do
|
227
|
+
nodename = ""
|
228
|
+
before(:each) { create_node_name("linux") }
|
228
229
|
|
229
230
|
after { nodename = @name_node }
|
230
231
|
|
231
|
-
let(:command)
|
232
|
+
let(:command) do
|
232
233
|
"knife openstack server create -N #{@name_node}"\
|
233
234
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
235
|
+
" --template-file " + get_linux_template_file_path +
|
236
|
+
" --server-url http://localhost:8889" \
|
237
|
+
" --yes --server-create-timeout 1800" \
|
238
|
+
" --delete-server-on-failure" +
|
238
239
|
get_ssh_credentials +
|
239
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
240
|
-
|
240
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
241
|
+
end
|
241
242
|
|
242
|
-
run_cmd_check_status_and_output(
|
243
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
243
244
|
|
244
|
-
context
|
245
|
-
let(:command) { "knife openstack server delete #{nodename} " + append_openstack_creds(is_list_cmd = true) +
|
246
|
-
run_cmd_check_status_and_output(
|
245
|
+
context "delete server by using name after create" do
|
246
|
+
let(:command) { "knife openstack server delete #{nodename} " + append_openstack_creds(is_list_cmd = true) + " --yes" }
|
247
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
247
248
|
end
|
248
249
|
end
|
249
250
|
|
250
|
-
context
|
251
|
-
before(:each) { create_node_name(
|
251
|
+
context "when delete-server-on-failure specified and bootstrap fails" do
|
252
|
+
before(:each) { create_node_name("linux") }
|
252
253
|
|
253
|
-
let(:command)
|
254
|
+
let(:command) do
|
254
255
|
"knife openstack server create -N #{@name_node}"\
|
255
256
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
257
|
+
" --template-file " + get_linux_template_file_path +
|
258
|
+
" --server-url http://localhost:8889" \
|
259
|
+
" --yes --server-create-timeout 1800" \
|
260
|
+
" --delete-server-on-failure" +
|
260
261
|
get_ssh_credentials +
|
261
|
-
" --identity-file #{temp_dir}/incorrect_openstack.pem" + append_openstack_creds +
|
262
|
-
|
262
|
+
" --identity-file #{temp_dir}/incorrect_openstack.pem" + append_openstack_creds + " --sudo"
|
263
|
+
end
|
263
264
|
|
264
|
-
run_cmd_check_status_and_output(
|
265
|
+
run_cmd_check_status_and_output("fail", "FATAL: Authentication Failed during bootstrapping")
|
265
266
|
end
|
266
267
|
|
267
|
-
context
|
268
|
-
before(:each) { create_node_name(
|
268
|
+
context "when openstack credentials not specified" do
|
269
|
+
before(:each) { create_node_name("linux") }
|
269
270
|
|
270
|
-
let(:command)
|
271
|
+
let(:command) do
|
271
272
|
"knife openstack server create -N #{@name_node}"\
|
272
273
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
273
|
-
|
274
|
-
|
275
|
-
|
274
|
+
" --template-file " + get_linux_template_file_path +
|
275
|
+
" --server-url http://localhost:8889" \
|
276
|
+
" --yes --server-create-timeout 1800" +
|
276
277
|
get_ssh_credentials +
|
277
278
|
" --identity-file #{temp_dir}/openstack.pem --sudo"
|
278
|
-
|
279
|
+
end
|
279
280
|
|
280
|
-
run_cmd_check_status_and_output(
|
281
|
+
run_cmd_check_status_and_output("fail", "ERROR: You did not provide a valid 'Openstack Username' value")
|
281
282
|
end
|
282
283
|
|
283
|
-
context
|
284
|
-
before(:each) { create_node_name(
|
284
|
+
context "when ssh-password and identity-file parameters not specified" do
|
285
|
+
before(:each) { create_node_name("linux") }
|
285
286
|
|
286
|
-
let(:command)
|
287
|
+
let(:command) do
|
287
288
|
"knife openstack server create -N #{@name_node}"\
|
288
289
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
append_openstack_creds +
|
293
|
-
|
290
|
+
" --template-file " + get_linux_template_file_path +
|
291
|
+
" --server-url http://localhost:8889" \
|
292
|
+
" --yes" +
|
293
|
+
append_openstack_creds + " --sudo"
|
294
|
+
end
|
294
295
|
|
295
|
-
it { skip
|
296
|
+
it { skip "Chef openstack setup not support this functionality." }
|
296
297
|
end
|
297
298
|
|
298
|
-
context
|
299
|
-
before(:each) { create_node_name(
|
299
|
+
context "when standard options and invalid openstack security group specified" do
|
300
|
+
before(:each) { create_node_name("linux") }
|
300
301
|
|
301
|
-
let(:command)
|
302
|
+
let(:command) do
|
302
303
|
"knife openstack server create -N #{@name_node}"\
|
303
304
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
304
|
-
|
305
|
-
|
306
|
-
|
305
|
+
" --template-file " + get_linux_template_file_path +
|
306
|
+
" --server-url http://localhost:8889" \
|
307
|
+
" --yes" +
|
307
308
|
get_ssh_credentials +
|
308
309
|
" --identity-file #{temp_dir}/openstack.pem"\
|
309
|
-
|
310
|
-
|
310
|
+
" --openstack-groups invalid-invalid-1212" + append_openstack_creds + " --sudo"
|
311
|
+
end
|
311
312
|
|
312
|
-
run_cmd_check_status_and_output(
|
313
|
+
run_cmd_check_status_and_output("fail", "Security group invalid-invalid-1212 not found")
|
313
314
|
end
|
314
315
|
|
315
|
-
context
|
316
|
-
before(:each) { create_node_name(
|
316
|
+
context "when standard options and invalid image id specified" do
|
317
|
+
before(:each) { create_node_name("linux") }
|
317
318
|
|
318
|
-
let(:command)
|
319
|
+
let(:command) do
|
319
320
|
"knife openstack server create -N #{@name_node}"\
|
320
321
|
" -I #{SecureRandom.hex(18)} -f #{@os_linux_flavor} "\
|
321
|
-
|
322
|
-
|
323
|
-
|
322
|
+
" --template-file " + get_linux_template_file_path +
|
323
|
+
" --server-url http://localhost:8889" \
|
324
|
+
" --yes" +
|
324
325
|
get_ssh_credentials +
|
325
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
326
|
-
|
326
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
327
|
+
end
|
327
328
|
|
328
|
-
run_cmd_check_status_and_output(
|
329
|
+
run_cmd_check_status_and_output("fail", "ERROR: You have not provided a valid image ID. Please note the options for this value are -I or --image")
|
329
330
|
end
|
330
331
|
|
331
|
-
context
|
332
|
-
before(:each) { create_node_name(
|
332
|
+
context "when standard options and invalid flavor id specified" do
|
333
|
+
before(:each) { create_node_name("linux") }
|
333
334
|
|
334
|
-
let(:command)
|
335
|
+
let(:command) do
|
335
336
|
"knife openstack server create -N #{@name_node}"\
|
336
337
|
" -I #{@os_linux_image} -f #{@os_invalid_flavor} "\
|
337
|
-
|
338
|
-
|
339
|
-
|
338
|
+
" --template-file " + get_linux_template_file_path +
|
339
|
+
" --server-url http://localhost:8889" \
|
340
|
+
" --yes" +
|
340
341
|
get_ssh_credentials +
|
341
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
342
|
-
|
342
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
343
|
+
end
|
343
344
|
|
344
|
-
run_cmd_check_status_and_output(
|
345
|
+
run_cmd_check_status_and_output("fail", "ERROR: You have not provided a valid flavor ID. Please note the options for this value are -f or --flavor")
|
345
346
|
end
|
346
347
|
|
347
|
-
context
|
348
|
-
before(:each) { create_node_name(
|
348
|
+
context "when standard options and invalid floating ip specified" do
|
349
|
+
before(:each) { create_node_name("linux") }
|
349
350
|
|
350
|
-
let(:command)
|
351
|
+
let(:command) do
|
351
352
|
"knife openstack server create -N #{@name_node}"\
|
352
353
|
" -I #{@os_linux_image} --openstack-floating-ip #{@os_invalid_floating_ip} "\
|
353
|
-
|
354
|
-
|
355
|
-
|
354
|
+
" --template-file " + get_linux_template_file_path +
|
355
|
+
" --server-url http://localhost:8889" \
|
356
|
+
" --yes" +
|
356
357
|
get_ssh_credentials +
|
357
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
358
|
-
|
358
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
359
|
+
end
|
359
360
|
|
360
|
-
run_cmd_check_status_and_output(
|
361
|
+
run_cmd_check_status_and_output("fail", "ERROR: You have either requested an invalid floating IP address or none are available")
|
361
362
|
end
|
362
363
|
|
363
|
-
context
|
364
|
-
before(:each) { create_node_name(
|
364
|
+
context "when invalid key_pair specified" do
|
365
|
+
before(:each) { create_node_name("linux") }
|
365
366
|
|
366
|
-
let(:command)
|
367
|
+
let(:command) do
|
367
368
|
"knife openstack server create -N #{@name_node}"\
|
368
369
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
369
|
-
|
370
|
-
|
371
|
-
|
370
|
+
" --template-file " + get_linux_template_file_path +
|
371
|
+
" --server-url http://localhost:8889" \
|
372
|
+
" --yes" \
|
372
373
|
" --ssh-user #{@os_ssh_user}"\
|
373
374
|
" --openstack-ssh-key-id #{SecureRandom.hex(6)}"\
|
374
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
375
|
-
|
375
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
376
|
+
end
|
376
377
|
|
377
|
-
run_cmd_check_status_and_output(
|
378
|
+
run_cmd_check_status_and_output("fail", "Invalid key_name provided")
|
378
379
|
end
|
379
380
|
|
380
|
-
context
|
381
|
+
context "when incorrect openstack private_key.pem file is used" do
|
381
382
|
server_create_common_bfr_aftr
|
382
383
|
|
383
|
-
let(:command)
|
384
|
+
let(:command) do
|
384
385
|
"knife openstack server create -N #{@name_node}"\
|
385
386
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
386
|
-
|
387
|
-
|
388
|
-
|
387
|
+
" --template-file " + get_linux_template_file_path +
|
388
|
+
" --server-url http://localhost:8889" \
|
389
|
+
" --yes" \
|
389
390
|
" --ssh-user #{@os_ssh_user}"\
|
390
391
|
" --openstack-ssh-key-id #{@openstack_key_pair}"\
|
391
|
-
" --identity-file #{temp_dir}/incorrect_openstack.pem" + append_openstack_creds +
|
392
|
-
|
392
|
+
" --identity-file #{temp_dir}/incorrect_openstack.pem" + append_openstack_creds + " --sudo"
|
393
|
+
end
|
393
394
|
|
394
|
-
run_cmd_check_status_and_output(
|
395
|
+
run_cmd_check_status_and_output("fail", "FATAL: Authentication Failed during bootstrapping")
|
395
396
|
end
|
396
397
|
|
397
|
-
context
|
398
|
+
context "when standard options and --openstack-private-network option specified" do
|
398
399
|
server_create_common_bfr_aftr
|
399
400
|
|
400
|
-
let(:command)
|
401
|
+
let(:command) do
|
401
402
|
"knife openstack server create -N #{@name_node}"\
|
402
403
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
403
|
-
|
404
|
-
|
405
|
-
|
404
|
+
" --template-file " + get_linux_template_file_path +
|
405
|
+
" --server-url http://localhost:8889" \
|
406
|
+
" --yes" +
|
406
407
|
get_ssh_credentials +
|
407
408
|
" --identity-file #{temp_dir}/openstack.pem"\
|
408
|
-
|
409
|
-
|
409
|
+
" --openstack-private-network" + append_openstack_creds + " --sudo"
|
410
|
+
end
|
410
411
|
|
411
|
-
it { skip
|
412
|
+
it { skip "not yet supported" }
|
412
413
|
end
|
413
414
|
|
414
|
-
context
|
415
|
+
context "when standard options and --openstack-floating-ip option specified" do
|
415
416
|
server_create_common_bfr_aftr
|
416
417
|
|
417
|
-
let(:command)
|
418
|
+
let(:command) do
|
418
419
|
"knife openstack server create -N #{@name_node}"\
|
419
420
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
420
|
-
|
421
|
-
|
422
|
-
|
421
|
+
" --template-file " + get_linux_template_file_path +
|
422
|
+
" --server-url http://localhost:8889" \
|
423
|
+
" --yes" +
|
423
424
|
get_ssh_credentials +
|
424
425
|
" --identity-file #{temp_dir}/openstack.pem"\
|
425
|
-
|
426
|
-
|
426
|
+
" --openstack-floating-ip" + append_openstack_creds + " --sudo"
|
427
|
+
end
|
427
428
|
|
428
|
-
it { skip
|
429
|
+
it { skip "empty floating ip pool" }
|
429
430
|
end
|
430
431
|
|
431
|
-
context
|
432
|
+
context "when standard options and user data specified" do
|
432
433
|
before(:each) do
|
433
|
-
create_node_name(
|
434
|
+
create_node_name("linux")
|
434
435
|
@user_data_file = create_sh_user_data_file
|
435
436
|
end
|
436
437
|
|
@@ -441,208 +442,208 @@ describe 'knife-openstack integration test', if: is_config_present do
|
|
441
442
|
run(delete_instance_cmd("#{cmd_output}"))
|
442
443
|
end
|
443
444
|
|
444
|
-
let(:command)
|
445
|
+
let(:command) do
|
445
446
|
"knife openstack server create -N #{@name_node}"\
|
446
447
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
447
|
-
|
448
|
-
|
449
|
-
|
448
|
+
" --template-file " + get_linux_template_file_path +
|
449
|
+
" --server-url http://localhost:8889" \
|
450
|
+
" --yes --server-create-timeout 1800" +
|
450
451
|
get_ssh_credentials +
|
451
452
|
" --identity-file #{temp_dir}/openstack.pem" \
|
452
453
|
" --user-data #{@user_data_file.path}" +
|
453
|
-
append_openstack_creds +
|
454
|
-
|
454
|
+
append_openstack_creds + " --sudo -VV"
|
455
|
+
end
|
455
456
|
|
456
|
-
run_cmd_check_status_and_output(
|
457
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
457
458
|
end
|
458
459
|
|
459
|
-
context
|
460
|
+
context "when standard options and no network option specified" do
|
460
461
|
server_create_common_bfr_aftr
|
461
462
|
|
462
|
-
let(:command)
|
463
|
+
let(:command) do
|
463
464
|
"knife openstack server create -N #{@name_node}"\
|
464
465
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
466
|
+
" --template-file " + get_linux_template_file_path +
|
467
|
+
" --server-url http://localhost:8889" \
|
468
|
+
" --yes --server-create-timeout 1800" \
|
469
|
+
" --no-network" +
|
469
470
|
get_ssh_credentials +
|
470
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
471
|
-
|
471
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
472
|
+
end
|
472
473
|
|
473
|
-
run_cmd_check_status_and_output(
|
474
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
474
475
|
end
|
475
476
|
|
476
|
-
context
|
477
|
+
context "when standard options and openstack endpoint type option is specified" do
|
477
478
|
server_create_common_bfr_aftr
|
478
479
|
|
479
|
-
let(:command)
|
480
|
+
let(:command) do
|
480
481
|
"knife openstack server create -N #{@name_node}"\
|
481
482
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
483
|
+
" --template-file " + get_linux_template_file_path +
|
484
|
+
" --server-url http://localhost:8889" \
|
485
|
+
" --yes --server-create-timeout 1800" \
|
486
|
+
" --openstack-endpoint-type publicURL" +
|
486
487
|
get_ssh_credentials +
|
487
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
488
|
-
|
488
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
489
|
+
end
|
489
490
|
|
490
|
-
run_cmd_check_status_and_output(
|
491
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
491
492
|
end
|
492
493
|
|
493
|
-
context
|
494
|
+
context "when standard options and openstack metadata option is specified" do
|
494
495
|
server_create_common_bfr_aftr
|
495
496
|
|
496
|
-
let(:command)
|
497
|
+
let(:command) do
|
497
498
|
"knife openstack server create -N #{@name_node}"\
|
498
499
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
499
|
-
|
500
|
-
|
501
|
-
|
500
|
+
" --template-file " + get_linux_template_file_path +
|
501
|
+
" --server-url http://localhost:8889" \
|
502
|
+
" --yes --server-create-timeout 1800" \
|
502
503
|
" --metadata testdataone='testmetadata'" +
|
503
504
|
get_ssh_credentials +
|
504
505
|
" --identity-file #{temp_dir}/openstack.pem"\
|
505
506
|
" --metadata testdatatwo='testmetadata'" +
|
506
|
-
append_openstack_creds +
|
507
|
-
|
507
|
+
append_openstack_creds + " --sudo"
|
508
|
+
end
|
508
509
|
|
509
|
-
run_cmd_check_status_and_output(
|
510
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
510
511
|
end
|
511
512
|
|
512
|
-
context
|
513
|
+
context "when standard options and openstack network-ids option is specified" do
|
513
514
|
server_create_common_bfr_aftr
|
514
515
|
|
515
|
-
let(:command)
|
516
|
+
let(:command) do
|
516
517
|
"knife openstack server create -N #{@name_node}"\
|
517
518
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
518
|
-
|
519
|
-
|
520
|
-
|
519
|
+
" --template-file " + get_linux_template_file_path +
|
520
|
+
" --server-url http://localhost:8889" \
|
521
|
+
" --yes --server-create-timeout 1800" \
|
521
522
|
" --network-ids #{@os_network_ids} " +
|
522
523
|
get_ssh_credentials +
|
523
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
524
|
-
|
524
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
525
|
+
end
|
525
526
|
|
526
|
-
it { skip
|
527
|
+
it { skip "Chef openstack setup not support this functionality" }
|
527
528
|
end
|
528
529
|
|
529
|
-
context
|
530
|
+
context "when standard options and openstack availability-zone option is specified" do
|
530
531
|
server_create_common_bfr_aftr
|
531
532
|
|
532
|
-
let(:command)
|
533
|
+
let(:command) do
|
533
534
|
"knife openstack server create -N #{@name_node}"\
|
534
535
|
" -I #{@os_linux_image} -f #{@os_linux_flavor} "\
|
535
|
-
|
536
|
-
|
537
|
-
|
536
|
+
" --template-file " + get_linux_template_file_path +
|
537
|
+
" --server-url http://localhost:8889" \
|
538
|
+
" --yes --server-create-timeout 1800" \
|
538
539
|
" --availability-zone #{@os_availability_zone} " +
|
539
540
|
get_ssh_credentials +
|
540
|
-
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds +
|
541
|
-
|
541
|
+
" --identity-file #{temp_dir}/openstack.pem" + append_openstack_creds + " --sudo"
|
542
|
+
end
|
542
543
|
|
543
|
-
it { skip
|
544
|
+
it { skip "Chef openstack setup not support this functionality" }
|
544
545
|
end
|
545
546
|
end
|
546
547
|
|
547
|
-
describe
|
548
|
+
describe "create and bootstrap Windows Server" do
|
548
549
|
before(:each) { rm_known_host }
|
549
550
|
|
550
|
-
context
|
551
|
-
cmd_out =
|
551
|
+
context "when standard options specified" do
|
552
|
+
cmd_out = ""
|
552
553
|
|
553
|
-
before(:each) { create_node_name(
|
554
|
+
before(:each) { create_node_name("windows") }
|
554
555
|
|
555
|
-
let(:command)
|
556
|
+
let(:command) do
|
556
557
|
"knife openstack server create -N #{@name_node}" \
|
557
558
|
" -I #{@os_windows_image} " \
|
558
559
|
" -f #{@os_windows_flavor} " \
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
560
|
+
" --template-file " + get_windows_msi_template_file_path +
|
561
|
+
" --server-url http://localhost:8889" \
|
562
|
+
" --bootstrap-protocol winrm" \
|
563
|
+
" --yes --server-create-timeout 1800" +
|
563
564
|
get_winrm_credentials + append_openstack_creds_for_windows
|
564
|
-
|
565
|
+
end
|
565
566
|
|
566
567
|
after { cmd_out = "#{cmd_output}" }
|
567
568
|
|
568
|
-
run_cmd_check_status_and_output(
|
569
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
569
570
|
|
570
|
-
context
|
571
|
+
context "delete server after create" do
|
571
572
|
let(:command) { delete_instance_cmd(cmd_out) }
|
572
|
-
run_cmd_check_status_and_output(
|
573
|
+
run_cmd_check_status_and_output("succeed")
|
573
574
|
end
|
574
575
|
end
|
575
576
|
|
576
|
-
context
|
577
|
-
server_create_common_bfr_aftr(
|
577
|
+
context "when invalid winrm user specified" do
|
578
|
+
server_create_common_bfr_aftr("windows")
|
578
579
|
|
579
|
-
let(:command)
|
580
|
+
let(:command) do
|
580
581
|
"knife openstack server create -N #{@name_node}" \
|
581
582
|
" -I #{@os_windows_image} " \
|
582
583
|
" -f #{@os_windows_flavor} " \
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
584
|
+
" --template-file " + get_windows_msi_template_file_path +
|
585
|
+
" --server-url http://localhost:8889" \
|
586
|
+
" --bootstrap-protocol winrm" \
|
587
|
+
" --yes --server-create-timeout 1800" \
|
587
588
|
" --winrm-user #{SecureRandom.hex(6)}"\
|
588
589
|
" --winrm-password #{@os_winrm_password}" +
|
589
590
|
append_openstack_creds_for_windows
|
590
|
-
|
591
|
-
it { skip
|
591
|
+
end
|
592
|
+
it { skip "Fails due to OC-9708 bug in knife-windows." }
|
592
593
|
end
|
593
594
|
|
594
|
-
context
|
595
|
-
server_create_common_bfr_aftr(
|
595
|
+
context "when invalid winrm password specified" do
|
596
|
+
server_create_common_bfr_aftr("windows")
|
596
597
|
|
597
|
-
let(:command)
|
598
|
+
let(:command) do
|
598
599
|
"knife openstack server create -N #{@name_node}" \
|
599
600
|
" -I #{@os_windows_image} " \
|
600
601
|
" -f #{@os_windows_flavor} " \
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
602
|
+
" --template-file " + get_windows_msi_template_file_path +
|
603
|
+
" --server-url http://localhost:8889" \
|
604
|
+
" --bootstrap-protocol winrm" \
|
605
|
+
" --yes --server-create-timeout 1800" \
|
605
606
|
" --winrm-user #{@os_winrm_user}"\
|
606
607
|
" --winrm-password #{SecureRandom.hex(6)}" +
|
607
608
|
append_openstack_creds_for_windows
|
608
|
-
|
609
|
+
end
|
609
610
|
after(:each) { run(delete_instance_cmd("#{cmd_output}")) }
|
610
611
|
|
611
|
-
it { skip
|
612
|
+
it { skip "Fails due to OC-9708 bug in knife-windows." }
|
612
613
|
end
|
613
614
|
|
614
|
-
context
|
615
|
-
server_create_common_bfr_aftr(
|
615
|
+
context "when standard options ssh bootstrap and valid image-os-type protocol specified" do
|
616
|
+
server_create_common_bfr_aftr("windows")
|
616
617
|
|
617
|
-
let(:command)
|
618
|
+
let(:command) do
|
618
619
|
"knife openstack server create -N #{@name_node}"\
|
619
620
|
" -I #{@os_windows_ssh_image}"\
|
620
621
|
" -f #{@os_windows_flavor} "\
|
621
|
-
|
622
|
-
|
623
|
-
|
622
|
+
" --template-file " + get_windows_msi_template_file_path +
|
623
|
+
" --server-url http://localhost:8889" \
|
624
|
+
" --yes --server-create-timeout 1800" \
|
624
625
|
" --identity-file #{temp_dir}/openstack.pem"\
|
625
|
-
" --openstack-ssh-key-id #{@openstack_key_pair}" + get_ssh_credentials_for_windows_image + append_openstack_creds +
|
626
|
-
|
626
|
+
" --openstack-ssh-key-id #{@openstack_key_pair}" + get_ssh_credentials_for_windows_image + append_openstack_creds + " --image-os-type windows"
|
627
|
+
end
|
627
628
|
|
628
|
-
run_cmd_check_status_and_output(
|
629
|
+
run_cmd_check_status_and_output("succeed", "#{@name_node}")
|
629
630
|
end
|
630
631
|
|
631
|
-
context
|
632
|
-
before(:each) { create_node_name(
|
632
|
+
context "when standard options ssh bootstrap and invalid image-os-type protocol specified" do
|
633
|
+
before(:each) { create_node_name("windows") }
|
633
634
|
|
634
|
-
let(:command)
|
635
|
+
let(:command) do
|
635
636
|
"knife openstack server create -N #{@name_node}"\
|
636
637
|
" -I #{@os_windows_ssh_image}"\
|
637
638
|
" -f #{@os_windows_flavor} "\
|
638
|
-
|
639
|
-
|
640
|
-
|
639
|
+
" --template-file " + get_windows_msi_template_file_path +
|
640
|
+
" --server-url http://localhost:8889" \
|
641
|
+
" --yes --server-create-timeout 1800" \
|
641
642
|
" --identity-file #{temp_dir}/openstack.pem"\
|
642
|
-
" --openstack-ssh-key-id #{@openstack_key_pair}" + get_ssh_credentials_for_windows_image + append_openstack_creds +
|
643
|
-
|
643
|
+
" --openstack-ssh-key-id #{@openstack_key_pair}" + get_ssh_credentials_for_windows_image + append_openstack_creds + " --image-os-type invalid"
|
644
|
+
end
|
644
645
|
|
645
|
-
run_cmd_check_status_and_output(
|
646
|
+
run_cmd_check_status_and_output("fail", "ERROR: You must provide --image-os-type option [windows/linux]")
|
646
647
|
end
|
647
648
|
end
|
648
649
|
end
|