Added extra field into node disks
Extra parameters, which actually are the id names of hard drives, allow to find them under ubuntu kernel. Closes-bug: #1277151 Change-Id: I01c0a3cd47ebf0ec8f8a723321ca8452c623994e
This commit is contained in:
parent
a88ce37dc1
commit
44195acbea
22
bin/agent
22
bin/agent
@ -131,7 +131,10 @@ class NodeAgent
|
||||
def put
|
||||
headers = {"Content-Type" => "application/json"}
|
||||
@logger.debug("Trying to put host info into #{@api_url}")
|
||||
@logger.debug("Headers: #{headers}")
|
||||
@logger.debug("Data: #{[_data].to_json}")
|
||||
res = htclient.put("#{@api_url}/nodes/", [_data].to_json, headers)
|
||||
@logger.debug("Response: status: #{res.status} body: #{res.body}")
|
||||
if res.status < 200 or res.status >= 300
|
||||
@logger.error("HTTP PUT failed: #{res.inspect}")
|
||||
end
|
||||
@ -141,7 +144,10 @@ class NodeAgent
|
||||
def post
|
||||
headers = {"Content-Type" => "application/json"}
|
||||
@logger.debug("Trying to create host using #{@api_url}")
|
||||
@logger.debug("Headers: #{headers}")
|
||||
@logger.debug("Data: #{_data.to_json}")
|
||||
res = htclient.post("#{@api_url}/nodes/", _data.to_json, headers)
|
||||
@logger.debug("Response: status: #{res.status} body: #{res.body}")
|
||||
res
|
||||
end
|
||||
|
||||
@ -241,7 +247,8 @@ class NodeAgent
|
||||
:name => dname,
|
||||
:model => binfo[:model],
|
||||
:size => (binfo[:size].to_i * block_size),
|
||||
:disk => _disk_path_by_name(dname) || dname
|
||||
:disk => _disk_path_by_name(dname) || dname,
|
||||
:extra => _disk_id_by_name(dname) || []
|
||||
}
|
||||
end
|
||||
end
|
||||
@ -252,16 +259,15 @@ class NodeAgent
|
||||
detailed_meta
|
||||
end
|
||||
|
||||
def _disk_id_by_name(name)
|
||||
dn = "/dev/disk/by-id"
|
||||
basepath = Dir["#{dn}/**?"].select{|f| /\/#{name}$/.match(File.readlink(f))}
|
||||
basepath.map{|p| p.split("/")[2..-1].join("/")}
|
||||
end
|
||||
|
||||
def _disk_path_by_name(name)
|
||||
dn = "/dev/disk/by-path"
|
||||
basepath = Dir["#{dn}/**?"].find{|f| /\/#{name}$/.match(File.readlink(f))}
|
||||
# It is to address the issue which appears when centos
|
||||
# udev names smart array devices like this
|
||||
# /dev/disk/by-path/pci-0000:06:00.0-cciss-disk0
|
||||
# and debian-installer udev names them like this
|
||||
# /dev/disk/by-path/pci-0000:06:00.0 and can not
|
||||
# find device.
|
||||
basepath.sub!(/-cciss-.+/, '')
|
||||
basepath.split("/")[2..-1].join("/") if basepath
|
||||
end
|
||||
|
||||
|
@ -302,7 +302,8 @@ class DisksFormatConvertor(object):
|
||||
class Disk(object):
|
||||
|
||||
def __init__(self, volumes, generator_method, disk_id, name,
|
||||
size, boot_is_raid=True, possible_pvs_count=0):
|
||||
size, boot_is_raid=True, possible_pvs_count=0,
|
||||
disk_extra=None):
|
||||
"""Create disk
|
||||
|
||||
:param volumes: volumes which need to allocate on disk
|
||||
@ -317,6 +318,7 @@ class Disk(object):
|
||||
"""
|
||||
self.call_generator = generator_method
|
||||
self.id = disk_id
|
||||
self.extra = disk_extra or []
|
||||
self.name = name
|
||||
self.size = size
|
||||
self.lvm_meta_size = self.call_generator('calc_lvm_meta_size')
|
||||
@ -519,6 +521,7 @@ class Disk(object):
|
||||
def render(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'extra': self.extra,
|
||||
'name': self.name,
|
||||
'type': 'disk',
|
||||
'size': self.size,
|
||||
@ -571,7 +574,8 @@ class VolumeManager(object):
|
||||
byte_to_megabyte(d["size"]),
|
||||
boot_is_raid=boot_is_raid,
|
||||
# Count of possible PVs equal to count of allowed VGs
|
||||
possible_pvs_count=len(only_vg(self.allowed_volumes)))
|
||||
possible_pvs_count=len(only_vg(self.allowed_volumes)),
|
||||
disk_extra=d.get("extra", []))
|
||||
|
||||
self.disks.append(disk)
|
||||
|
||||
@ -859,36 +863,25 @@ class VolumeManager(object):
|
||||
lambda volume: volume['_allocate_size'] == 'full-disk',
|
||||
self.allowed_volumes)
|
||||
|
||||
def expand_generators(self, cdict):
|
||||
new_dict = {}
|
||||
if isinstance(cdict, dict):
|
||||
for i, val in cdict.iteritems():
|
||||
if type(val) in (str, unicode, int, float):
|
||||
new_dict[i] = val
|
||||
elif isinstance(val, dict):
|
||||
if "generator" in val:
|
||||
genval = self.call_generator(
|
||||
val["generator"],
|
||||
*(val.get("generator_args", []))
|
||||
)
|
||||
self.__logger(
|
||||
'Generator %s with args %s expanded to: %s' %
|
||||
(val['generator'],
|
||||
val.get('generator_args', []),
|
||||
genval))
|
||||
|
||||
new_dict[i] = genval
|
||||
else:
|
||||
new_dict[i] = self.expand_generators(val)
|
||||
elif isinstance(val, list):
|
||||
new_dict[i] = []
|
||||
for d in val:
|
||||
new_dict[i].append(self.expand_generators(d))
|
||||
elif isinstance(cdict, list):
|
||||
new_dict = []
|
||||
for d in cdict:
|
||||
new_dict.append(self.expand_generators(d))
|
||||
return new_dict
|
||||
def expand_generators(self, value):
|
||||
if isinstance(value, (str, unicode, int, float, long)):
|
||||
return value
|
||||
elif isinstance(value, dict):
|
||||
generator = value.get("generator")
|
||||
generator_args = value.get("generator_args", [])
|
||||
if generator is not None:
|
||||
genval = self.call_generator(
|
||||
generator, *generator_args)
|
||||
self.__logger(
|
||||
'Generator {0} with args {1} expanded to: {2}'.format(
|
||||
generator, generator_args, genval))
|
||||
return genval
|
||||
else:
|
||||
return {k: self.expand_generators(v)
|
||||
for k, v in value.iteritems()}
|
||||
elif isinstance(value, list):
|
||||
return [self.expand_generators(i) for i in value]
|
||||
return value
|
||||
|
||||
def check_disk_space_for_deployment(self):
|
||||
'''Check disks space for minimal installation.
|
||||
|
Loading…
Reference in New Issue
Block a user