Bug #43

avatar

amcc.rb issues

Added by Jeremy Miller 2544 days ago. Updated 2540 days ago.

Status:Resolved Start:12/28/2010
Priority:High Due date:
Assigned to:avatarMikhail Yakshin % Done:

0%

Category:-
Target version:-

Description

Hello,

I have worked with one of our in-house developers to isolate and fix a bug with the amcc module.

The issue is as follows:

[root@server ~]# einarc -t amcc physical list
DEBUG: /var/lib/einarc/tools/amcc/cli /c show

Error: (CLI:003) Specified controller does not exist.

There are two fixes, not sure which is best in case one of them breaks something else.

Fix 1)

Edit the amcc.rb file

[root@soluscn27xen raid]# diff -u /usr/lib/ruby/site_ruby/1.8/raid/amcc.rb.orig /usr/lib/ruby/site_ruby/1.8/raid/amcc.rb
--- /usr/lib/ruby/site_ruby/1.8/raid/amcc.rb.orig    2010-12-28 13:27:54.000000000 -0600
+++ /usr/lib/ruby/site_ruby/1.8/raid/amcc.rb    2010-12-28 13:26:00.000000000 -0600
@@ -17,6 +17,7 @@
         SG3INQ = "/usr/bin/sg_inq" 

         def initialize(adapter_num = nil)
+            adapter_num = 0 if (adapter_num.nil? || adapter_num.empty?)
             @adapter_num = adapter_num
         end

2) Edit the einarc binary

usr/local/bin/einarc

adapter_type = adapter_num = nil

changing that to

adapter_type = nil
adapter_num = 0 # the variable name implies an int, not a nil

History

Updated by Jeremy Miller 2544 days ago

avatar

sorry about the formatting on the above, let me know if anything isn't clear

Updated by Jeremy Miller 2543 days ago

avatar

Our developer made things "pretty" so you can see the code changes better:

https://gist.github.com/e0e43e59a48cea506cc7

Updated by Mikhail Yakshin 2543 days ago

avatar
  • Status changed from New to Assigned
  • Assigned to set to Mikhail Yakshin

Thanks for your contribution! I'll try to estimate what's best overall and apply a relevant patch ASAP.

Updated by Mikhail Yakshin 2543 days ago

avatar
  • Status changed from Assigned to Resolved

I've applied a fix in r1861, to enforce a similar model of default value for adapter_num. Please check it out and see if it works for you?

Updated by Justin Mazzi 2543 days ago

avatar

Hey,

That fix will work unless adapter_num contains a space - https://gist.github.com/cbecad65fe07cafb1f0d

Updated by Mikhail Yakshin 2542 days ago

avatar

Justin Mazzi wrote:

That fix will work unless adapter_num contains a space - https://gist.github.com/cbecad65fe07cafb1f0d

This one doesn't work for me as you say. I've checked both Ruby 1.8 and 1.9 - ' '.empty? is false all the time, thus it returns ' ' in all cases.

"nil" value for adapter_num argument in module constructor indeed bears the special meaning - it means that no argument was given from a command line. But why should one really want to make a space (' ') or empty string ('') a special value?

Updated by Justin Mazzi 2542 days ago

avatar

Hey,

If adapter_num is passed in as a space then the script blows up. It executes:

/var/lib/einarc/tools/amcc/cli /c show

which is wrong. If the adapter_num is an empty space it should execute:
/var/lib/einarc/tools/amcc/cli /c0 show

Perhaps strip the adapter_num of white space if it responds_to?(:strip)?

Updated by Mikhail Yakshin 2540 days ago

avatar

I don't really seem much point in special handling of whitespace in `adapter_num`. We might just as well support any other weird data types or special values.

Why exactly do you want to handle space (or whitespace / empty strings) the same way as `nil` value in `adapter_num`? You're using such invocation from some shell script or from Ruby API?

Also available in: Atom PDF