knife-lpar 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,87 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2014-2016 Chef Software Inc.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require "spec_helper"
19
+ require "chef/knife/lpar_list.rb"
20
+
21
+ describe Chef::Knife::LparList do
22
+
23
+ subject(:knife) do
24
+ Chef::Knife::LparList.new(argv).tap do |c|
25
+ allow(c).to receive(:output).and_return(true)
26
+ c.parse_options(argv)
27
+ c.merge_configs
28
+ end
29
+ end
30
+
31
+ describe "#run" do
32
+ context "by default" do
33
+ let(:argv) { %w{ list serverurl --virtual-server fakevirt } }
34
+
35
+ it "parses argv, gets password, and lists lpars" do
36
+ expect(knife).to receive(:read_and_validate_params).and_call_original
37
+ expect(knife).to receive(:get_password)
38
+ expect(knife).to receive(:list_lpars)
39
+ knife.run
40
+ end
41
+ end
42
+ end
43
+
44
+ describe "#read_and_validate_params" do
45
+ context "when argv is empty" do
46
+ let(:argv) { [] }
47
+
48
+ it "prints usage and exits" do
49
+ expect(knife).to receive(:read_and_validate_params).and_call_original
50
+ expect(knife).to receive(:show_usage)
51
+ expect { knife.run }.to raise_error(SystemExit)
52
+ end
53
+ end
54
+
55
+ context "when the virtual-server parameter is missing" do
56
+ let(:argv) { %w{ list serverurl } }
57
+
58
+ it "prints usage and exits" do
59
+ expect(knife).to receive(:read_and_validate_params).and_call_original
60
+ expect(knife).to receive(:show_usage)
61
+ expect { knife.run }.to raise_error(SystemExit)
62
+ end
63
+ end
64
+ end
65
+
66
+ describe "#list_lpars" do
67
+ before(:each) do
68
+ Chef::Knife::LparList.load_deps
69
+ @session = double(Net::SSH)
70
+ allow(Net::SSH).to receive(:start).with("serverurl", "hscroot", :password => "testpass").and_yield(@session)
71
+ end
72
+
73
+ context "listing lpars" do
74
+ let(:argv) { %w{ list serverurl --virtual-server fakevirt } }
75
+
76
+ it "lists lpars" do
77
+
78
+ expect(knife).to receive(:read_and_validate_params).and_call_original
79
+ expect(knife).to receive(:get_password).and_return("testpass")
80
+ expect(knife).to receive(:list_lpars).and_call_original
81
+ expect(knife).to receive(:run_remote_command).with(@session, "lssyscfg -m fakevirt -F lpar_id,lpar_env,name,os_version -r lpar").and_return("1,vios,whee,VIOS 1.2.3.4\n")
82
+
83
+ knife.run
84
+ end
85
+ end
86
+ end
87
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: knife-lpar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Scott Hain
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-07-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: net-ssh
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
27
+ description: LPAR creation
28
+ email:
29
+ - shain@chef.io
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/CODEOWNERS"
35
+ - ".github/ISSUE_TEMPLATE.md"
36
+ - ".gitignore"
37
+ - ".rubocop.yml"
38
+ - ".travis.yml"
39
+ - CHANGELOG.md
40
+ - Gemfile
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - knife-lpar.gemspec
45
+ - lib/chef/knife/lpar_base.rb
46
+ - lib/chef/knife/lpar_create.rb
47
+ - lib/chef/knife/lpar_delete.rb
48
+ - lib/chef/knife/lpar_list.rb
49
+ - lib/knife-lpar/version.rb
50
+ - spec/spec_helper.rb
51
+ - spec/unit/lpar_base_spec.rb
52
+ - spec/unit/lpar_create_spec.rb
53
+ - spec/unit/lpar_delete_spec.rb
54
+ - spec/unit/lpar_list_spec.rb
55
+ homepage: http://github.com/chef/knife-lpar
56
+ licenses:
57
+ - Apache 2.0
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.7.6
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: LPAR creation
79
+ test_files:
80
+ - spec/spec_helper.rb
81
+ - spec/unit/lpar_base_spec.rb
82
+ - spec/unit/lpar_create_spec.rb
83
+ - spec/unit/lpar_delete_spec.rb
84
+ - spec/unit/lpar_list_spec.rb