Commit 659023be authored by Florent Didier's avatar Florent Didier
Browse files

[dev] Give unique values to disk property (bug 8260)

Before this commit, the oarsub command:
oarsub -r"2018-01-01 00:00:00" -t noop -l {type='disk'}/disk=1
gives all 1st disks of the cluster when we expect only one disk.

To obtain only one disk, we need to have unique values for property
disk (which was not the case before this commit, see bug 8260).

This commit changes disk property from 1..k (i for disk number i) on
each node, to device_uid.node_uid (ex: sda.grimoire-1) which is unique.
parent 0f2a182a
......@@ -178,12 +178,30 @@ def get_maintenance_property(node)
return maintenance
end
# Returns the expected properties of the reservable disks. These
# properties are then compared with the values in OAR database, to
# generate a diff.
# The key is of the form [node, disk]. In the following example
# we list the different disks (from sdb to sdf) of node grimoire-1.
# {["grimoire-1", "sdb.grimoire-1"]=>
# {"cluster"=>"grimoire",
# "host"=>"grimoire-1.nancy.grid5000.fr",
# "network_address"=>"",
# "available_upto"=>0,
# "deploy"=>"YES",
# "production"=>"NO",
# "maintenance"=>"NO",
# "disk"=>"sdb.grimoire-1",
# "diskpath"=>"/dev/disk/by-path/pci-0000:02:00.0-scsi-0:0:1:0",
# "cpuset"=>-1},
# ["grimoire-1", "sdc.grimoire-1"]=> ...
def get_ref_disk_properties_internal(site_uid, cluster_uid, node_uid, node)
properties = {}
node['storage_devices'].to_a.each_with_index do |v, index|
_device_uid, device = v
device_uid, device = v
disk = [device_uid, node_uid].join('.')
if index > 0 && device['reservation']
key = [node_uid, index]
key = [node_uid, disk]
h = {}
node_address = [node_uid, site_uid, 'grid5000.fr'].join('.')
h['cluster'] = cluster_uid
......@@ -193,7 +211,7 @@ def get_ref_disk_properties_internal(site_uid, cluster_uid, node_uid, node)
h['deploy'] = 'YES'
h['production'] = get_production_property(node)
h['maintenance'] = get_maintenance_property(node)
h['disk'] = index
h['disk'] = disk
h['diskpath'] = device['by_path']
h['cpuset'] = -1
properties[key] = h
......@@ -479,14 +497,14 @@ def oarcmd_create_disk(host, disk)
disk_exist = "disk_exist '#{host}' '#{disk}'"
command = "echo; echo 'Adding disk #{disk} on host #{host}:'\n"
command += "#{disk_exist} && echo '=> disk already exists'\n"
command += "#{disk_exist} || oarnodesetting -a -h '' -p host='#{host}' -p network_address='' -p type='disk' -p disk=#{disk}"
command += "#{disk_exist} || oarnodesetting -a -h '' -p host='#{host}' -p network_address='' -p type='disk' -p disk='#{disk}'"
return command + "\n\n"
end
def oarcmd_set_disk_properties(host, disk, disk_properties)
return '' if disk_properties.size == 0
command = "echo; echo 'Setting properties for disk #{disk} on host #{host}:'; echo\n"
command += "oarnodesetting --sql \"host='#{host}' and type='disk' and disk=#{disk}\" -p "
command += "oarnodesetting --sql \"host='#{host}' and type='disk' and disk='#{disk}'\" -p "
command += properties_internal(disk_properties)
return command + "\n\n"
end
......
......@@ -25,7 +25,7 @@
# },
# }
# {"disk"=>
# {["grimoire-1", 1]=>
# {["grimoire-1", "sdb.grimoire-1"]=>
# {"cluster"=>"grimoire",
# "host"=>"grimoire-1.nancy.grid5000.fr"
# "network_address"="grimoire-1.nancy.grid5000.fr"
......@@ -33,9 +33,9 @@
# "diskpath"=>"/dev/disk/by-path/pci-0000:02:00.0-scsi-0:0:1:0"
# "cpuset"=>"disk-1"
# },
# ["grimoire-1", 2]=>...,
# ["grimoire-1", "sdc.grimoire-1"]=>...,
# ...
# ["grimoire-2", 1]=>...,
# ["grimoire-2", "sdb.grimoire-2"]=>...,
# }
# }
# }
......@@ -389,7 +389,7 @@ if options[:output] || options[:exec]
# Build and output disk commands
site_properties['disk'].each_filtered_node_uid(options[:clusters], options[:nodes]) do |key, disk_properties|
# As an example, key can be equal to 'grimoire-1' for default resources or
# ['grimoire-1', 1] for disk resources (disk n°1 of grimoire-1)
# ['grimoire-1', 'sdb.grimoire-1'] for disk resources (disk sdb of grimoire-1)
node_uid, disk = key
host = [node_uid, site_uid, 'grid5000.fr'].join('.')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment