It really is not that simple.  Making a library of code that can be shared
between the crowbar framework and the nodes during chef-client runs is
nontrivial -- all the code running in Crowbar is running under a Rails app
on the admin node, code running in the context of a chef-client run
(BarclampLibrary, in this instance) is pushed from the chef-server onto the
nodes on demand, and there is no easy way to share code between them.

Please accept that I have been hacking on Crowbar for over 2 years now, and
might have a tiny clue about these sorts of things.


On Tue, Jun 4, 2013 at 4:20 PM, Vincent Untz <notifications@github.com>wrote:

> In crowbar_framework/app/models/node_object.rb:
>
> > @@ -339,11 +339,13 @@ def virtual?
> >    end
> >
> >    def number_of_drives
> > -    self.crowbar['crowbar']['disks'].length rescue -1
> > +    @node[:block_device].find_all do |disk,data|
> > +      disk =~ /^[hsv]d/ && data[:removable] == "0"
> > +    end.length
>
> Really, it's just adding a simple method somewhere that would take two
> arguments. And the reason to do this is to not duplicate this code, which
> might look trivial until we will need to change it and somebody will only
> update it in one place. This is the kind of stuff we should do to keep the
> code maintainable in the long term ;-)
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/crowbar/barclamp-crowbar/pull/522/files#r4533529>
> .
>