brocadesan 0.4.0 → 0.4.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.
- data/README +114 -113
- data/brocadesan.gemspec +2 -2
- data/lib/brocadesan/switch.rb +5 -0
- data/test/switch_test.rb +10 -0
- metadata +2 -2
data/README
CHANGED
@@ -1,113 +1,114 @@
|
|
1
|
-
=
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
switch.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
switch.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
#
|
46
|
-
# the mode
|
47
|
-
#
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
agent
|
61
|
-
|
62
|
-
|
63
|
-
zone
|
64
|
-
zone.
|
65
|
-
zone.add_member "
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
#
|
72
|
-
#
|
73
|
-
agent
|
74
|
-
|
75
|
-
agent.
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
Software
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
1
|
+
{<img src="https://badge.fury.io/rb/brocadesan.svg" alt="Gem Version" />}[http://badge.fury.io/rb/brocadesan]
|
2
|
+
= BrocadeSAN
|
3
|
+
|
4
|
+
== What is BrocadeSAN?
|
5
|
+
|
6
|
+
BrocadeSAN provides a simple wrapper API to communicate with Brocade SAN switches using SSH connection.
|
7
|
+
You have option to either run the command manualy or query the switch with pre-defined set of methods.
|
8
|
+
|
9
|
+
Additionally you can use Brocade::SAN::Provisioning::Agent for zoning provisioning tasks.
|
10
|
+
|
11
|
+
== Basic Usage
|
12
|
+
|
13
|
+
You can use BrocadeSAN in 2 different ways:
|
14
|
+
|
15
|
+
=== 1. Query the SAN switch directly using 1 connection per command query
|
16
|
+
|
17
|
+
# this will query the switch name and version and open connection to switch twice
|
18
|
+
|
19
|
+
switch=Brocade::SAN::Switch.new("address","user","password")
|
20
|
+
|
21
|
+
switch.name
|
22
|
+
switch.firmware
|
23
|
+
|
24
|
+
=== 2. Query the SAN switch in session block using 1 connection per session
|
25
|
+
|
26
|
+
# this will query the switch name and version and open connection to switch only once
|
27
|
+
|
28
|
+
switch=Brocade::SAN::Switch.new("address","user","password")
|
29
|
+
|
30
|
+
switch.session do
|
31
|
+
switch.name
|
32
|
+
switch.firmare
|
33
|
+
end
|
34
|
+
|
35
|
+
== Special Usage
|
36
|
+
|
37
|
+
If the API is not sufficient for your need you can always utilize the Brocade::SAN::Switch#query method to execute arbitrary commands
|
38
|
+
|
39
|
+
# sends command to switch
|
40
|
+
response=switch.query("portshow | grep Online ")
|
41
|
+
|
42
|
+
# sends several commands to switch
|
43
|
+
response=switch.query("switchshow","cfgshow")
|
44
|
+
|
45
|
+
# calls interactive command and sends response along the way
|
46
|
+
# the mode has to be set to interactive
|
47
|
+
# the mode will persist across queries
|
48
|
+
# change it back to :script when you want to run non-interactive command
|
49
|
+
switch.set_mode :interactive
|
50
|
+
response=switch.query("cfgsave","y")
|
51
|
+
|
52
|
+
Response is type of Brocade::SAN::Switch::Response. You can get the data by calling +data+ and errors by calling +errors+.
|
53
|
+
The data will be raw output from the switch with each cmd prefixed by defined/default prompt.
|
54
|
+
|
55
|
+
== Provisioning
|
56
|
+
|
57
|
+
This is wrapper API for provisioning tasks with added control. This wrapper expects some basic understanding of zoning provisioning tasks and should be used to build
|
58
|
+
specialized provisioning clients.
|
59
|
+
|
60
|
+
# creates a agent, user must have provisioning rights
|
61
|
+
agent=Brocade::SAN::Provisoning::Agent.create("address","user","password")
|
62
|
+
|
63
|
+
# create a zone instance with aliases
|
64
|
+
zone = Brocade::SAN::Zone.new("host_array_zone")
|
65
|
+
zone.add_member "host_alias"
|
66
|
+
zone.add_member "array_alias"
|
67
|
+
|
68
|
+
# gets effecive configuration (false gets name only without members)
|
69
|
+
cfg=agent.effective_configuration(false)
|
70
|
+
|
71
|
+
# creates zone and adds it to the configuration in transaction
|
72
|
+
# transaction saves configuration at the end, it does not enable effective configuration
|
73
|
+
# agent methods outside of transaction will save configuration immediately
|
74
|
+
agent.transaction do
|
75
|
+
agent.zone_create zone
|
76
|
+
agent.cfg_add cfg, zone
|
77
|
+
end
|
78
|
+
|
79
|
+
# enable effective configuration
|
80
|
+
agent.cfg_enable cfg
|
81
|
+
|
82
|
+
== Download and Installation
|
83
|
+
|
84
|
+
Installation *with* RubyGems:
|
85
|
+
# gem install brocadesan
|
86
|
+
|
87
|
+
== Author
|
88
|
+
|
89
|
+
Written 2015 by Tomas Trnecka <mailto:trnecka@gmail.com>.
|
90
|
+
|
91
|
+
== License
|
92
|
+
|
93
|
+
Copyright (c) 2015 Tomas Trnecka
|
94
|
+
|
95
|
+
Permission is hereby granted, free of charge, to any person
|
96
|
+
obtaining a copy of this software and associated documentation
|
97
|
+
files (the "Software"), to deal in the Software without
|
98
|
+
restriction, including without limitation the rights to use,
|
99
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
100
|
+
copies of the Software, and to permit persons to whom the
|
101
|
+
Software is furnished to do so, subject to the following
|
102
|
+
conditions:
|
103
|
+
|
104
|
+
The above copyright notice and this permission notice shall be
|
105
|
+
included in all copies or substantial portions of the Software.
|
106
|
+
|
107
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
108
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
109
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
110
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
111
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
112
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
113
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
114
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/brocadesan.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'brocadesan'
|
3
|
-
s.version = '0.4.
|
4
|
-
s.date = '2015-02-
|
3
|
+
s.version = '0.4.1'
|
4
|
+
s.date = '2015-02-10'
|
5
5
|
s.summary = "Brocade SAN library"
|
6
6
|
s.description = "Gem to manipulate FABOS based devices"
|
7
7
|
s.authors = ["Tomas Trnecka"]
|
data/lib/brocadesan/switch.rb
CHANGED
data/test/switch_test.rb
CHANGED
@@ -21,6 +21,16 @@ class SwitchTest < MiniTest::Test
|
|
21
21
|
response=@device.query("test")
|
22
22
|
assert_instance_of Switch::Response, response
|
23
23
|
assert_equal @device.prompt+"test\n"+Mock::Net::SSH::get_data+"\n", response.data
|
24
|
+
# check fullcmd is started
|
25
|
+
@i=0
|
26
|
+
inc = lambda {|cmd| @i+=1;cmd}
|
27
|
+
@device.stub :fullcmd, inc do
|
28
|
+
response=@device.query("test")
|
29
|
+
assert_equal 1, @i
|
30
|
+
@i=0
|
31
|
+
response=@device.query("test","test")
|
32
|
+
assert_equal 2, @i
|
33
|
+
end
|
24
34
|
end
|
25
35
|
|
26
36
|
def test_device_setup
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brocadesan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-02-
|
12
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|