cisco_nxapi 1.0.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63d9532b69dca7a3d89222ab55572a22cd3eabac
4
- data.tar.gz: e16273c18cbb27992cde626b79d966395edc6f7d
3
+ metadata.gz: f43fda90d4e3356ec90ae3d58b3b5c42df1f5b81
4
+ data.tar.gz: 27411cb40812ff94649fc7fd60f77d9e3b0c2479
5
5
  SHA512:
6
- metadata.gz: efceaaee7cca21224a8a105998b203f7c3f44a08decc02cca3f2b9bac0fafb3e7b2bec923b3e26b84561c53183803060275f72637a623685745310f5726aac41
7
- data.tar.gz: 6bbde4135eba7ab19101df8d7c551925f99dfd539d4665ee42e7212de77f46a84c848c0a5185cbaac3281f6e2022406c5de533e775101b8b136d188571738d34
6
+ metadata.gz: ddff10307f0baafa3330c0b1944b81de4208e00a8e638e2be87786489cb45525a85ea14f8b118765fcd0947d8426853e855fadeebb499b894a501425a4eebf95
7
+ data.tar.gz: d0dc20a41170f446880f92329bc485a763e02f85004692189788df66381caf380d22c4bb1b8ae91c8b08447842c105281c6b20bfe3f3d36a61adfdb8b6b00d2c
@@ -210,11 +210,20 @@ module CiscoNxapi
210
210
  end
211
211
  end
212
212
 
213
+ # Sends a request to the NX API and returns the body of the request or
214
+ # handles errors that happen.
213
215
  # @raise CiscoNxapi::ConnectionRefused if NXAPI is disabled
214
216
  # @raise CiscoNxapi::HTTPUnauthorized if username/password are invalid
215
217
  # @raise CiscoNxapi::HTTPBadRequest (should never occur)
216
218
  # @raise CiscoNxapi::RequestNotSupported
217
219
  # @raise CiscoNxapi::CliError if any command is rejected as invalid
220
+ #
221
+ # @param type ["cli_show", "cli_show_ascii"] Specifies the type of command
222
+ # to be executed.
223
+ # @param command_or_list [String, Array<String>] The command or array of
224
+ # commands which should be run.
225
+ # @return [Hash, Array<Hash>] output when type == "cli_show"
226
+ # @return [String, Array<String>] output when type == "cli_show_ascii"
218
227
  def req(type, command_or_list)
219
228
  if command_or_list.is_a?(Array)
220
229
  # NXAPI wants config lines to be separated by ' ; '
@@ -274,10 +283,20 @@ module CiscoNxapi
274
283
  handle_output(prev_cmds, cmd, o)
275
284
  prev_cmds << cmd
276
285
  end
277
- output = output.each { |o| o['body'] }
286
+ output = output.collect do |o|
287
+ if type == 'cli_show_ascii' && o['body'].empty?
288
+ ''
289
+ else
290
+ o['body']
291
+ end
292
+ end
278
293
  else
279
294
  handle_output(prev_cmds, command, output)
280
- output = output['body']
295
+ if type == 'cli_show_ascii' && output['body'].empty?
296
+ output = ''
297
+ else
298
+ output = output['body']
299
+ end
281
300
  end
282
301
 
283
302
  @cache_hash[type][command] = output if cache_enable?
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module CiscoNxapi
16
- VERSION = '1.0.0'
16
+ VERSION = '1.0.1'
17
17
  end
@@ -105,6 +105,11 @@ class TestNxapi < TestCase
105
105
  assert_equal(result.strip, s.split("\n")[1].strip)
106
106
  end
107
107
 
108
+ def test_show_ascii_empty
109
+ result = client.show('show hostname | include foo | exclude foo', :ascii)
110
+ assert_equal('', result)
111
+ end
112
+
108
113
  def test_show_structured
109
114
  result = client.show('show hostname', :structured)
110
115
  s = @device.cmd('show hostname')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cisco_nxapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Hunsberger
@@ -12,88 +12,88 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-08-25 00:00:00.000000000 Z
15
+ date: 2016-01-14 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: minitest
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - '>='
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: 2.5.1
24
- - - <
24
+ - - "<"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 5.0.0
27
27
  type: :development
28
28
  prerelease: false
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.5.1
34
- - - <
34
+ - - "<"
35
35
  - !ruby/object:Gem::Version
36
36
  version: 5.0.0
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
39
  requirement: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - ~>
41
+ - - "~>"
42
42
  - !ruby/object:Gem::Version
43
43
  version: '1.7'
44
44
  type: :development
45
45
  prerelease: false
46
46
  version_requirements: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ~>
48
+ - - "~>"
49
49
  - !ruby/object:Gem::Version
50
50
  version: '1.7'
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rake
53
53
  requirement: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ~>
55
+ - - "~>"
56
56
  - !ruby/object:Gem::Version
57
57
  version: '10.0'
58
58
  type: :development
59
59
  prerelease: false
60
60
  version_requirements: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - ~>
62
+ - - "~>"
63
63
  - !ruby/object:Gem::Version
64
64
  version: '10.0'
65
65
  - !ruby/object:Gem::Dependency
66
66
  name: rubocop
67
67
  requirement: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0.32'
72
72
  type: :development
73
73
  prerelease: false
74
74
  version_requirements: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0.32'
79
79
  - !ruby/object:Gem::Dependency
80
80
  name: net_http_unix
81
81
  requirement: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - ~>
83
+ - - "~>"
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0.2'
86
- - - '>='
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: 0.2.1
89
89
  type: :runtime
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ~>
93
+ - - "~>"
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0.2'
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: 0.2.1
99
99
  description: |
@@ -104,9 +104,9 @@ executables: []
104
104
  extensions: []
105
105
  extra_rdoc_files: []
106
106
  files:
107
- - .gitignore
108
- - .rubocop.yml
109
- - .rubocop_todo.yml
107
+ - ".gitignore"
108
+ - ".rubocop.yml"
109
+ - ".rubocop_todo.yml"
110
110
  - CHANGELOG.md
111
111
  - CONTRIBUTING.md
112
112
  - Gemfile
@@ -133,17 +133,17 @@ require_paths:
133
133
  - lib
134
134
  required_ruby_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - '>='
141
+ - - ">="
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
145
  rubyforge_project:
146
- rubygems_version: 2.1.11
146
+ rubygems_version: 2.5.0
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Utilities for working with Cisco NX-OS NX-API