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