rbvppc 1.0.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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +302 -0
- data/Rakefile +8 -0
- data/documentation/hmc.odt +0 -0
- data/documentation/lpar.odt +0 -0
- data/documentation/lun.odt +0 -0
- data/documentation/network.odt +0 -0
- data/documentation/nim.odt +0 -0
- data/documentation/vio.odt +0 -0
- data/documentation/vnic.odt +0 -0
- data/documentation/vscsi.odt +0 -0
- data/examples/add_disk_any_size_to_lpar.rb +46 -0
- data/examples/add_disk_specifing_size_to_lpar.rb +47 -0
- data/examples/remove_disks_and_delete_lpar.rb +35 -0
- data/examples/remove_disks_from_lpar.rb +33 -0
- data/examples/test_lpar_build.rb +83 -0
- data/lib/rbvppc/command_failure.rb +18 -0
- data/lib/rbvppc/connectable_server.rb +95 -0
- data/lib/rbvppc/hmc.rb +892 -0
- data/lib/rbvppc/lpar.rb +1140 -0
- data/lib/rbvppc/lun.rb +23 -0
- data/lib/rbvppc/network.rb +54 -0
- data/lib/rbvppc/nim.rb +442 -0
- data/lib/rbvppc/version.rb +10 -0
- data/lib/rbvppc/vio.rb +720 -0
- data/lib/rbvppc/vnic.rb +34 -0
- data/lib/rbvppc/vscsi.rb +36 -0
- data/lib/rbvppc.rb +28 -0
- data/rbvppc.gemspec +26 -0
- metadata +117 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Authors: Christopher M Wood (<woodc@us.ibm.com>)
|
|
3
|
+
# John F Hutchinson (<jfhutchi@us.ibm.com)
|
|
4
|
+
# © Copyright IBM Corporation 2015.
|
|
5
|
+
#
|
|
6
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
|
7
|
+
#
|
|
8
|
+
=begin
|
|
9
|
+
TODO:
|
|
10
|
+
1.Add Connectivity Methods for Non SSH connections.
|
|
11
|
+
2.Check if the password is passed in clear text or not
|
|
12
|
+
|
|
13
|
+
=end
|
|
14
|
+
|
|
15
|
+
require 'rubygems'
|
|
16
|
+
require 'net/ssh'
|
|
17
|
+
require_relative 'command_failure'
|
|
18
|
+
|
|
19
|
+
class ConnectableServer
|
|
20
|
+
|
|
21
|
+
attr_reader :debug
|
|
22
|
+
|
|
23
|
+
def initialize(hostname, username, options)
|
|
24
|
+
options[:protocol] = :ssh if !options.has_key? :protocol
|
|
25
|
+
options[:port] = 22 if (options[:protocol] == :ssh) && (!options.has_key? :port)
|
|
26
|
+
@hostname, @username, @options = hostname, username, options
|
|
27
|
+
@session = nil
|
|
28
|
+
@debug ||= false
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def connected?
|
|
32
|
+
! @session.nil?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#Debug attribute toggle for childen classes
|
|
36
|
+
#to employ for logging purposes
|
|
37
|
+
def toggle_debug
|
|
38
|
+
@debug ^= true
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def connect
|
|
42
|
+
# @session = Net::SSH.start(@hostname, @username, :password => @password, :port => @port)
|
|
43
|
+
if (@options[:key] && !@options[:password]) then
|
|
44
|
+
@session = Net::SSH.start(@hostname, @username, :key => @options[:key], :port => @options[:port])
|
|
45
|
+
elsif (@options[:key] && @options[:password])
|
|
46
|
+
@session = Net::SSH.start(@hostname, @username, :key => @options[:key], :passphrase => @options[:password], :port => @options[:port])
|
|
47
|
+
else
|
|
48
|
+
@session = Net::SSH.start(@hostname, @username, :password => @options[:password], :port => @options[:port])
|
|
49
|
+
end
|
|
50
|
+
true
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def execute_cmd(command)
|
|
54
|
+
raise StandardError.new("No connection has been established") if !connected?
|
|
55
|
+
stdout_data = ""
|
|
56
|
+
stderr_data = ""
|
|
57
|
+
exit_code = nil
|
|
58
|
+
exit_signal = nil
|
|
59
|
+
@session.open_channel do |channel|
|
|
60
|
+
channel.exec(command) do |ch, success|
|
|
61
|
+
unless success
|
|
62
|
+
abort "FAILED: couldn't execute command (@session.channel.exec)"
|
|
63
|
+
end
|
|
64
|
+
channel.on_data do |ch,data|
|
|
65
|
+
stdout_data+=data
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
channel.on_extended_data do |ch,type,data|
|
|
69
|
+
stderr_data+=data
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
channel.on_request("exit-status") do |ch,data|
|
|
73
|
+
exit_code = data.read_long
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
channel.on_request("exit-signal") do |ch, data|
|
|
77
|
+
exit_signal = data.read_long
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
@session.loop
|
|
82
|
+
raise CommandFailure.new(stderr_data, exit_code, exit_signal) if exit_code != 0
|
|
83
|
+
return stdout_data
|
|
84
|
+
# {:stdout => stdout_data, :stderr => stderr_data, :exit_code => exit_code, :exit_signal => exit_signal}
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def disconnect
|
|
88
|
+
@session.close
|
|
89
|
+
@session = nil
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def toggle_debug
|
|
93
|
+
@debug ^= true
|
|
94
|
+
end
|
|
95
|
+
end
|