From 0fb17b83ca25c3974c557794cae8e1b06f8c6360 Mon Sep 17 00:00:00 2001 From: Ryan Moe Date: Tue, 10 Dec 2013 15:48:29 -0800 Subject: [PATCH] Add cciss device numbers to nailgun agent Change-Id: I1cc9d7579855ca9e069179d914efa0609546f14b Closes-bug: #1259612 --- bin/agent | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/agent b/bin/agent index 4761fdecd5..46fa5eca60 100755 --- a/bin/agent +++ b/bin/agent @@ -260,8 +260,13 @@ class NodeAgent Dir["/sys/block/*"].each do |block_device_dir| basename_dir = File.basename(block_device_dir) + # Entries in /sys/block for cciss look like cciss!c0d1 while + # the entries in /dev look like /dev/cciss/c0d1. udevadm uses + # the entry in /dev so we need to replace the ! to get a valid + # device name. + devname = basename_dir.gsub(/!/, '/') - properties = `udevadm info --query=property --export --name=#{basename_dir}`.inject({}) do |result, raw_propety| + properties = `udevadm info --query=property --export --name=#{devname}`.inject({}) do |result, raw_propety| key, value = raw_propety.split(/\=/) result.update(key.strip => value.strip.chomp("'").reverse.chomp("'").reverse) end @@ -271,7 +276,9 @@ class NodeAgent end # look at https://github.com/torvalds/linux/blob/master/Documentation/devices.txt # KVM virtio volumes has code 252 in CentOS, but 253 in Ubuntu - if [3, 8, 202, 252, 253].include?(properties['MAJOR'].to_i) && removable =~ /^0$/ + # Please also update the device codes here + # https://github.com/stackforge/fuel-astute/blob/master/mcagents/erase_node.rb#L81 + if [3, 8, 104, 105, 106, 107, 108, 109, 110, 111, 202, 252, 253].include?(properties['MAJOR'].to_i) && removable =~ /^0$/ # Exclude LVM volumes (in CentOS - 253, in Ubuntu - 252) using additional check @blocks << basename_dir unless properties['DEVPATH'].include?('virtual') end