brocadesan 0.4.1 → 0.4.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWQzNDA4YmVhZmJiYzgxZWMyYjRjYTRjZmFkZWJmOTljMDQwNGQzNQ==
5
+ data.tar.gz: !binary |-
6
+ MDM5MGY3YWUyOTQ1OGNkYTI3MjY1MmQ5ZDdmM2U1ZjY5YTkzYmY3MA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MmUxN2I2ZDdmNjg5MzA1OTdlYTRkZjMxNmEyNDFjZDYzMzgwNjc3ZDQ1NGUx
10
+ ODIzNDA5YjdkYjFiYzE3ZWU1YjhlYTNjZjIwZjEzODUxMGQ2YzVjMmJiYTQ2
11
+ ZjU4NTAzNjMyMjNhMjI5ZGRiMTNlYThjYTlhOTc5ODU3NTVhNWM=
12
+ data.tar.gz: !binary |-
13
+ M2YwYTczYTRiZTBiZjVmNDhiOTNkMDM3NzZiZjliYzk5NjkwNzQzMDA4YTM2
14
+ YjIwNzE3MzM5NmIzYjVjMWIyMTBjYjNkNzY2NTM3NTkyYWRjN2VjODMwZDcw
15
+ OTBhZGExMWI2MzAzNGE2ZGNkNjEwYTBlNjc3OTY2YTNlMTUwYWU=
@@ -1,14 +1,14 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'brocadesan'
3
- s.version = '0.4.1'
4
- s.date = '2015-02-10'
3
+ s.version = '0.4.8'
4
+ s.date = '2016-02-26'
5
5
  s.summary = "Brocade SAN library"
6
6
  s.description = "Gem to manipulate FABOS based devices"
7
7
  s.authors = ["Tomas Trnecka"]
8
8
  s.email = 'trnecka@gmail.com'
9
9
  s.files = `git ls-files`.split("\n")
10
10
  s.homepage = 'http://rubygems.org/gems/brocadesan'
11
- s.add_runtime_dependency "net-ssh", ">= 2.9.2"
12
- s.add_development_dependency "minitest",[">= 5.0.0"]
13
- s.add_development_dependency "rake-notes",[">= 0.2.0"]
11
+ s.add_runtime_dependency "net-ssh", "~> 2.9"
12
+ s.add_development_dependency "minitest",["~> 5.0"]
13
+ s.add_development_dependency "rake-notes",["~> 0.2"]
14
14
  end
@@ -10,6 +10,10 @@
10
10
  :cmd: switchshow
11
11
  :attr: switch_mode
12
12
  :format: string
13
+ :type:
14
+ :cmd: switchshow
15
+ :attr: switch_type
16
+ :format: string
13
17
  :role:
14
18
  :cmd: switchshow
15
19
  :attr: switch_role
@@ -90,9 +94,17 @@
90
94
  :cmd: "switchstatusshow"
91
95
  :attr: switchstatusshow
92
96
  :format: string
97
+ :maps_status:
98
+ :cmd: "mapsdb --show"
99
+ :attr: current_switch_policy_status
100
+ :format: string
101
+ :maps_status_details:
102
+ :cmd: "mapsdb --show"
103
+ :attr: maps_summary
104
+ :format: string
93
105
  :ip:
94
- :cmd: "switchstatusshow"
95
- :attr: ip_address
106
+ :cmd: "ipaddrshow"
107
+ :attr: ethernet_ip_address
96
108
  :format: string
97
109
  :supportshow:
98
110
  :cmd: "supportshow"
@@ -113,4 +125,12 @@
113
125
  :cfg_transaction:
114
126
  :cmd: "cfgtransshow"
115
127
  :attr: cfg_transaction
116
- :format: hash
128
+ :format: hash
129
+ :principal_mode:
130
+ :cmd: fabricprincipal
131
+ :attr: principal_selection_mode
132
+ :format: string
133
+ :principal_priority:
134
+ :cmd: fabricprincipal
135
+ :attr: principal_switch_selection_priority
136
+ :format: string
@@ -7,6 +7,7 @@
7
7
  :dlsshow: oneline
8
8
  :iodshow: oneline
9
9
  :switchstatusshow: multiline
10
+ :mapsdb: multiline
10
11
  :supportshow: multiline
11
12
  :cfgshow: cfgshow
12
13
  :nsshow: ns
@@ -18,4 +19,6 @@
18
19
  :trunkshow: trunk
19
20
  :cfgtransshow: multiline
20
21
  :zoneshow: cfgshow
21
- :alishow: cfgshow
22
+ :alishow: cfgshow
23
+ :fabricprincipal: multiline
24
+ :ipaddrshow: ipaddrshow
@@ -34,6 +34,9 @@ module Provisioning
34
34
  # Checks as well if the switch is virtual fabric enabled since that defines the way it will be queried further.
35
35
  def self.create(*params)
36
36
  agent=new(*params)
37
+ #TODO revisit this once the v7.3 is installed
38
+ agent.override_vf
39
+ agent
37
40
  end
38
41
 
39
42
  # Queries the agent for ongoing transaction.
@@ -748,9 +751,9 @@ module Provisioning
748
751
  when "delete"
749
752
  ""
750
753
  when "create"
751
- ", \"#{obj.members.join(";")}\""
754
+ ", \'#{obj.members.join(";")}\'"
752
755
  when "remove","add"
753
- ", \"#{member}\""
756
+ ", \'#{member}\'"
754
757
  else
755
758
  ""
756
759
  end
@@ -803,7 +806,7 @@ module Provisioning
803
806
  cmd_part = get_cmd klass, word
