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
|
def put
|
||||||
headers = {"Content-Type" => "application/json"}
|
headers = {"Content-Type" => "application/json"}
|
||||||
@logger.debug("Trying to put host info into #{@api_url}")
|
@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)
|
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
|
if res.status < 200 or res.status >= 300
|
||||||
@logger.error("HTTP PUT failed: #{res.inspect}")
|
@logger.error("HTTP PUT failed: #{res.inspect}")
|
||||||
end
|
end
|
||||||
@ -141,7 +144,10 @@ class NodeAgent
|
|||||||
def post
|
def post
|
||||||
headers = {"Content-Type" => "application/json"}
|
headers = {"Content-Type" => "application/json"}
|
||||||
@logger.debug("Trying to create host using #{@api_url}")
|
@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)
|
res = htclient.post("#{@api_url}/nodes/", _data.to_json, headers)
|
||||||
|
@logger.debug("Response: status: #{res.status} body: #{res.body}")
|
||||||
res
|
res
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -241,7 +247,8 @@ class NodeAgent
|
|||||||
:name => dname,
|
:name => dname,
|
||||||
:model => binfo[:model],
|
:model => binfo[:model],
|
||||||
:size => (binfo[:size].to_i * block_size),
|
: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
|
||||||
end
|
end
|
||||||
@ -252,16 +259,15 @@ class NodeAgent
|
|||||||
detailed_meta
|
detailed_meta
|
||||||
end
|
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)
|
def _disk_path_by_name(name)
|
||||||
dn = "/dev/disk/by-path"
|
dn = "/dev/disk/by-path"
|
||||||
basepath = Dir["#{dn}/**?"].find{|f| /\/#{name}$/.match(File.readlink(f))}
|
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
|
basepath.split("/")[2..-1].join("/") if basepath
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -302,7 +302,8 @@ class DisksFormatConvertor(object):
|
|||||||
class Disk(object):
|
class Disk(object):
|
||||||
|
|
||||||
def __init__(self, volumes, generator_method, disk_id, name,
|
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
|
"""Create disk
|
||||||
|
|
||||||
:param volumes: volumes which need to allocate on disk
|
:param volumes: volumes which need to allocate on disk
|
||||||
@ -317,6 +318,7 @@ class Disk(object):
|
|||||||
"""
|
"""
|
||||||
self.call_generator = generator_method
|
self.call_generator = generator_method
|
||||||
self.id = disk_id
|
self.id = disk_id
|
||||||
|
self.extra = disk_extra or []
|
||||||
self.name = name
|
self.name = name
|
||||||
self.size = size
|
self.size = size
|
||||||
self.lvm_meta_size = self.call_generator('calc_lvm_meta_size')
|
self.lvm_meta_size = self.call_generator('calc_lvm_meta_size')
|
||||||
@ -519,6 +521,7 @@ class Disk(object):
|
|||||||
def render(self):
|
def render(self):
|
||||||
return {
|
return {
|
||||||
'id': self.id,
|
'id': self.id,
|
||||||
|
'extra': self.extra,
|
||||||
'name': self.name,
|
'name': self.name,
|
||||||
'type': 'disk',
|
'type': 'disk',
|
||||||
'size': self.size,
|
'size': self.size,
|
||||||
@ -571,7 +574,8 @@ class VolumeManager(object):
|
|||||||
byte_to_megabyte(d["size"]),
|
byte_to_megabyte(d["size"]),
|
||||||
boot_is_raid=boot_is_raid,
|
boot_is_raid=boot_is_raid,
|
||||||
# Count of possible PVs equal to count of allowed VGs
|
# 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)
|
self.disks.append(disk)
|
||||||
|
|
||||||
@ -859,36 +863,25 @@ class VolumeManager(object):
|
|||||||
lambda volume: volume['_allocate_size'] == 'full-disk',
|
lambda volume: volume['_allocate_size'] == 'full-disk',
|
||||||
self.allowed_volumes)
|
self.allowed_volumes)
|
||||||
|
|
||||||
def expand_generators(self, cdict):
|
def expand_generators(self, value):
|
||||||
new_dict = {}
|
if isinstance(value, (str, unicode, int, float, long)):
|
||||||
if isinstance(cdict, dict):
|
return value
|
||||||
for i, val in cdict.iteritems():
|
elif isinstance(value, dict):
|
||||||
if type(val) in (str, unicode, int, float):
|
generator = value.get("generator")
|
||||||
new_dict[i] = val
|
generator_args = value.get("generator_args", [])
|
||||||
elif isinstance(val, dict):
|
if generator is not None:
|
||||||
if "generator" in val:
|
genval = self.call_generator(
|
||||||
genval = self.call_generator(
|
generator, *generator_args)
|
||||||
val["generator"],
|
self.__logger(
|
||||||
*(val.get("generator_args", []))
|
'Generator {0} with args {1} expanded to: {2}'.format(
|
||||||
)
|
generator, generator_args, genval))
|
||||||
self.__logger(
|
return genval
|
||||||
'Generator %s with args %s expanded to: %s' %
|
else:
|
||||||
(val['generator'],
|
return {k: self.expand_generators(v)
|
||||||
val.get('generator_args', []),
|
for k, v in value.iteritems()}
|
||||||
genval))
|
elif isinstance(value, list):
|
||||||
|
return [self.expand_generators(i) for i in value]
|
||||||
new_dict[i] = genval
|
return value
|
||||||
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 check_disk_space_for_deployment(self):
|
def check_disk_space_for_deployment(self):
|
||||||
'''Check disks space for minimal installation.
|
'''Check disks space for minimal installation.
|
||||||
|
Loading…
Reference in New Issue
Block a user