Revision d23a2a9d
b/lib/cmdlib.py | ||
---|---|---|
1286 | 1286 |
raise errors.ProgrammerError("Unhandled certificate error code %r" % errcode) |
1287 | 1287 |
|
1288 | 1288 |
|
1289 |
def _GetAllHypervisorParameters(cluster, instances): |
|
1290 |
"""Compute the set of all hypervisor parameters. |
|
1291 |
|
|
1292 |
@type cluster: L{objects.Cluster} |
|
1293 |
@param cluster: the cluster object |
|
1294 |
@param instances: list of L{objects.Instance} |
|
1295 |
@param instances: additional instances from which to obtain parameters |
|
1296 |
@rtype: list of (origin, hypervisor, parameters) |
|
1297 |
@return: a list with all parameters found, indicating the hypervisor they |
|
1298 |
apply to, and the origin (can be "cluster", "os X", or "instance Y") |
|
1299 |
|
|
1300 |
""" |
|
1301 |
hvp_data = [] |
|
1302 |
|
|
1303 |
for hv_name in cluster.enabled_hypervisors: |
|
1304 |
hvp_data.append(("cluster", hv_name, cluster.GetHVDefaults(hv_name))) |
|
1305 |
|
|
1306 |
for os_name, os_hvp in cluster.os_hvp.items(): |
|
1307 |
for hv_name, hv_params in os_hvp.items(): |
|
1308 |
if hv_params: |
|
1309 |
full_params = cluster.GetHVDefaults(hv_name, os_name=os_name) |
|
1310 |
hvp_data.append(("os %s" % os_name, hv_name, full_params)) |
|
1311 |
|
|
1312 |
# TODO: collapse identical parameter values in a single one |
|
1313 |
for instance in instances: |
|
1314 |
if instance.hvparams: |
|
1315 |
hvp_data.append(("instance %s" % instance.name, instance.hypervisor, |
|
1316 |
cluster.FillHV(instance))) |
|
1317 |
|
|
1318 |
return hvp_data |
|
1319 |
|
|
1320 |
|
|
1289 | 1321 |
class _VerifyErrors(object): |
1290 | 1322 |
"""Mix-in for cluster/group verify LUs. |
1291 | 1323 |
|
... | ... | |
1375 | 1407 |
|
1376 | 1408 |
REQ_BGL = False |
1377 | 1409 |
|
1410 |
def _VerifyHVP(self, hvp_data): |
|
1411 |
"""Verifies locally the syntax of the hypervisor parameters. |
|
1412 |
|
|
1413 |
""" |
|
1414 |
for item, hv_name, hv_params in hvp_data: |
|
1415 |
msg = ("hypervisor %s parameters syntax check (source %s): %%s" % |
|
1416 |
(item, hv_name)) |
|
1417 |
try: |
|
1418 |
hv_class = hypervisor.GetHypervisor(hv_name) |
|
1419 |
utils.ForceDictType(hv_params, constants.HVS_PARAMETER_TYPES) |
|
1420 |
hv_class.CheckParameterSyntax(hv_params) |
|
1421 |
except errors.GenericError, err: |
|
1422 |
self._ErrorIf(True, self.ECLUSTERCFG, None, msg % str(err)) |
|
1423 |
|
|
1378 | 1424 |
def ExpandNames(self): |
1379 | 1425 |
self.all_group_info = self.cfg.GetAllNodeGroupsInfo() |
1426 |
self.all_inst_info = self.cfg.GetAllInstancesInfo() |
|
1380 | 1427 |
self.needed_locks = {} |
1381 | 1428 |
|
1382 | 1429 |
def Exec(self, feedback_fn): |
... | ... | |
1397 | 1444 |
(errcode, msg) = _VerifyCertificate(cert_filename) |
1398 | 1445 |
self._ErrorIf(errcode, self.ECLUSTERCERT, None, msg, code=errcode) |
1399 | 1446 |
|
1447 |
feedback_fn("* Verifying hypervisor parameters") |
|
1448 |
|
|
1449 |
self._VerifyHVP(_GetAllHypervisorParameters(self.cfg.GetClusterInfo(), |
|
1450 |
self.all_inst_info.values())) |
|
1451 |
|
|
1400 | 1452 |
return (not self.bad, [g.name for g in self.all_group_info.values()]) |
1401 | 1453 |
|
1402 | 1454 |
|
... | ... | |
2278 | 2330 |
|
2279 | 2331 |
return instdisk |
2280 | 2332 |
|
2281 |
def _VerifyHVP(self, hvp_data): |
|
2282 |
"""Verifies locally the syntax of the hypervisor parameters. |
|
2283 |
|
|
2284 |
""" |
|
2285 |
for item, hv_name, hv_params in hvp_data: |
|
2286 |
msg = ("hypervisor %s parameters syntax check (source %s): %%s" % |
|
2287 |
(item, hv_name)) |
|
2288 |
try: |
|
2289 |
hv_class = hypervisor.GetHypervisor(hv_name) |
|
2290 |
utils.ForceDictType(hv_params, constants.HVS_PARAMETER_TYPES) |
|
2291 |
hv_class.CheckParameterSyntax(hv_params) |
|
2292 |
except errors.GenericError, err: |
|
2293 |
self._ErrorIf(True, self.ECLUSTERCFG, None, msg % str(err)) |
|
2294 |
|
|
2295 | 2333 |
def BuildHooksEnv(self): |
2296 | 2334 |
"""Build hooks env. |
2297 | 2335 |
|
... | ... | |
2328 | 2366 |
|
2329 | 2367 |
vg_name = self.cfg.GetVGName() |
2330 | 2368 |
drbd_helper = self.cfg.GetDRBDHelper() |
2331 |
hypervisors = self.cfg.GetClusterInfo().enabled_hypervisors |
|
2332 | 2369 |
cluster = self.cfg.GetClusterInfo() |
2333 | 2370 |
groupinfo = self.cfg.GetAllNodeGroupsInfo() |
2371 |
hypervisors = cluster.enabled_hypervisors |
|
2334 | 2372 |
node_data_list = [self.my_node_info[name] for name in self.my_node_names] |
2335 | 2373 |
|
2336 | 2374 |
i_non_redundant = [] # Non redundant instances |
... | ... | |
2348 | 2386 |
master_node = self.master_node = self.cfg.GetMasterNode() |
2349 | 2387 |
master_ip = self.cfg.GetMasterIP() |
2350 | 2388 |
|
2351 |
# Compute the set of hypervisor parameters |
|
2352 |
hvp_data = [] |
|
2353 |
for hv_name in hypervisors: |
|
2354 |
hvp_data.append(("cluster", hv_name, cluster.GetHVDefaults(hv_name))) |
|
2355 |
for os_name, os_hvp in cluster.os_hvp.items(): |
|
2356 |
for hv_name, hv_params in os_hvp.items(): |
|
2357 |
if not hv_params: |
|
2358 |
continue |
|
2359 |
full_params = cluster.GetHVDefaults(hv_name, os_name=os_name) |
|
2360 |
hvp_data.append(("os %s" % os_name, hv_name, full_params)) |
|
2361 |
# TODO: collapse identical parameter values in a single one |
|
2362 |
for instance in self.all_inst_info.values(): |
|
2363 |
if not instance.hvparams: |
|
2364 |
continue |
|
2365 |
hvp_data.append(("instance %s" % instance.name, instance.hypervisor, |
|
2366 |
cluster.FillHV(instance))) |
|
2367 |
# and verify them locally |
|
2368 |
self._VerifyHVP(hvp_data) |
|
2369 |
|
|
2370 | 2389 |
feedback_fn("* Gathering data (%d nodes)" % len(self.my_node_names)) |
2371 | 2390 |
node_verify_param = { |
2372 | 2391 |
constants.NV_FILELIST: |
... | ... | |
2376 | 2395 |
constants.NV_NODELIST: [node.name for node in self.all_node_info.values() |
2377 | 2396 |
if not node.offline], |
2378 | 2397 |
constants.NV_HYPERVISOR: hypervisors, |
2379 |
constants.NV_HVPARAMS: hvp_data, |
|
2398 |
constants.NV_HVPARAMS: |
|
2399 |
_GetAllHypervisorParameters(cluster, self.all_inst_info.values()), |
|
2380 | 2400 |
constants.NV_NODENETTEST: [(node.name, node.primary_ip, node.secondary_ip) |
2381 | 2401 |
for node in node_data_list |
2382 | 2402 |
if not node.offline], |
Also available in: Unified diff