804
807
  object_member_part = get_member_part obj, word, member
805
808
  response = script_mode do
806
- query("#{cmd_part} \"#{obj}\"#{object_member_part}")
809
+ query("#{cmd_part} \'#{obj}\'#{object_member_part}")
807
810
  end
808
811
  validate_and_save(response)
809
812
  end
@@ -130,6 +130,12 @@ module SAN
130
130
  @fid = fid.to_i==0 ? 128 : fid.to_i
131
131
  end
132
132
 
133
+ # override VF settings
134
+ # all commands will run only on base switch
135
+ # this is to allow to run certain commands on VF enabled switches untill the fosexec is fixed
136
+ def override_vf
137
+ @configuration[:override_vf]=true
138
+ end
133
139
  # gets the +attr+
134
140
  #
135
141
  # +attr+ has to be speficied in the CMD_MAPPING
@@ -380,7 +386,11 @@ module SAN
380
386
  end
381
387
 
382
388
  def query(*cmds) #:nodoc
383
- cmds.map! {|cmd| fullcmd(cmd)}
389
+ if get_mode=="interactive"
390
+ cmds[0]=fullcmd(cmds[0])
391
+ else
392
+ cmds.map! {|cmd| fullcmd(cmd)}
393
+ end
384
394
  super(*cmds)
385
395
  end
386
396
 
@@ -496,12 +506,12 @@ module SAN
496
506
  end
497
507
 
498
508
  def fullcmd(cmd)
499
- if @configuration[:vf]=="enabled" && @fid
509
+ if @configuration[:vf]=="enabled" && @fid && !@configuration[:override_vf]
500
510
  cmds = cmd.split("|")
501
511
  if cmds.size>1
502
- "fosexec --fid #{@fid} \'#{cmds.shift}\' |#{cmds.join("|")}"
512
+ "fosexec --fid #{@fid} -cmd \'#{cmds.shift}\' |#{cmds.join("|")}"
503
513
  else
504
- "fosexec --fid #{@fid} \'#{cmds.shift}\'"
514
+ "fosexec --fid #{@fid} -cmd \'#{cmds.shift}\'"
505
515
  end
506
516
  else
507
517
  cmd
@@ -568,7 +578,7 @@ module SAN
568
578
  # we detect which command output we parse - commands start with defined prompt on the XML line
569
579
  @parsed[:parsing_position] = case
570
580
  # stripping fosexec, all pipes and ' to get pure command
