knife-vrealize 1.0.0.rc1

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.
@@ -0,0 +1,43 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+ require 'chef/knife/vra_catalog_list'
21
+ require 'support/shared_examples_for_command'
22
+
23
+ describe Chef::Knife::Cloud::VraCatalogList do
24
+ it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::VraCatalogList.new
25
+
26
+ subject { described_class.new }
27
+
28
+ describe '#format_status_value' do
29
+ context 'when the status is "published"' do
30
+ it 'displays with green' do
31
+ expect(subject.ui).to receive(:color).with('published', :green)
32
+ subject.format_status_value('published')
33
+ end
34
+ end
35
+
36
+ context 'when the status it not "published"' do
37
+ it 'displays with red' do
38
+ expect(subject.ui).to receive(:color).with('unpublished', :red)
39
+ subject.format_status_value('unpublished')
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,127 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+ require 'chef/knife/vra_server_create'
21
+ require 'support/shared_examples_for_command'
22
+ require 'support/shared_examples_for_servercreatecommand'
23
+
24
+ describe Chef::Knife::Cloud::VraServerCreate do
25
+ argv = []
26
+ argv += %w(--cpus 1)
27
+ argv += %w(--memory 512)
28
+ argv += %w(--requested-for myuser@corp.local)
29
+ argv += %w(--bootstrap-protocol ssh)
30
+ argv += %w(--ssh-password password)
31
+ argv += %w(--extra-param key1=string:value1)
32
+ argv += %w(--extra-param key2=integer:2)
33
+ argv += %w(d5ba201a-449f-47a4-9d02-39196224bf01)
34
+
35
+ subject { Chef::Knife::Cloud::VraServerCreate.new(argv) }
36
+
37
+ it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::VraServerCreate.new(argv)
38
+ it_behaves_like Chef::Knife::Cloud::ServerCreateCommand, Chef::Knife::Cloud::VraServerCreate.new(argv)
39
+
40
+ describe '#validate_params!' do
41
+ context 'when no catalog ID is supplied' do
42
+ it 'raises an error' do
43
+ argv = []
44
+ argv += %w(--cpus 1)
45
+ argv += %w(--memory 512)
46
+ argv += %w(--requested-for myuser@corp.local)
47
+ argv += %w(--bootstrap-protocol ssh)
48
+ argv += %w(--ssh-password password)
49
+
50
+ command = Chef::Knife::Cloud::VraServerCreate.new(argv)
51
+ expect(command.ui).to receive(:error)
52
+ expect { command.validate_params! }.to raise_error(SystemExit)
53
+ end
54
+ end
55
+
56
+ it 'validates extra parameters' do
57
+ expect(subject).to receive(:validate_extra_params!)
58
+ subject.validate_params!
59
+ end
60
+ end
61
+
62
+ describe '#extra_params' do
63
+ it 'parses extra parameters properly' do
64
+ params = subject.extra_params
65
+ expect(params[0][:key]).to eq 'key1'
66
+ expect(params[0][:type]).to eq 'string'
67
+ expect(params[0][:value]).to eq 'value1'
68
+ expect(params[1][:key]).to eq 'key2'
69
+ expect(params[1][:type]).to eq 'integer'
70
+ expect(params[1][:value]).to eq '2'
71
+ end
72
+ end
73
+
74
+ describe '#validate_extra_params!' do
75
+ context 'when no extra parameters are supplied' do
76
+ it 'does not raise an exception' do
77
+ argv = []
78
+ argv += %w(--cpus 1)
79
+ argv += %w(--memory 512)
80
+ argv += %w(--requested-for myuser@corp.local)
81
+ argv += %w(--bootstrap-protocol ssh)
82
+ argv += %w(--ssh-password password)
83
+ command = Chef::Knife::Cloud::VraServerCreate.new(argv)
84
+
85
+ expect { command.validate_extra_params! }.not_to raise_error
86
+ end
87
+ end
88
+
89
+ context 'when correct parameters are supplied' do
90
+ it 'does not raise an exception' do
91
+ expect { subject.validate_extra_params! }.not_to raise_error
92
+ end
93
+ end
94
+
95
+ context 'when a type or value is missing' do
96
+ it 'raises an exception' do
97
+ argv = []
98
+ argv += %w(--cpus 1)
99
+ argv += %w(--memory 512)
100
+ argv += %w(--requested-for myuser@corp.local)
101
+ argv += %w(--bootstrap-protocol ssh)
102
+ argv += %w(--ssh-password password)
103
+ argv += %w(d5ba201a-449f-47a4-9d02-39196224bf01)
104
+ argv += %w(--extra-param key1=value1)
105
+ command = Chef::Knife::Cloud::VraServerCreate.new(argv)
106
+
107
+ expect { command.validate_extra_params! }.to raise_error(ArgumentError)
108
+ end
109
+ end
110
+
111
+ context 'when an invalid parameter type is provided' do
112
+ it 'raises an exception' do
113
+ argv = []
114
+ argv += %w(--cpus 1)
115
+ argv += %w(--memory 512)
116
+ argv += %w(--requested-for myuser@corp.local)
117
+ argv += %w(--bootstrap-protocol ssh)
118
+ argv += %w(--ssh-password password)
119
+ argv += %w(d5ba201a-449f-47a4-9d02-39196224bf01)
120
+ argv += %w(--extra-param key1=faketype:value1)
121
+ command = Chef::Knife::Cloud::VraServerCreate.new(argv)
122
+
123
+ expect { command.validate_extra_params! }.to raise_error(ArgumentError)
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,63 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+ require 'chef/knife/vra_server_delete'
21
+ require 'support/shared_examples_for_command'
22
+ require 'support/shared_examples_for_serverdeletecommand'
23
+
24
+ describe Chef::Knife::Cloud::VraServerDelete do
25
+ subject { Chef::Knife::Cloud::VraServerDelete.new(%w(12345 54321)) }
26
+
27
+ it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::VraServerDelete.new(%w(12345 54321))
28
+
29
+ describe '#validate_params!' do
30
+ context 'when no resource IDs are supplied' do
31
+ let(:command) { Chef::Knife::Cloud::VraServerDelete.new }
32
+ it 'prints an error and exits' do
33
+ expect(command.ui).to receive(:error)
34
+ expect { command.validate_params! }.to raise_error(SystemExit)
35
+ end
36
+ end
37
+ end
38
+
39
+ describe '#execute_command' do
40
+ before(:each) do
41
+ server1 = double('server1', name: 'server1')
42
+ server2 = double('server2', name: 'server2')
43
+ allow(subject).to receive_message_chain(:service, :get_server).with('12345').and_return(server1)
44
+ allow(subject).to receive_message_chain(:service, :get_server).with('54321').and_return(server2)
45
+ end
46
+
47
+ it 'calls delete_server for each server' do
48
+ allow(subject).to receive(:delete_from_chef).with('server1')
49
+ allow(subject).to receive(:delete_from_chef).with('server2')
50
+ expect(subject).to receive_message_chain(:service, :delete_server).with('12345')
51
+ expect(subject).to receive_message_chain(:service, :delete_server).with('54321')
52
+ subject.execute_command
53
+ end
54
+
55
+ it 'calls delete_from_chef using the server names for each server' do
56
+ allow(subject).to receive_message_chain(:service, :delete_server).with('12345')
57
+ allow(subject).to receive_message_chain(:service, :delete_server).with('54321')
58
+ expect(subject).to receive(:delete_from_chef).with('server1')
59
+ expect(subject).to receive(:delete_from_chef).with('server2')
60
+ subject.execute_command
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,50 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+ require 'chef/knife/vra_server_list'
21
+ require 'support/shared_examples_for_command'
22
+
23
+ describe Chef::Knife::Cloud::VraServerList do
24
+ it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::VraServerList.new
25
+
26
+ subject { described_class.new }
27
+
28
+ describe '#format_status_value' do
29
+ context 'when the status is "active"' do
30
+ it 'displays with green' do
31
+ expect(subject.ui).to receive(:color).with('active', :green)
32
+ subject.format_status_value('active')
33
+ end
34
+ end
35
+
36
+ context 'when the status is "deleted"' do
37
+ it 'displays with red' do
38
+ expect(subject.ui).to receive(:color).with('deleted', :red)
39
+ subject.format_status_value('deleted')
40
+ end
41
+ end
42
+
43
+ context 'when the status is anything else' do
44
+ it 'displays with yellow' do
45
+ expect(subject.ui).to receive(:color).with('unknown', :yellow)
46
+ subject.format_status_value('unknown')
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,43 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+ require 'chef/knife/vra_server_show'
21
+ require 'support/shared_examples_for_command'
22
+
23
+ describe Chef::Knife::Cloud::VraServerShow do
24
+ it_behaves_like Chef::Knife::Cloud::Command, Chef::Knife::Cloud::VraServerShow.new
25
+
26
+ describe '#validate_params!' do
27
+ context 'when no resources are supplied' do
28
+ let(:command) { Chef::Knife::Cloud::VraServerShow.new }
29
+ it 'prints an error and exits' do
30
+ expect(command.ui).to receive(:error)
31
+ expect { command.validate_params! }.to raise_error(SystemExit)
32
+ end
33
+ end
34
+
35
+ context 'when more than one resource is supplied' do
36
+ let(:command) { Chef::Knife::Cloud::VraServerShow.new(%w(12345 54321)) }
37
+ it 'prints an error and exits' do
38
+ expect(command.ui).to receive(:error)
39
+ expect { command.validate_params! }.to raise_error(SystemExit)
40
+ end
41
+ end
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knife-vrealize
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Chef Partner Engineering
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chef
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: knife-cloud
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: vmware-vra
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.0.rc2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0.rc2
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description: Knife plugin to interact with VMware vRealize.
84
+ email:
85
+ - partnereng@chef.io
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rubocop.yml"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - knife-vrealize.gemspec
96
+ - lib/chef/knife/cloud/vra_service.rb
97
+ - lib/chef/knife/cloud/vra_service_helpers.rb
98
+ - lib/chef/knife/cloud/vra_service_options.rb
99
+ - lib/chef/knife/vra_catalog_list.rb
100
+ - lib/chef/knife/vra_server_create.rb
101
+ - lib/chef/knife/vra_server_delete.rb
102
+ - lib/chef/knife/vra_server_list.rb
103
+ - lib/chef/knife/vra_server_show.rb
104
+ - lib/knife-vrealize/version.rb
105
+ - spec/spec_helper.rb
106
+ - spec/unit/cloud/vra_service_helpers_spec.rb
107
+ - spec/unit/cloud/vra_service_spec.rb
108
+ - spec/unit/vra_catalog_list_spec.rb
109
+ - spec/unit/vra_server_create_spec.rb
110
+ - spec/unit/vra_server_delete_spec.rb
111
+ - spec/unit/vra_server_list_spec.rb
112
+ - spec/unit/vra_server_show_spec.rb
113
+ homepage: https://gihub.com/chef-partners/knife-vrealize
114
+ licenses:
115
+ - Apache 2.0
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">"
129
+ - !ruby/object:Gem::Version
130
+ version: 1.3.1
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.4.4
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Knife plugin to interact with VMware vRealize.
137
+ test_files:
138
+ - spec/spec_helper.rb
139
+ - spec/unit/cloud/vra_service_helpers_spec.rb
140
+ - spec/unit/cloud/vra_service_spec.rb
141
+ - spec/unit/vra_catalog_list_spec.rb
142
+ - spec/unit/vra_server_create_spec.rb
143
+ - spec/unit/vra_server_delete_spec.rb
144
+ - spec/unit/vra_server_list_spec.rb
145
+ - spec/unit/vra_server_show_spec.rb
146
+ has_rdoc: