boris 1.0.0.beta.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/CHANGELOG.md +11 -0
  2. data/README.md +114 -32
  3. data/Rakefile +19 -0
  4. data/lib/boris.rb +0 -13
  5. data/lib/boris/connectors.rb +25 -7
  6. data/lib/boris/connectors/snmp.rb +24 -4
  7. data/lib/boris/connectors/ssh.rb +32 -6
  8. data/lib/boris/connectors/wmi.rb +109 -54
  9. data/lib/boris/errors.rb +1 -1
  10. data/lib/boris/helpers/array.rb +62 -62
  11. data/lib/boris/helpers/constants.rb +22 -19
  12. data/lib/boris/helpers/hash.rb +7 -7
  13. data/lib/boris/helpers/network.rb +68 -0
  14. data/lib/boris/helpers/scrubber.rb +53 -51
  15. data/lib/boris/helpers/string.rb +148 -26
  16. data/lib/boris/lumberjack.rb +74 -47
  17. data/lib/boris/options.rb +28 -16
  18. data/lib/boris/profiler.rb +19 -0
  19. data/lib/boris/profilers/linux/redhat.rb +74 -0
  20. data/lib/boris/{profiles → profilers}/linux_core.rb +13 -4
  21. data/lib/boris/{profiles → profilers}/unix/solaris.rb +25 -15
  22. data/lib/boris/{profiles → profilers}/unix_core.rb +90 -85
  23. data/lib/boris/profilers/windows/windows2003.rb +11 -0
  24. data/lib/boris/profilers/windows/windows2008.rb +26 -0
  25. data/lib/boris/profilers/windows/windows2012.rb +11 -0
  26. data/lib/boris/{profiles → profilers}/windows_core.rb +36 -14
  27. data/lib/boris/structure.rb +173 -167
  28. data/lib/boris/target.rb +110 -168
  29. data/lib/boris/version.rb +3 -0
  30. metadata +32 -115
  31. data/boris.gemspec +0 -28
  32. data/doc/Array.html +0 -437
  33. data/doc/Boris.html +0 -230
  34. data/doc/Boris/ConnectionAlreadyActive.html +0 -123
  35. data/doc/Boris/ConnectionFailed.html +0 -127
  36. data/doc/Boris/Connector.html +0 -794
  37. data/doc/Boris/InvalidCredentials.html +0 -131
  38. data/doc/Boris/InvalidOption.html +0 -123
  39. data/doc/Boris/InvalidTargetName.html +0 -123
  40. data/doc/Boris/Lumberjack.html +0 -466
  41. data/doc/Boris/MissingCredentials.html +0 -123
  42. data/doc/Boris/NoActiveConnection.html +0 -123
  43. data/doc/Boris/NoProfileDetected.html +0 -123
  44. data/doc/Boris/Options.html +0 -783
  45. data/doc/Boris/Profiles.html +0 -117
  46. data/doc/Boris/Profiles/Linux.html +0 -1151
  47. data/doc/Boris/Profiles/RedHat.html +0 -875
  48. data/doc/Boris/Profiles/Solaris.html +0 -1230
  49. data/doc/Boris/Profiles/Structure.html +0 -2050
  50. data/doc/Boris/Profiles/UNIX.html +0 -893
  51. data/doc/Boris/Profiles/Windows.html +0 -1846
  52. data/doc/Boris/Profiles/Windows/Windows2003.html +0 -304
  53. data/doc/Boris/Profiles/Windows/Windows2008.html +0 -379
  54. data/doc/Boris/Profiles/Windows/Windows2012.html +0 -304
  55. data/doc/Boris/SNMPConnector.html +0 -512
  56. data/doc/Boris/SSHConnector.html +0 -633
  57. data/doc/Boris/Target.html +0 -2002
  58. data/doc/Boris/WMIConnector.html +0 -1134
  59. data/doc/BorisLogger.html +0 -217
  60. data/doc/Hash.html +0 -195
  61. data/doc/String.html +0 -1246
  62. data/doc/_index.html +0 -420
  63. data/doc/class_list.html +0 -53
  64. data/doc/css/common.css +0 -1
  65. data/doc/css/full_list.css +0 -57
  66. data/doc/css/style.css +0 -328
  67. data/doc/file.README.html +0 -183
  68. data/doc/file_list.html +0 -55
  69. data/doc/frames.html +0 -28
  70. data/doc/index.html +0 -183
  71. data/doc/js/app.js +0 -214
  72. data/doc/js/full_list.js +0 -173
  73. data/doc/js/jquery.js +0 -4
  74. data/doc/method_list.html +0 -1468
  75. data/doc/top-level-namespace.html +0 -126
  76. data/lib/boris/profiles/linux/redhat.rb +0 -77
  77. data/lib/boris/profiles/windows/windows2003.rb +0 -15
  78. data/lib/boris/profiles/windows/windows2008.rb +0 -23
  79. data/lib/boris/profiles/windows/windows2012.rb +0 -15
  80. data/test/connector_tests/test_snmp.rb +0 -35
  81. data/test/connector_tests/test_ssh.rb +0 -51
  82. data/test/connector_tests/test_wmi.rb +0 -129
  83. data/test/helper_tests/test_array.rb +0 -25
  84. data/test/helper_tests/test_hash.rb +0 -10
  85. data/test/helper_tests/test_string.rb +0 -136
  86. data/test/profile_tests/test_core_skeleton +0 -107
  87. data/test/profile_tests/test_linux_core.rb +0 -331
  88. data/test/profile_tests/test_redhat.rb +0 -134
  89. data/test/profile_tests/test_solaris.rb +0 -523
  90. data/test/profile_tests/test_unix_core.rb +0 -117
  91. data/test/profile_tests/test_windows.rb +0 -536
  92. data/test/setup_tests.rb +0 -14
  93. data/test/test_all.rb +0 -8
  94. data/test/test_options.rb +0 -44
  95. data/test/test_structure.rb +0 -136
  96. data/test/test_target.rb +0 -146
@@ -1,14 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__),'..','lib')
2
-
3
- require 'test/unit'
4
- require 'shoulda'
5
- require 'boris'
6
-
7
- include Boris
8
-
9
- class ProfileTestSetup < Test::Unit::TestCase
10
- def initialize(test)
11
- super(test)
12
- @target = Target.new('0.0.0.0')
13
- end
14
- end
@@ -1,8 +0,0 @@
1
- $: << '.'
2
-
3
- Dir.chdir(File.dirname(__FILE__)) do
4
- test_files = Dir['test_*.rb'] - [('test_all.rb')]
5
- test_files.concat(Dir['**/test_*.rb'])
6
-
7
- test_files.each { |file| require file }
8
- end
@@ -1,44 +0,0 @@
1
- require 'setup_tests'
2
-
3
- class OptionsTest < Test::Unit::TestCase
4
- context 'the options for a Target' do
5
- setup do
6
- @options = Options.new
7
- end
8
-
9
- should 'be modifiable via the options hash' do
10
- @options[:auto_scrub_data] = false
11
- @options[:credentials] = [{:user=>'someuser'}]
12
- @options[:log_level] = Logger::INFO
13
- @options[:profiles] = [:windows_core]
14
- @options[:snmp_options] = {:MibModules=>['IF-MIB']}
15
- @options[:ssh_options] = {:keys=>'~/.ssh/my_private_key', :verbose=>:debug}
16
-
17
- assert_equal(false, @options[:auto_scrub_data])
18
- assert_equal([{:user=>'someuser'}], @options[:credentials])
19
- assert_equal(Logger::INFO, @options[:log_level])
20
- assert_equal([:windows_core], @options[:profiles])
21
- assert_equal({:MibModules=>['IF-MIB']}, @options[:snmp_options])
22
- assert_equal({:keys=>'~/.ssh/my_private_key', :verbose=>:debug}, @options[:ssh_options])
23
- end
24
-
25
- should 'error if invalid options are provided' do
26
- assert_raise(ArgumentError) {@options[:invalid_option] = nil}
27
- end
28
-
29
- should 'error if invalid options are passed to #add_credential' do
30
- assert_raise(ArgumentError) {@options.add_credential(:password=>'somepass')}
31
- assert_raise(ArgumentError) {@options.add_credential(:user=>'someuser', :connection_types=>[:i_dont_exist])}
32
- assert_raise(ArgumentError) {@options.add_credential([{:user=>'someuser1'},{:user=>'someuser2'}])}
33
- end
34
-
35
- should 'allow its credentials be added through #add_credential' do
36
- @options.add_credential(:user=>'someuser', :password=>'somepass', :connection_types=>[:wmi])
37
- @options.add_credential(:user=>'someotheruser', :connection_types=>[:ssh])
38
- assert_equal([
39
- {:user=>'someuser', :password=>'somepass', :connection_types=>[:wmi]},
40
- {:user=>'someotheruser', :connection_types=>[:ssh]}
41
- ], @options[:credentials])
42
- end
43
- end
44
- end
@@ -1,136 +0,0 @@
1
- require 'setup_tests'
2
-
3
- class ProfileStructure
4
- include Profiles::Structure
5
- attr_accessor :logger, :options
6
- end
7
-
8
- class StructureTest < Test::Unit::TestCase
9
- context 'a data structure' do
10
- setup do
11
- @structure = ProfileStructure.new
12
- @structure.options = Options.new
13
- end
14
-
15
- should 'provide us with a file system template via #file_system_template' do
16
- expected = [
17
- :capacity_mb,
18
- :file_system,
19
- :mount_point,
20
- :san_storage,
21
- :used_space_mb
22
- ].to_nil_hash
23
-
24
- assert_equal(expected, @structure.file_system_template)
25
- end
26
-
27
- should 'provide us with a hardware template via #get_hardware' do
28
- expected = [
29
- :cpu_architecture,
30
- :cpu_core_count,
31
- :cpu_model,
32
- :cpu_physical_count,
33
- :cpu_speed_mhz,
34
- :cpu_vendor,
35
- :firmware_version,
36
- :model,
37
- :memory_installed_mb,
38
- :serial,
39
- :vendor
40
- ].to_nil_hash
41
-
42
- assert_equal(expected, @structure.get_hardware)
43
- end
44
-
45
- should 'provide us with an installed application template via #installed_application_template' do
46
- expected = [
47
- :date_installed,
48
- :install_location,
49
- :license_key,
50
- :name,
51
- :vendor,
52
- :version
53
- ].to_nil_hash
54
-
55
- assert_equal(expected, @structure.installed_application_template)
56
- end
57
-
58
- should 'provide us with a local user groups template via #local_user_groups_template' do
59
- expected = {
60
- :group=>nil,
61
- :members=>[]
62
- }
63
-
64
- assert_equal(expected, @structure.local_user_groups_template)
65
- end
66
-
67
- should 'provide us with a network identification template via #get_network_id' do
68
- expected = [
69
- :domain,
70
- :hostname
71
- ].to_nil_hash
72
-
73
- assert_equal(expected, @structure.get_network_id)
74
- end
75
-
76
- should 'provide us with a network interface template via #network_interface_template' do
77
- expected = [
78
- :auto_negotiate,
79
- :current_speed_mbps,
80
- :duplex,
81
- :fabric_name,
82
- :is_uplink,
83
- :mac_address,
84
- :model,
85
- :model_id,
86
- :mtu,
87
- :name,
88
- :node_wwn,
89
- :port_wwn,
90
- :remote_mac_address,
91
- :status,
92
- :type,
93
- :vendor,
94
- :vendor_id,
95
- :dns_servers=>[],
96
- :ip_addresses=>[]
97
- ].to_nil_hash
98
-
99
- assert_equal(expected, @structure.network_interface_template)
100
- end
101
-
102
- should 'provide us with an operating system template via #get_operating_system' do
103
- expected = [
104
- :date_installed,
105
- :kernel,
106
- :license_key,
107
- :name,
108
- :service_pack,
109
- :version,
110
- :features=>[],
111
- :roles=>[]
112
- ].to_nil_hash
113
-
114
- assert_equal(expected, @structure.get_operating_system)
115
- end
116
-
117
- should 'provide us with a patch template via #installed_patch_template' do
118
- expected = [
119
- :date_installed,
120
- :installed_by,
121
- :patch_code
122
- ].to_nil_hash
123
-
124
- assert_equal(expected, @structure.installed_patch_template)
125
- end
126
-
127
- should 'provide us with a share template via #hosted_share_template' do
128
- expected = [
129
- :name,
130
- :path
131
- ].to_nil_hash
132
-
133
- assert_equal(expected, @structure.hosted_share_template)
134
- end
135
- end
136
- end
@@ -1,146 +0,0 @@
1
- require 'setup_tests'
2
-
3
- class TargetTest < Test::Unit::TestCase
4
- context 'a Target' do
5
- setup do
6
- @target = Target.new('0.0.0.0')
7
- @target.extend(Profiles::Structure)
8
- @cred = {:user=>'someuser', :password=>'somepass'}
9
- end
10
-
11
- should 'return host info after calling #load_host_info' do
12
- @target.expects(:load_host_info).returns([@host, nil])
13
- assert_equal(@target.load_host_info, [@host, nil])
14
- end
15
-
16
- should 'allow its target name to be readable' do
17
- assert_equal('0.0.0.0', @target.host)
18
- end
19
-
20
- should 'allow its options to be modifiable by passing a block to Target#new' do
21
- Target.new(@host) do |t|
22
- t.options[:ssh_options] = {:timeout=>10}
23
-
24
- assert_equal({:timeout=>10}, t.options[:ssh_options])
25
- end
26
- end
27
-
28
- should 'allow us to call methods for retrieving all standard configuration items via #retrieve_all' do
29
- @target.options[:auto_scrub_data] = false
30
- @target.retrieve_all
31
-
32
- assert_equal([], @target.file_systems)
33
- assert_equal([], @target.installed_applications)
34
- assert_equal([], @target.local_user_groups)
35
- assert_equal([], @target.network_interfaces)
36
- assert_equal([], @target.installed_patches)
37
- assert_equal([], @target.hosted_shares)
38
- end
39
-
40
- should 'allow its data (instance variables) to be produced as json' do
41
- long_json_string = %w{
42
- {"file_systems":null,
43
- "hardware":null,
44
- "hosted_shares":null,
45
- "installed_applications":null,
46
- "installed_patches":null,
47
- "installed_services":null,
48
- "local_user_groups":null,
49
- "network_id":null,
50
- "network_interfaces":null,
51
- "operating_system":null}}.join
52
-
53
- assert_equal(long_json_string, @target.to_json)
54
- end
55
-
56
-
57
- should 'allow credentials to be added through #add_credential' do
58
- @target.options.add_credential(@cred.merge!(:connection_types=>[:wmi]))
59
- assert_equal([@cred], @target.options[:credentials])
60
- end
61
-
62
- context 'listening on certain ports' do
63
- should "allow us to detect a possible SSH connection if it is listening on port #{Boris::PORT_DEFAULTS[:ssh]}" do
64
- @target.expects(:tcp_port_responding?).with(22).returns(true)
65
- @target.expects(:tcp_port_responding?).with(135).returns(false)
66
- assert_equal(:ssh, @target.suggested_connection_method)
67
- end
68
-
69
- should "allow us to detect a possible WMI connection if if it is listening on port #{Boris::PORT_DEFAULTS[:wmi]}" do
70
- @target.expects(:tcp_port_responding?).with(135).returns(true)
71
- assert_equal(:wmi, @target.suggested_connection_method)
72
- end
73
-
74
- should 'return with no detected connection method if all attempts fail' do
75
- @target.expects(:tcp_port_responding?).with(22).returns(false)
76
- @target.expects(:tcp_port_responding?).with(135).returns(false)
77
- assert_nil(nil, @target.suggested_connection_method)
78
- end
79
- end
80
-
81
- context 'that we will try to connect to' do
82
- should 'error if no credentials are specified' do
83
- assert_raise(InvalidOption) {@target.connect}
84
- end
85
-
86
- should 'error if we try to detect the profile when there is no active connection' do
87
- assert_raise(NoActiveConnection) {@target.detect_profile}
88
- end
89
-
90
- should 'attempt an SSH and WMI connection only once if the target does not respond to an attempt' do
91
- skip("test relies on WIN32OLE") if PLATFORM != :win32
92
-
93
- @target.options.add_credential(@cred.merge!(:connection_types=>[:snmp, :ssh, :wmi]))
94
-
95
- Net::SSH.stubs(:start).raises(Net::SSH::HostKeyMismatch)
96
- WIN32OLE.any_instance.stubs(:ConnectServer).raises(WIN32OLERuntimeError, 'rpc server is unavailable')
97
-
98
- SSHConnector.any_instance.expects(:establish_connection).once
99
- WMIConnector.any_instance.expects(:establish_connection).once
100
-
101
- @target.connect
102
- end
103
-
104
- should 'attempt a connection only once when connection is not available and when multiple credentials are supplied' do
105
- @target.options[:credentials] = [@cred.merge(:connection_types=>[:ssh])]
106
- @target.options[:credentials] << @cred.merge(:connection_types=>[:ssh])
107
-
108
- SSHConnector.any_instance.stubs(:reconnectable).returns(false)
109
- SSHConnector.any_instance.expects(:establish_connection).once
110
-
111
- @target.connect
112
- end
113
- end
114
-
115
- context 'that we have successfully connected to' do
116
- setup do
117
- ssh_connection = mock('SSHConnector')
118
- @target.connector = ssh_connection
119
-
120
- @target.connector.stubs(:connected?).returns(true)
121
- @target.connector.stubs(:class).returns(Connector::SSHConnector)
122
- @target.stubs(:connect).returns(@target.connector)
123
-
124
- @target.options[:profiles].each do |profile|
125
- profile.stubs(:matches_target?).returns(false)
126
- end
127
-
128
- @target.connect
129
- end
130
-
131
- should 'raise an error if no profiles are found to be suitable' do
132
- assert_raise(NoProfileDetected) {@target.detect_profile}
133
- end
134
-
135
- should 'detect the best profile for our target' do
136
- Profiles::RedHat.stubs(:matches_target?).returns(true)
137
- assert_equal(Profiles::RedHat, @target.detect_profile)
138
- end
139
-
140
- should 'allow us to force a profile to be used for our target even if it is not ideal' do
141
- @target.force_profile_to(Profiles::RedHat)
142
- assert_equal(Profiles::RedHat, @target.target_profile)
143
- end
144
- end
145
- end
146
- end