571
- when line.match(/^#{@prompt}/) then line.gsub(/(fosexec --fid \d+ \')|\'$|\' \|.*$/,"").split(" ")[1]
581
+ when line.match(/^#{@prompt}/) then line.gsub(/(fosexec --fid \d+ -cmd \')|\'$|\' \|.*$/,"").split(" ")[1]
572
582
  else @parsed[:parsing_position]
573
583
  end
574
584
  #some default processing
@@ -605,6 +615,8 @@ module SAN
605
615
  parse_ns(line)
606
616
  when @parsed[:parsing_position].match(/#{PARSER_MAPPING.map{ |k,v| v=='trunk' ? k : nil }.compact.join("|")}/i)
607
617
  parse_trunk(line)
618
+ when @parsed[:parsing_position].match(/#{PARSER_MAPPING.map{ |k,v| v=='ipaddrshow' ? k : nil }.compact.join("|")}/i)
619
+ parse_ipaddrshow(line)
608
620
  end
609
621
  end
610
622
 
@@ -615,24 +627,48 @@ module SAN
615
627
 
616
628
  # parser used to parse commands with multi lines output
617
629
  def parse_multiline(line)
618
- # switchstatusshow
619
- case
620
- when line.match(/^\s*[a-z]+.*:/i)
621
- arr = line.split(":")
622
- @parsed[arr[0].strip.gsub(/\s+/,"_").gsub(/([a-z])([A-Z])/,'\1_\2').downcase.to_sym]=arr[1..-1].join(":").strip
623
- when line.match(/^There is no outstanding/) && @parsed[:parsing_position]=="cfgtransshow"
624
- @parsed[:cfg_transaction] = {:id=>-1, :abortable=>nil, :msg => "no transaction"}
625
- when line.match(/^Current transaction token is (.+)$/) && @parsed[:parsing_position]=="cfgtransshow"
626
- @parsed[:cfg_transaction][:id] = $1
627
- when line.match(/It is(.+)abortable$/) && @parsed[:parsing_position]=="cfgtransshow"
628
- @parsed[:cfg_transaction][:abortable] = $1.match(/not/) ? false : true
630
+ case @parsed[:parsing_position]
631
+ when "mapsdb"
632
+ case
633
+ when line.match(/^Current Switch Policy Status/)
634
+ arr = line.split(":")
635
+ @parsed[arr[0].strip.gsub(/\s+/,"_").gsub(/([a-z])([A-Z])/,'\1_\2').downcase.to_sym]=arr[1..-1].join(":").strip
636
+ when line.match(/Summary Report/)
637
+ @in_maps_summary = true
638
+ when line.match(/Rules Affecting Health/)
639
+ @in_maps_summary = false
640
+ #@parsed[:maps_summary].gsub!(/\n$/,"")
641
+ when @in_maps_summary == true
642
+ return nil if line.match(/^=/)
643
+ @parsed[:maps_summary]||=""
644
+ @parsed[:maps_summary]+=line+"\n"
645
+ end
629
646
  else
630
- #supportshow
631
- @parsed[@parsed[:parsing_position].to_sym]||=""
632
- @parsed[@parsed[:parsing_position].to_sym]+=line+"\n"
647
+ # switchstatusshow
648
+ case
649
+ when line.match(/^\s*[a-z]+.*:/i)
650
+ arr = line.split(":")
651
+ @parsed[arr[0].strip.gsub(/\s+/,"_").gsub(/([a-z])([A-Z])/,'\1_\2').downcase.to_sym]=arr[1..-1].join(":").strip
652
+ when line.match(/^There is no outstanding/) && @parsed[:parsing_position]=="cfgtransshow"
653
+ @parsed[:cfg_transaction] = {:id=>-1, :abortable=>nil, :msg => "no transaction"}
654
+ when line.match(/^Current transaction token is (.+)$/) && @parsed[:parsing_position]=="cfgtransshow"
655
+ @parsed[:cfg_transaction][:id] = $1
656
+ when line.match(/It is(.+)abortable$/) && @parsed[:parsing_position]=="cfgtransshow"
657
+ @parsed[:cfg_transaction][:abortable] = $1.match(/not/) ? false : true
658
+ else
659
+ #supportshow
660
+ @parsed[@parsed[:parsing_position].to_sym]||=""
661
+ @parsed[@parsed[:parsing_position].to_sym]+=line+"\n"
662
+ end
633
663
  end
634
664
  end
635
665
 
666
+ #parser for ipaddrshow
667
+ def parse_ipaddrshow(line)
668
+ if @parsed[:ethernet_ip_address].nil? && line.match(/Ethernet IP Address/)
669
+ @parsed[:ethernet_ip_address] = line.split(":")[1].strip
670
+ end
671
+ end
636
672
  # parser for multiline output where each line is independent
637
673
  def parse_simple(line)
638
674
  case
@@ -26,6 +26,15 @@ class Brocade::SAN::Switch
26
26
  #
27
27
  # Returns value in (string) format
28
28
 
29
+ ##
30
+ # :method: type
31
+ # :call-seq:
32
+ # type(forced=true)
33
+ #
34
+ # If called with +true+ argument it will get the switch_type from the switch instead of cache
35
+ #
36
+ # Returns value in (string) format
37
+
29
38
  ##
30
39
  # :method: role
31
40
  # :call-seq:
@@ -260,4 +269,22 @@ class Brocade::SAN::Switch
260
269
  #
261
270
  # Returns value in (hash) format
262
271
 
272
+ ##
273
+ # :method: principal_mode
274
+ # :call-seq:
275
+ # principal_mode(forced=true)
276
+ #
277
+ # If called with +true+ argument it will get the principal_selection_mode from the switch instead of cache
278
+ #
279
+ # Returns value in (string) format
280
+
281
+ ##
282
+ # :method: principal_priority
283
+ # :call-seq:
284
+ # principal_priority(forced=true)
285
+ #
286
+ # If called with +true+ argument it will get the principal_switch_selection_priority from the switch instead of cache
287
+ #
288
+ # Returns value in (string) format
289
+
263
290
  end
@@ -0,0 +1,3 @@
1
+ > fabricprincipal
2
+ Principal Selection Mode: Enable
3
+ Principal Switch Selection Priority: 0x1
@@ -0,0 +1,3 @@
1
+ :principal_selection_mode: Enable
2
+ :principal_switch_selection_priority: '0x1'
3
+ :parsing_position: end
@@ -0,0 +1,3 @@
1
+ > fabricprincipal
2
+ Principal Selection Mode: Disable
3
+ Principal Switch Selection Priority: 0
@@ -0,0 +1,3 @@
1
+ :principal_selection_mode: Disable
2
+ :principal_switch_selection_priority: '0'
3
+ :parsing_position: end
@@ -0,0 +1,3 @@
1
+ > fosexec --fid 128 -cmd 'fabricprincipal'
2
+ Principal Selection Mode: Disable
3
+ Principal Switch Selection Priority: 0
@@ -0,0 +1,3 @@
1
+ :principal_selection_mode: Disable
2
+ :principal_switch_selection_priority: '0'
3
+ :parsing_position: end
@@ -0,0 +1,7 @@
1
+ > ipaddrshow
2
+
3
+ SWITCH
4
+ Ethernet IP Address: 10.200.1.112
5
+ Ethernet Subnetmask: 255.255.0.0
6
+ Gateway IP Address: 10.200.0.1
7
+ DHCP: Off
@@ -0,0 +1,4 @@
1
+ :ethernet_ip_address: 10.200.1.112
2
+ :parsing_position: end
3
+
4
+
@@ -0,0 +1,21 @@
1
+ > ipaddrshow
2
+
3
+ CHASSIS
4
+ Ethernet IP Address: 10.200.0.153
5
+ Ethernet Subnetmask: 255.255.0.0
6
+
7
+ CP0
8
+ Ethernet IP Address: 10.200.0.151
9
+ Ethernet Subnetmask: 255.255.0.0
10
+ Host Name: PLNPOD2N2ECS001-mgmt06
11
+ Gateway IP Address: 10.200.0.1
12
+
13
+ CP1
14
+ Ethernet IP Address: 10.200.0.152
15
+ Ethernet Subnetmask: 255.255.0.0
16
+ Host Name: PLNPOD2N2ECS001-mgmt07
17
+ Gateway IP Address: 10.200.0.1
18
+ IPv6 Autoconfiguration Enabled: Yes
19
+ Local IPv6 Addresses:
20
+ IPv6 Gateways:
21
+ DHCPv6: Off
@@ -0,0 +1,4 @@
1
+ :ethernet_ip_address: 10.200.0.153
2
+ :parsing_position: end
3
+
4
+
@@ -0,0 +1,32 @@
1
+ > mapsdb --show
2
+
3
+ 1 Dashboard Information:
4
+ =======================
5
+
6
+ DB start time: Mon Jan 25 11:00:04 2016
7
+ Active policy: dflt_base_policy
8
+ Configured Notifications: None
9
+ Quarantined Ports : None
10
+
11
+ 2 Switch Health Report:
12
+ =======================
13
+
14
+ Current Switch Policy Status: HEALTHY
15
+
16
+
17
+ 3.1 Summary Report:
18
+ ===================
19
+
20
+ Category |Today |Last 7 days
21
+ --------------------------------------------------------------------------------
22
+ Fru Health |No Errors |No Errors
23
+ Switch Resource |No Errors |No Errors
24
+
25
+
26
+ 3.2 Rules Affecting Health:
27
+ ===========================
28
+
29
+ Category(Rule Count)|RepeatCount|Rule Name |Execution Time |Object |Triggered Value(Units)|
30
+ ------------------------------------------------------------------------------------------------------------------------
31
+
32
+ MAPS is not Licensed. MAPS extended features are available ONLY with License
@@ -0,0 +1,7 @@
1
+ :current_switch_policy_status: HEALTHY
2
+ :maps_summary: |
3
+ Category |Today |Last 7 days
4
+ --------------------------------------------------------------------------------
5
+ Fru Health |No Errors |No Errors
6
+ Switch Resource |No Errors |No Errors
7
+ :parsing_position: end
@@ -1,4 +1,4 @@
1
- > fosexec --fid 99 'switchshow'
1
+ > fosexec --fid 99 -cmd 'switchshow'
2
2
  switchName: IDAA1C01
3
3
  switchType: 62.3
4
4
  switchState: Online
@@ -21,6 +21,7 @@ class ProvisioningTest < MiniTest::Test
21
21
  def test_device_setup
22
22
  assert_instance_of Provisioning::Agent, @agent
23
23
  assert_equal nil, @agent.instance_variable_get(:@transaction)
24
+ assert @agent.instance_variable_get(:@configuration)[:override_vf]
24
25
 
25
26
  # this hack ensures I can test verify false inside create
26
27
  Provisioning::Agent.class_eval do
@@ -342,12 +343,12 @@ class ProvisioningTest < MiniTest::Test
342
343
  :cmd => "cfgcreate",
343
344
  :member_name => "Zone",
344
345
  :error=>Provisioning::Agent::Error::CFG_BAD,:method=>:cfg_create,
345
- :msg_invalid => "> cfgcreate \"test-04\",\"koza; byk\"\nInvalid name\n",
346
+ :msg_invalid => "> cfgcreate \'test-04\',\'koza; byk\'\nInvalid name\n",
346
347
  :resp_invalid => "Invalid name",
347
- :msg_ok => "> cfgcreate \"test\",\"koza; byk\"\n",
348
+ :msg_ok => "> cfgcreate \'test\',\'koza; byk\'\n",
348
349
  :resp_ok => "",
349
- :msg_duplicate => "> cfgcreate cfg1, zone1\n\"cfg1\" duplicate name\n",
350
- :resp_duplicate => "\"cfg1\" duplicate name",
350
+ :msg_duplicate => "> cfgcreate cfg1, zone1\n\'cfg1\' duplicate name\n",
351
+ :resp_duplicate => "\'cfg1\' duplicate name",
351
352
  :members => zones.map {|z| z.to_s}
352
353
  },
353
354
  {:obj=>Zone.new("zonetest"),
@@ -355,12 +356,12 @@ class ProvisioningTest < MiniTest::Test
355
356
  :cmd => "zonecreate",
356
357
  :member_name => "Alias",
357
358
  :error => Provisioning::Agent::Error::ZONE_BAD,:method=>:zone_create,
358
- :msg_invalid => "> zonecreate \"test-04\",\"koza; byk\"\nInvalid name\n",
359
+ :msg_invalid => "> zonecreate \'test-04\',\'koza; byk\'\nInvalid name\n",
359
360
  :resp_invalid => "Invalid name",
360
- :msg_ok => "> zonecreate \"test\",\"koza; byk\"\n",
361
+ :msg_ok => "> zonecreate \'test\',\'koza; byk\'\n",
361
362
  :resp_ok => "",
362
- :msg_duplicate => "> zonecreate WYN_vls1_node3_fc0, 5B:49:9B:AF:F0:93:00:13\n\"WYN_vls1_node3_fc0\" duplicate name\n",
363
- :resp_duplicate => "\"WYN_vls1_node3_fc0\" duplicate name",
363
+ :msg_duplicate => "> zonecreate WYN_vls1_node3_fc0, 5B:49:9B:AF:F0:93:00:13\n\'WYN_vls1_node3_fc0\' duplicate name\n",
364
+ :resp_duplicate => "\'WYN_vls1_node3_fc0\' duplicate name",
364
365
  :members => als.map {|a| a.to_s}
365
366
  },
366
367
  {:obj=>Alias.new("aliastest"),
@@ -368,12 +369,12 @@ class ProvisioningTest < MiniTest::Test
368
369
  :cmd => "alicreate",
369
370
  :member_name => "Wwn",
370
371
  :error => Provisioning::Agent::Error::ALIAS_BAD,:method=>:alias_create,
371
- :msg_invalid => "> alicreate \"test\",\"50:00; 50:02\"\nInvalid alias\n",
372
+ :msg_invalid => "> alicreate \'test\',\'50:00; 50:02\'\nInvalid alias\n",
372
373
  :resp_invalid => "Invalid alias",
373
- :msg_ok => "> alicreate \"test\",\"50:00; 50:02\"\n",
374
+ :msg_ok => "> alicreate \'test\',\'50:00; 50:02\'\n",
374
375
  :resp_ok => "",
375
- :msg_duplicate => "> alicreate WYN_vls1_node3_fc0, 5B:49:9B:AF:F0:93:00:13\n\"WYN_vls1_node3_fc0\" duplicate name\n",
376
- :resp_duplicate => "\"WYN_vls1_node3_fc0\" duplicate name",
376
+ :msg_duplicate => "> alicreate WYN_vls1_node3_fc0, 5B:49:9B:AF:F0:93:00:13\n\'WYN_vls1_node3_fc0\' duplicate name\n",
377
+ :resp_duplicate => "\'WYN_vls1_node3_fc0\' duplicate name",
377
378
  :members => wwns.map {|w| w.to_s}
378
379
  }
379
380
  ]
@@ -432,7 +433,7 @@ class ProvisioningTest < MiniTest::Test
432
433
  @agent.query_stub do
433
434
  assert_equal obj[:obj], @agent.send(:obj_create,obj[:obj],obj[:klass])
434
435
  # checks the cmd sent to query
435
- assert_equal "#{obj[:cmd]} \"#{obj[:obj].name}\", \"#{obj[:obj].members.join(";")}\"", @agent.instance_variable_get(:@query_string)
436
+ assert_equal "#{obj[:cmd]} \'#{obj[:obj].name}\', \'#{obj[:obj].members.join(";")}\'", @agent.instance_variable_get(:@query_string)
436
437
  end
437
438
  end
438
439
 
@@ -485,9 +486,9 @@ class ProvisioningTest < MiniTest::Test
485
486
  :member_name => "Zone",
486
487
  :error=>Provisioning::Agent::Error::CFG_BAD,
487
488
  :method=>:cfg_delete,
488
- :msg_not_found => "> cfgdelete \"test\"\nnot found\n",
489
+ :msg_not_found => "> cfgdelete \'test\'\nnot found\n",
489
490
  :resp_not_found => "not found",
490
- :msg_ok => "> cfgedelete \"test\"\n",
491
+ :msg_ok => "> cfgedelete \'test\'\n",
491
492
  :resp_ok => ""
492
493
  },
493
494
  {:obj=>Zone.new("zonetest"),
@@ -496,9 +497,9 @@ class ProvisioningTest < MiniTest::Test
496
497
  :member_name => "Alias",
497
498
  :error => Provisioning::Agent::Error::ZONE_BAD,
498
499
  :method=>:zone_delete,
499
- :msg_not_found => "> zonedelete \"test\"\nnot found\n",
500
+ :msg_not_found => "> zonedelete \'test\'\nnot found\n",
500
501
  :resp_not_found => "not found",
501
- :msg_ok => "> zonedelete \"test\"\n",
502
+ :msg_ok => "> zonedelete \'test\'\n",
502
503
  :resp_ok => ""
503
504
  },
504
505
  {:obj=>Alias.new("aliastest"),
@@ -507,9 +508,9 @@ class ProvisioningTest < MiniTest::Test
507
508
  :member_name => "Wwn",
508
509
  :error => Provisioning::Agent::Error::ALIAS_BAD,
509
510
  :method=>:alias_delete,
510
- :msg_not_found => "> alidelete \"test\"\nnot found\n",
511
+ :msg_not_found => "> alidelete \'test\'\nnot found\n",
511
512
  :resp_not_found => "not found",
512
- :msg_ok => "> alidelete \"test\"\n",
513
+ :msg_ok => "> alidelete \'test\'\n",
513
514
  :resp_ok => ""
514
515
  }
515
516
  ]
