You suggestion is in fact what I initially converted the recipe to do, but
I then realized that it did not preserve the behaviour of the system that
would automatically reformat  and readd a disk that did not have either a
partition table or a file system that the barclamp recognized.  The current
code is a comprimise that preserves that properly.


On Tue, Jun 4, 2013 at 4:46 PM, Vincent Untz <notifications@github.com>wrote:

> In chef/data_bags/crowbar/bc-template-swift.json:
>
> > @@ -99,8 +99,8 @@
> >        "admin_ip_expr": "Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, \"admin\").address",
> >        "storage_ip_expr": "Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, \"storage\").address",
> >        "public_ip_expr": "Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, \"public\").address",
> > -      "disk_enum_expr": "node[\"crowbar\"][\"disks\"]",
> > -      "disk_test_expr": "v[\"usage\"] == \"Storage\"",
> > +        "disk_enum_expr": "r = Hash.new; BarclampLibrary::Barclamp::Inventory::Disk.unclaimed(node).each do |d| Chef::Log.info(\"Swift: Not claiming #{d.device}\") unless d.claim(\"Swift\") end; BarclampLibrary::Barclamp::Inventory::Disk.claimed(node,\"Swift\").each do |d| r[d.device]=d end; r",
> > +      "disk_test_expr": "true",
> >        "disk_zone_assign_expr":  "$rack_aware=Rack_awareness::By_switch.new(node) if $rack_aware.nil? ;[ $rack_aware.node_to_zone(params) , 99]"
>
> FWIW, looking at this again, disk_enum_expr should return all unclaimed
> disks, while disk_test_expr should more or less be claiming the disk. This
> matches better what the recipe is expecting, and would likely be a bit
> safer if user change this.
>
> Something like this:
>
> "disk_enum_expr": "r = Hash.new;
> BarclampLibrary::Barclamp::Inventory::Disk.unclaimed(node).each do |d|
> r[d.device] = d end; r"
> "disk_test_expr": "v.claim(\"Swift\")"
>
> Any objection against this approach instead?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/crowbar/barclamp-swift/pull/78/files#r4534149>
> .
>