knife-openstack 1.3.2.pre → 1.3.2.pre.1

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