@@ -554,7 +555,7 @@ class ProvisioningTest < MiniTest::Test
554
555
  @agent.query_stub do
555
556
  assert_equal obj[:obj], @agent.send(:obj_delete,obj[:obj],obj[:klass])
556
557
  # checks the cmd sent to query
557
- assert_equal "#{obj[:cmd]} \"#{obj[:obj].name}\"", @agent.instance_variable_get(:@query_string)
558
+ assert_equal "#{obj[:cmd]} \'#{obj[:obj].name}\'", @agent.instance_variable_get(:@query_string)
558
559
  end
559
560
  end
560
561
  end
@@ -576,7 +577,7 @@ class ProvisioningTest < MiniTest::Test
576
577
  :method => :alias_change
577
578
  }
578
579
  ]
579
- @response.data="> alidelete \"test\"\n"
580
+ @response.data="> alidelete \'test\'\n"
580
581
  objs.each do |obj|
581
582
  @agent.multistub [
582
583
  [:check_for_running_transaction, false],
@@ -590,11 +591,11 @@ class ProvisioningTest < MiniTest::Test
590
591
  @agent.query_stub do
591
592
  assert_equal obj[:obj], @agent.send(:obj_change,obj[:obj],obj[:klass])
592
593
  # checks the cmd sent to query
593
- assert_equal "#{obj[:queries][0]} \"#{obj[:obj].name}\"#{obj[:queries][1]} \"#{obj[:obj].name}\", \"#{obj[:obj].members.join(";")}\"", @agent.instance_variable_get(:@query_string)
594
+ assert_equal "#{obj[:queries][0]} \'#{obj[:obj].name}\'#{obj[:queries][1]} \'#{obj[:obj].name}\', \'#{obj[:obj].members.join(";")}\'", @agent.instance_variable_get(:@query_string)
594
595
  @agent.instance_variable_set(:@query_string,"")
595
596
  # test wrapper method
596
597
  @agent.send obj[:method],obj[:obj]
597
- assert_equal "#{obj[:queries][0]} \"#{obj[:obj].name}\"#{obj[:queries][1]} \"#{obj[:obj].name}\", \"#{obj[:obj].members.join(";")}\"", @agent.instance_variable_get(:@query_string)
598
+ assert_equal "#{obj[:queries][0]} \'#{obj[:obj].name}\'#{obj[:queries][1]} \'#{obj[:obj].name}\', \'#{obj[:obj].members.join(";")}\'", @agent.instance_variable_get(:@query_string)
598
599
  end
599
600
  end
600
601
  end
@@ -612,9 +613,9 @@ class ProvisioningTest < MiniTest::Test
612
613
  :error=>Provisioning::Agent::Error::CFG_BAD,
613
614
  :error_member => Provisioning::Agent::Error::ZONE_BAD,
614
615
  :method=>:cfg_remove,
615
- :msg_not_found => "> cfgremove \"zctest\",\"zonetest\"\nnot found\n",
616
+ :msg_not_found => "> cfgremove \'zctest\',\'zonetest\'\nnot found\n",
616
617
  :resp_not_found => "not found",
617
- :msg_ok => "> cfgremove \"zctest\",\"zonetest\"\n",
618
+ :msg_ok => "> cfgremove \'zctest\',\'zonetest\'\n",
618
619
  :resp_ok => ""
619
620
  },
