Revision bc5d0215 lib/objects.py
b/lib/objects.py | ||
---|---|---|
110 | 110 |
del target[constants.BE_MEMORY] |
111 | 111 |
|
112 | 112 |
|
113 |
def UpgradeDiskParams(diskparams): |
|
114 |
"""Upgrade the disk parameters. |
|
115 |
|
|
116 |
@type diskparams: dict |
|
117 |
@param diskparams: disk parameters to upgrade |
|
118 |
@rtype: dict |
|
119 |
@return: the upgraded disk parameters dit |
|
120 |
|
|
121 |
""" |
|
122 |
result = dict() |
|
123 |
if diskparams is None: |
|
124 |
result = constants.DISK_DT_DEFAULTS.copy() |
|
125 |
else: |
|
126 |
# Update the disk parameter values for each disk template. |
|
127 |
# The code iterates over constants.DISK_TEMPLATES because new templates |
|
128 |
# might have been added. |
|
129 |
for template in constants.DISK_TEMPLATES: |
|
130 |
if template not in diskparams: |
|
131 |
result[template] = constants.DISK_DT_DEFAULTS[template].copy() |
|
132 |
else: |
|
133 |
result[template] = FillDict(constants.DISK_DT_DEFAULTS[template], |
|
134 |
diskparams[template]) |
|
135 |
|
|
136 |
return result |
|
137 |
|
|
138 |
|
|
113 | 139 |
class ConfigObject(object): |
114 | 140 |
"""A generic config object. |
115 | 141 |
|
... | ... | |
451 | 477 |
class Disk(ConfigObject): |
452 | 478 |
"""Config object representing a block device.""" |
453 | 479 |
__slots__ = ["dev_type", "logical_id", "physical_id", |
454 |
"children", "iv_name", "size", "mode"] |
|
480 |
"children", "iv_name", "size", "mode", "params"]
|
|
455 | 481 |
|
456 | 482 |
def CreateOnSecondary(self): |
457 | 483 |
"""Test if this device needs to be created on a secondary node.""" |
... | ... | |
745 | 771 |
if self.children: |
746 | 772 |
for child in self.children: |
747 | 773 |
child.UpgradeConfig() |
774 |
|
|
775 |
if not self.params: |
|
776 |
self.params = constants.DISK_LD_DEFAULTS[self.dev_type].copy() |
|
777 |
else: |
|
778 |
self.params = FillDict(constants.DISK_LD_DEFAULTS[self.dev_type], |
|
779 |
self.params) |
|
748 | 780 |
# add here config upgrade for this disk |
749 | 781 |
|
750 | 782 |
|
... | ... | |
1111 | 1143 |
"name", |
1112 | 1144 |
"members", |
1113 | 1145 |
"ndparams", |
1146 |
"diskparams", |
|
1114 | 1147 |
"serial_no", |
1115 | 1148 |
"alloc_policy", |
1116 | 1149 |
] + _TIMESTAMPS + _UUID |
... | ... | |
1155 | 1188 |
if self.mtime is None: |
1156 | 1189 |
self.mtime = time.time() |
1157 | 1190 |
|
1191 |
self.diskparams = UpgradeDiskParams(self.diskparams) |
|
1192 |
|
|
1158 | 1193 |
def FillND(self, node): |
1159 | 1194 |
"""Return filled out ndparams for L{objects.Node} |
1160 | 1195 |
|
... | ... | |
1206 | 1241 |
"osparams", |
1207 | 1242 |
"nicparams", |
1208 | 1243 |
"ndparams", |
1244 |
"diskparams", |
|
1209 | 1245 |
"candidate_pool_size", |
1210 | 1246 |
"modify_etc_hosts", |
1211 | 1247 |
"modify_ssh_setup", |
... | ... | |
1312 | 1348 |
if self.use_external_mip_script is None: |
1313 | 1349 |
self.use_external_mip_script = False |
1314 | 1350 |
|
1351 |
self.diskparams = UpgradeDiskParams(self.diskparams) |
|
1352 |
|
|
1315 | 1353 |
def ToDict(self): |
1316 | 1354 |
"""Custom function for cluster. |
1317 | 1355 |
|
Also available in: Unified diff