620
621
  {:obj=>Zone.new("zonetest"),
@@ -627,9 +628,9 @@ class ProvisioningTest < MiniTest::Test
627
628
  :error => Provisioning::Agent::Error::ZONE_BAD,
628
629
  :error_member => Provisioning::Agent::Error::MEMBER_BAD,
629
630
  :method=>:zone_remove,
630
- :msg_not_found => "> zoneremove \"zonename\",\"aliastest\"\nnot found\n",
631
+ :msg_not_found => "> zoneremove \'zonename\',\'aliastest\'\nnot found\n",
631
632
  :resp_not_found => "not found",
632
- :msg_ok => "> zoneremove \"zonename\",\"aliastest\"\n",
633
+ :msg_ok => "> zoneremove \'zonename\',\'aliastest\'\n",
633
634
  :resp_ok => ""
634
635
  },
635
636
  {:obj=>Alias.new("aliastest"),
@@ -642,9 +643,9 @@ class ProvisioningTest < MiniTest::Test
642
643
  :error => Provisioning::Agent::Error::ALIAS_BAD,
643
644
  :error_member => Provisioning::Agent::Error::ALIAS_MEMBER_BAD,
644
645
  :method=>:alias_remove,
645
- :msg_not_found => "> aliremove \"aliastest\",\"50:00; 50:02\"\nnot found\n",
646
+ :msg_not_found => "> aliremove \'aliastest\',\'50:00; 50:02\'\nnot found\n",
646
647
  :resp_not_found => "not found",
647
- :msg_ok => "> aliremove \"aliastest\",\"50:00; 50:02\"\n",
648
+ :msg_ok => "> aliremove \'aliastest\',\'50:00; 50:02\'\n",
648
649
  :resp_ok => ""
649
650
  }
650
651
  ]
@@ -697,11 +698,11 @@ class ProvisioningTest < MiniTest::Test
697
698
  @agent.query_stub do
698
699
  obj[:members_ok].each do |mem_ok|
699
700
  assert_equal obj[:obj], @agent.send(:obj_remove,obj[:obj],obj[:klass],mem_ok)
700
- assert_equal "#{obj[:cmd]} \"#{obj[:obj].name}\", \"#{mem_ok}\"", @agent.instance_variable_get(:@query_string)
701
+ assert_equal "#{obj[:cmd]} \'#{obj[:obj].name}\', \'#{mem_ok}\'", @agent.instance_variable_get(:@query_string)
701
702
  @agent.instance_variable_set(:@query_string,"")
702
703
  # test wrapper method
703
704
  @agent.send obj[:method],obj[:obj],mem_ok
704
- assert_equal "#{obj[:cmd]} \"#{obj[:obj].name}\", \"#{mem_ok}\"", @agent.instance_variable_get(:@query_string)
705
+ assert_equal "#{obj[:cmd]} \'#{obj[:obj].name}\', \'#{mem_ok}\'", @agent.instance_variable_get(:@query_string)
705
706
  @agent.instance_variable_set(:@query_string,"")
706
707
  end
707
708
  end
@@ -735,9 +736,9 @@ class ProvisioningTest < MiniTest::Test
735
736
  :error=>Provisioning::Agent::Error::CFG_BAD,
736
737
  :error_member => Provisioning::Agent::Error::ZONE_BAD,
737
738
  :method=>:cfg_add,
738
- :msg_not_found => "> cfgadd \"zctest\",\"zonetest\"\nnot found\n",
739
+ :msg_not_found => "> cfgadd \'zctest\',\'zonetest\'\nnot found\n",
739
740
  :resp_not_found => "not found",
740
- :msg_ok => "> cfgadd \"zctest\",\"zonetest\"\n",
741
+ :msg_ok => "> cfgadd \'zctest\',\'zonetest\'\n",
741
742
  :resp_ok => ""
742
743
  },
743
744
  {:obj=>Zone.new("zonetest"),
@@ -750,9 +751,9 @@ class ProvisioningTest < MiniTest::Test
750
751
  :error => Provisioning::Agent::Error::ZONE_BAD,
751
752
  :error_member => Provisioning::Agent::Error::MEMBER_BAD,
752
753
  :method=>:zone_add,
753
- :msg_not_found => "> zoneadd \"zonename\",\"aliastest\"\nnot found\n",
754
+ :msg_not_found => "> zoneadd \'zonename\',\'aliastest\'\nnot found\n",
754
755
  :resp_not_found => "not found",
755
- :msg_ok => "> zoneadd \"zonename\",\"aliastest\"\n",
756
+ :msg_ok => "> zoneadd \'zonename\',\'aliastest\'\n",
756
757
  :resp_ok => ""
757
758
  },
758
759
  {:obj=>Alias.new("aliastest"),
@@ -765,9 +766,9 @@ class ProvisioningTest < MiniTest::Test
765
766
  :error => Provisioning::Agent::Error::ALIAS_BAD,
766
767
  :error_member => Provisioning::Agent::Error::ALIAS_MEMBER_BAD,
767
768
  :method=>:alias_add,
768
- :msg_not_found => "> aliadd \"aliastest\",\"50:00; 50:02\"\nnot found\n",
769
+ :msg_not_found => "> aliadd \'aliastest\',\'50:00; 50:02\'\nnot found\n",
769
770
  :resp_not_found => "not found",
770
- :msg_ok => "> aliadd \"aliastest\",\"50:00; 50:02\"\n",
771
+ :msg_ok => "> aliadd \'aliastest\',\'50:00; 50:02\'\n",
771
772
  :resp_ok => ""
772
773
  }
773
774
  ]
@@ -820,11 +821,11 @@ class ProvisioningTest < MiniTest::Test
820
821
  @agent.query_stub do
821
822
  obj[:members_ok].each do |mem_ok|
822
823
  assert_equal obj[:obj], @agent.send(:obj_add,obj[:obj],obj[:klass],mem_ok)
823
- assert_equal "#{obj[:cmd]} \"#{obj[:obj].name}\", \"#{mem_ok}\"", @agent.instance_variable_get(:@query_string)
824
+ assert_equal "#{obj[:cmd]} \'#{obj[:obj].name}\', \'#{mem_ok}\'", @agent.instance_variable_get(:@query_string)
824
825
  @agent.instance_variable_set(:@query_string,"")
825
826
  # test wrapper method
826
827
  @agent.send obj[:method],obj[:obj],mem_ok
827
- assert_equal "#{obj[:cmd]} \"#{obj[:obj].name}\", \"#{mem_ok}\"", @agent.instance_variable_get(:@query_string)
828
+ assert_equal "#{obj[:cmd]} \'#{obj[:obj].name}\', \'#{mem_ok}\'", @agent.instance_variable_get(:@query_string)
828
829
  @agent.instance_variable_set(:@query_string,"")
829
830
  end
830
831
  end
@@ -878,7 +879,7 @@ class ProvisioningTest < MiniTest::Test
878
879
  }
879
880
  ]
880
881
  # some ok response
881
- @response.data="> alidelete \"test\"\n"
882
+ @response.data="> alidelete \'test\'\n"
882
883
  objs.each do |obj|
883
884
  @agent.multistub [
884
885
  [:check_for_running_transaction, false],
@@ -893,11 +894,11 @@ class ProvisioningTest < MiniTest::Test
893
894
  @agent.query_stub do
894
895
  assert_equal obj[:obj], @agent.send(:obj_purge,obj[:obj],obj[:klass])
895
896
  # checks the cmd sent to query
896
- assert_equal "#{obj[:queries][0]} \"#{obj[:parents][0]}\", \"#{obj[:obj]}\"#{obj[:queries][1]} \"#{obj[:obj]}\"", @agent.instance_variable_get(:@query_string)
897
+ assert_equal "#{obj[:queries][0]} \'#{obj[:parents][0]}\', \'#{obj[:obj]}\'#{obj[:queries][1]} \'#{obj[:obj]}\'", @agent.instance_variable_get(:@query_string)
897
898
  @agent.instance_variable_set(:@query_string,"")
898
899
  # test wrapper method
899
900
  @agent.send obj[:method],obj[:obj]
900
- assert_equal "#{obj[:queries][0]} \"#{obj[:parents][0]}\", \"#{obj[:obj]}\"#{obj[:queries][1]} \"#{obj[:obj]}\"", @agent.instance_variable_get(:@query_string)
901
+ assert_equal "#{obj[:queries][0]} \'#{obj[:parents][0]}\', \'#{obj[:obj]}\'#{obj[:queries][1]} \'#{obj[:obj]}\'", @agent.instance_variable_get(:@query_string)
901
902
  end
902
903
  end
903
904
  end
@@ -1040,4 +1041,4 @@ class ProvisioningTest < MiniTest::Test
1040
1041
  end
1041
1042
  end
1042
1043
 
1043
- end; end
1044
+ end; end
@@ -6,6 +6,7 @@ module Brocade module SAN
6
6
 
7
7
  class SwitchTest < MiniTest::Test
8
8
  include OutputReader
9
+ include SshStoryWriter
9
10
  include Mock::Net::SSH
10
11
  patch_set
11
12
 
@@ -17,6 +18,11 @@ class SwitchTest < MiniTest::Test
17
18
  @device = Switch.new("test","test","test")
18
19
  end
19
20
 
21
+ def test_override_vf
22
+ @device.override_vf
23
+ assert @device.instance_variable_get(:@configuration)[:override_vf]
24
+ end
25
+
20
26
  def test_query
21
27
  response=@device.query("test")
22
28
  assert_instance_of Switch::Response, response
@@ -33,6 +39,24 @@ class SwitchTest < MiniTest::Test
33
39
  end
34
40
  end
35
41
 
42
+ def test_interactive_query
43
+ cmds = ["fosexec --fid 99 -cmd 'cfgsave'","y"]
44
+ replies = ["confirm? [y,n]"]
45
+ exp_response = write_interactive_story(cmds,replies,TestDevice::DEFAULT_QUERY_PROMPT)
46
+
47
+ @device.set_mode("interactive")
48
+ @device.set_context 99
49
+ # connection is net/ssh/test method
50
+ @device.instance_variable_set(:@session,connection)
51
+
52
+ response=nil
53
+ assert_scripted do
54
+ response=@device.query("cfgsave","y")
55
+ assert_equal exp_response, response.data
56
+ end
57
+
58
+ end
59
+
36
60
  def test_device_setup
37
61
  assert_instance_of Switch, @device
38
62
  end
@@ -138,15 +162,21 @@ class SwitchTest < MiniTest::Test
138
162
 
139
163
  #vf enabled and fid given
140
164
  @device.set_context 99
141
- assert_equal "fosexec --fid 99 \'test\'", @device.send(:fullcmd,"test")
165
+ assert_equal "fosexec --fid 99 -cmd \'test\'", @device.send(:fullcmd,"test")
142
166
 
143
167
  #vf enabled and fid given and piped commnad
144
168
  @device.set_context 99
145
- assert_equal "fosexec --fid 99 \'test\' |grep shit", @device.send(:fullcmd,"test|grep shit")
169
+ assert_equal "fosexec --fid 99 -cmd \'test\' |grep shit", @device.send(:fullcmd,"test|grep shit")
146
170
 
147
171
  #vf enabled and fid given and piped commnad
148
172
  @device.set_context 99
149
- assert_equal "fosexec --fid 99 \'test\' | grep shit| grep shit2", @device.send(:fullcmd,"test| grep shit| grep shit2")
173
+ assert_equal "fosexec --fid 99 -cmd \'test\' | grep shit| grep shit2", @device.send(:fullcmd,"test| grep shit| grep shit2")
174
+
175
+ #vf enabled and fid given and override
176
+ @device.set_context 99
177
+ @device.override_vf
178
+ assert_equal "test", @device.send(:fullcmd,"test")
179
+
150
180
  end
151
181
 
152
182
  def test_zone_cfgs_and_effective_cfg_and_zones
metadata CHANGED
@@ -1,64 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brocadesan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
5
- prerelease:
4
+ version: 0.4.8
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tomas Trnecka
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-02-10 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: net-ssh
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 2.9.2
19
+ version: '2.9'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 2.9.2
26
+ version: '2.9'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: minitest
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: 5.0.0
33
+ version: '5.0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: 5.0.0
40
+ version: '5.0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake-notes
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: 0.2.0
47
+ version: '0.2'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: 0.2.0
54
+ version: '0.2'
62
55
  description: Gem to manipulate FABOS based devices
63
56
  email: trnecka@gmail.com
64
57
  executables: []
@@ -107,16 +100,28 @@ files:
107
100
  - test/outputs/dlsshow_1.yml
108
101
  - test/outputs/dlsshow_2.txt
109
102
  - test/outputs/dlsshow_2.yml
103
+ - test/outputs/fabricprincipal_1.txt
104
+ - test/outputs/fabricprincipal_1.yml
105
+ - test/outputs/fabricprincipal_2.txt
106
+ - test/outputs/fabricprincipal_2.yml
107
+ - test/outputs/fabricprincipal_3.txt
108
+ - test/outputs/fabricprincipal_3.yml
110
109
  - test/outputs/fabricshow_1.txt
111
110
  - test/outputs/fabricshow_1.yml
112
111
  - test/outputs/iodshow_1.txt
113
112
  - test/outputs/iodshow_1.yml
113
+ - test/outputs/ipaddrshow_1.txt
114
+ - test/outputs/ipaddrshow_1.yml
115
+ - test/outputs/ipaddrshow_2.txt
116
+ - test/outputs/ipaddrshow_2.yml
114
117
  - test/outputs/islshow_1.txt
115
118
  - test/outputs/islshow_1.yml
116
119
  - test/outputs/islshow_2.txt
117
120
  - test/outputs/islshow_2.yml
118
121
  - test/outputs/lscfg_show_1.txt
119
122
  - test/outputs/lscfg_show_1.yml
123
+ - test/outputs/mapsdbshow_1.txt
124
+ - test/outputs/mapsdbshow_1.yml
120
125
  - test/outputs/ns_1.txt
121
126
  - test/outputs/ns_1.yml
122
127
  - test/outputs/ns_2.txt
@@ -145,26 +150,25 @@ files:
145
150
  - test/zone_test.rb
146
151
  homepage: http://rubygems.org/gems/brocadesan
147
152
  licenses: []
153
+ metadata: {}
148
154
  post_install_message:
149
155
  rdoc_options: []
150
156
  require_paths:
151
157
  - lib
152
158
  required_ruby_version: !ruby/object:Gem::Requirement
153
- none: false
154
159
  requirements:
155
160
  - - ! '>='
156
161
  - !ruby/object:Gem::Version
157
162
  version: '0'
158
163
  required_rubygems_version: !ruby/object:Gem::Requirement
159
- none: false
160
164
  requirements:
161
165
  - - ! '>='
162
166
  - !ruby/object:Gem::Version
163
167
  version: '0'
164
168
  requirements: []
165
169
  rubyforge_project:
166
- rubygems_version: 1.8.24
170
+ rubygems_version: 2.3.0
167
171
  signing_key:
168
- specification_version: 3
172
+ specification_version: 4
169
173
  summary: Brocade SAN library
170
174
  test_files: []