Revision 29921401
b/lib/backend.py | ||
---|---|---|
173 | 173 |
master_ip = cfg.GetMasterIP() |
174 | 174 |
master_node = cfg.GetMasterNode() |
175 | 175 |
except errors.ConfigurationError, err: |
176 |
_Fail("Cluster configuration incomplete", exc=True)
|
|
176 |
_Fail("Cluster configuration incomplete: %s", err, exc=True)
|
|
177 | 177 |
return master_netdev, master_ip, master_node |
178 | 178 |
|
179 | 179 |
|
... | ... | |
680 | 680 |
for hname in hypervisor_list: |
681 | 681 |
iinfo = hypervisor.GetHypervisor(hname).GetAllInstancesInfo() |
682 | 682 |
if iinfo: |
683 |
for name, inst_id, memory, vcpus, state, times in iinfo:
|
|
683 |
for name, _, memory, vcpus, state, times in iinfo:
|
|
684 | 684 |
value = { |
685 | 685 |
'memory': memory, |
686 | 686 |
'vcpus': vcpus, |
... | ... | |
796 | 796 |
"pv_count": int(valarr[2]), |
797 | 797 |
} |
798 | 798 |
except ValueError, err: |
799 |
logging.exception("Fail to parse vgs output")
|
|
799 |
logging.exception("Fail to parse vgs output: %s", err)
|
|
800 | 800 |
else: |
801 | 801 |
logging.error("vgs output has the wrong number of fields (expected" |
802 | 802 |
" three): %s", str(valarr)) |
... | ... | |
840 | 840 |
"""Remove the block device symlinks belonging to the given instance. |
841 | 841 |
|
842 | 842 |
""" |
843 |
for idx, disk in enumerate(disks):
|
|
843 |
for idx, _ in enumerate(disks):
|
|
844 | 844 |
link_name = _GetBlockDevSymlinkPath(instance_name, idx) |
845 | 845 |
if os.path.islink(link_name): |
846 | 846 |
try: |
... | ... | |
1534 | 1534 |
try: |
1535 | 1535 |
f_names = utils.ListVisibleFiles(dir_name) |
1536 | 1536 |
except EnvironmentError, err: |
1537 |
logging.exception("Can't list the OS directory %s", dir_name)
|
|
1537 |
logging.exception("Can't list the OS directory %s: %s", dir_name, err)
|
|
1538 | 1538 |
break |
1539 | 1539 |
for name in f_names: |
1540 | 1540 |
os_path = os.path.sep.join([dir_name, name]) |
... | ... | |
2360 | 2360 |
|
2361 | 2361 |
min_resync = 100 |
2362 | 2362 |
alldone = True |
2363 |
failure = False |
|
2364 | 2363 |
for rd in bdevs: |
2365 | 2364 |
stats = rd.GetProcStatus() |
2366 | 2365 |
if not (stats.is_connected or stats.is_in_resync): |
... | ... | |
2382 | 2381 |
hyper = hypervisor.GetHypervisor(hypervisor_type) |
2383 | 2382 |
try: |
2384 | 2383 |
pid = os.fork() |
2385 |
except OSError, err:
|
|
2384 |
except OSError: |
|
2386 | 2385 |
# if we can't fork, we'll pretend that we're in the child process |
2387 | 2386 |
pid = 0 |
2388 | 2387 |
if pid > 0: |
... | ... | |
2497 | 2496 |
dir_name = "%s/%s" % (self._BASE_DIR, subdir) |
2498 | 2497 |
try: |
2499 | 2498 |
dir_contents = utils.ListVisibleFiles(dir_name) |
2500 |
except OSError, err:
|
|
2499 |
except OSError: |
|
2501 | 2500 |
# FIXME: must log output in case of failures |
2502 | 2501 |
return rr |
2503 | 2502 |
|
... | ... | |
2619 | 2618 |
try: |
2620 | 2619 |
utils.WriteFile(fpath, data=fdata) |
2621 | 2620 |
except EnvironmentError, err: |
2622 |
logging.exception("Can't update bdev cache for %s", dev_path)
|
|
2621 |
logging.exception("Can't update bdev cache for %s: %s", dev_path, err)
|
|
2623 | 2622 |
|
2624 | 2623 |
@classmethod |
2625 | 2624 |
def RemoveCache(cls, dev_path): |
... | ... | |
2641 | 2640 |
try: |
2642 | 2641 |
utils.RemoveFile(fpath) |
2643 | 2642 |
except EnvironmentError, err: |
2644 |
logging.exception("Can't update bdev cache for %s", dev_path) |
|
2643 |
logging.exception("Can't update bdev cache for %s: %s", dev_path, err) |
b/lib/cmdlib.py | ||
---|---|---|
26 | 26 |
import os |
27 | 27 |
import os.path |
28 | 28 |
import time |
29 |
import tempfile |
|
30 | 29 |
import re |
31 | 30 |
import platform |
32 | 31 |
import logging |
33 | 32 |
import copy |
34 |
import random |
|
35 | 33 |
|
36 | 34 |
from ganeti import ssh |
37 | 35 |
from ganeti import utils |
... | ... | |
40 | 38 |
from ganeti import locking |
41 | 39 |
from ganeti import constants |
42 | 40 |
from ganeti import objects |
43 |
from ganeti import opcodes |
|
44 | 41 |
from ganeti import serializer |
45 | 42 |
from ganeti import ssconf |
46 | 43 |
|
... | ... | |
637 | 634 |
|
638 | 635 |
""" |
639 | 636 |
if node is None: |
640 |
node=instance.primary_node
|
|
637 |
node = instance.primary_node
|
|
641 | 638 |
_CheckNicsBridgesExist(lu, instance.nics, node) |
642 | 639 |
|
643 | 640 |
|
... | ... | |
2582 | 2579 |
"master": cluster.master_node, |
2583 | 2580 |
"default_hypervisor": cluster.default_hypervisor, |
2584 | 2581 |
"enabled_hypervisors": cluster.enabled_hypervisors, |
2585 |
"hvparams": dict([(hypervisor, cluster.hvparams[hypervisor])
|
|
2586 |
for hypervisor in cluster.enabled_hypervisors]),
|
|
2582 |
"hvparams": dict([(hvname, cluster.hvparams[hvname])
|
|
2583 |
for hvname in cluster.enabled_hypervisors]),
|
|
2587 | 2584 |
"beparams": cluster.beparams, |
2588 | 2585 |
"nicparams": cluster.nicparams, |
2589 | 2586 |
"candidate_pool_size": cluster.candidate_pool_size, |
... | ... | |
4536 | 4533 |
bridge = nic.get("bridge", None) |
4537 | 4534 |
link = nic.get("link", None) |
4538 | 4535 |
if bridge and link: |
4539 |
raise errors.OpPrereqError("Cannot pass 'bridge' and 'link' at the same time") |
|
4536 |
raise errors.OpPrereqError("Cannot pass 'bridge' and 'link'" |
|
4537 |
" at the same time") |
|
4540 | 4538 |
elif bridge and nic_mode == constants.NIC_MODE_ROUTED: |
4541 | 4539 |
raise errors.OpPrereqError("Cannot pass 'bridge' on a routed nic") |
4542 | 4540 |
elif bridge: |
... | ... | |
5927 | 5925 |
nic_bridge = nic_dict.get('bridge', None) |
5928 | 5926 |
nic_link = nic_dict.get('link', None) |
5929 | 5927 |
if nic_bridge and nic_link: |
5930 |
raise errors.OpPrereqError("Cannot pass 'bridge' and 'link' at the same time") |
|
5928 |
raise errors.OpPrereqError("Cannot pass 'bridge' and 'link'" |
|
5929 |
" at the same time") |
|
5931 | 5930 |
elif nic_bridge and nic_bridge.lower() == constants.VALUE_NONE: |
5932 | 5931 |
nic_dict['bridge'] = None |
5933 | 5932 |
elif nic_link and nic_link.lower() == constants.VALUE_NONE: |
b/lib/hypervisor/hv_base.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
import os |
41 | 41 |
import re |
42 |
import logging |
|
42 | 43 |
|
43 | 44 |
|
44 | 45 |
from ganeti import errors |
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
56 | 56 |
constants.HV_ACPI: hv_base.NO_CHECK, |
57 | 57 |
constants.HV_SERIAL_CONSOLE: hv_base.NO_CHECK, |
58 | 58 |
constants.HV_VNC_BIND_ADDRESS: \ |
59 |
(False, lambda x: (utils.IsValidIP(x) or utils.IsAbsNormPath(x)),
|
|
59 |
(False, lambda x: (utils.IsValidIP(x) or utils.IsNormAbsPath(x)),
|
|
60 | 60 |
"the VNC bind address must be either a valid IP address or an absolute" |
61 | 61 |
" pathname", None, None), |
62 | 62 |
constants.HV_VNC_TLS: hv_base.NO_CHECK, |
... | ... | |
86 | 86 |
hv_base.BaseHypervisor.__init__(self) |
87 | 87 |
# Let's make sure the directories we need exist, even if the RUN_DIR lives |
88 | 88 |
# in a tmpfs filesystem or has been otherwise wiped out. |
89 |
dirs = [(dir, constants.RUN_DIRS_MODE) for dir in self._DIRS]
|
|
89 |
dirs = [(dname, constants.RUN_DIRS_MODE) for dname in self._DIRS]
|
|
90 | 90 |
utils.EnsureDirs(dirs) |
91 | 91 |
|
92 | 92 |
def _InstancePidAlive(self, instance_name): |
b/lib/mcpu.py | ||
---|---|---|
364 | 364 |
phase = constants.HOOKS_PHASE_POST |
365 | 365 |
hpath = constants.HOOKS_NAME_CFGUPDATE |
366 | 366 |
nodes = [self.lu.cfg.GetMasterNode()] |
367 |
results = self._RunWrapper(nodes, hpath, phase) |
|
367 |
self._RunWrapper(nodes, hpath, phase) |
b/lib/objects.py | ||
---|---|---|
40 | 40 |
"OS", "Node", "Cluster", "FillDict"] |
41 | 41 |
|
42 | 42 |
def FillDict(defaults_dict, custom_dict): |
43 |
"""Basic function to apply settings on top a default dict.
|
|
43 |
"""Basic function to apply settings on top a default dict. |
|
44 | 44 |
|
45 |
@type defaults_dict: dict
|
|
46 |
@param defaults_dict: dictionary holding the default values
|
|
47 |
@type custom_dict: dict
|
|
48 |
@param custom_dict: dictionary holding customized value
|
|
49 |
@rtype: dict
|
|
50 |
@return: dict with the 'full' values
|
|
45 |
@type defaults_dict: dict |
|
46 |
@param defaults_dict: dictionary holding the default values |
|
47 |
@type custom_dict: dict |
|
48 |
@param custom_dict: dictionary holding customized value |
|
49 |
@rtype: dict |
|
50 |
@return: dict with the 'full' values |
|
51 | 51 |
|
52 |
"""
|
|
53 |
ret_dict = copy.deepcopy(defaults_dict)
|
|
54 |
ret_dict.update(custom_dict)
|
|
55 |
return ret_dict
|
|
52 |
""" |
|
53 |
ret_dict = copy.deepcopy(defaults_dict) |
|
54 |
ret_dict.update(custom_dict) |
|
55 |
return ret_dict |
|
56 | 56 |
|
57 | 57 |
|
58 | 58 |
def UpgradeGroupedParams(target, defaults): |
... | ... | |
578 | 578 |
"""Checks that this disk is correctly configured. |
579 | 579 |
|
580 | 580 |
""" |
581 |
errors = []
|
|
581 |
errs = [] |
|
582 | 582 |
if self.mode not in constants.DISK_ACCESS_SET: |
583 |
errors.append("Disk access mode '%s' is invalid" % (self.mode, ))
|
|
584 |
return errors
|
|
583 |
errs.append("Disk access mode '%s' is invalid" % (self.mode, )) |
|
584 |
return errs |
|
585 | 585 |
|
586 | 586 |
|
587 | 587 |
class Instance(TaggableObject): |
b/lib/utils.py | ||
---|---|---|
396 | 396 |
if target[key] in allowed_values: |
397 | 397 |
continue |
398 | 398 |
|
399 |
type = key_types[key] |
|
400 |
if type not in constants.ENFORCEABLE_TYPES: |
|
401 |
msg = "'%s' has non-enforceable type %s" % (key, type) |
|
399 |
ktype = key_types[key]
|
|
400 |
if ktype not in constants.ENFORCEABLE_TYPES:
|
|
401 |
msg = "'%s' has non-enforceable type %s" % (key, ktype)
|
|
402 | 402 |
raise errors.ProgrammerError(msg) |
403 | 403 |
|
404 |
if type == constants.VTYPE_STRING: |
|
404 |
if ktype == constants.VTYPE_STRING:
|
|
405 | 405 |
if not isinstance(target[key], basestring): |
406 | 406 |
if isinstance(target[key], bool) and not target[key]: |
407 | 407 |
target[key] = '' |
408 | 408 |
else: |
409 | 409 |
msg = "'%s' (value %s) is not a valid string" % (key, target[key]) |
410 | 410 |
raise errors.TypeEnforcementError(msg) |
411 |
elif type == constants.VTYPE_BOOL: |
|
411 |
elif ktype == constants.VTYPE_BOOL:
|
|
412 | 412 |
if isinstance(target[key], basestring) and target[key]: |
413 | 413 |
if target[key].lower() == constants.VALUE_FALSE: |
414 | 414 |
target[key] = False |
... | ... | |
421 | 421 |
target[key] = True |
422 | 422 |
else: |
423 | 423 |
target[key] = False |
424 |
elif type == constants.VTYPE_SIZE: |
|
424 |
elif ktype == constants.VTYPE_SIZE:
|
|
425 | 425 |
try: |
426 | 426 |
target[key] = ParseUnit(target[key]) |
427 | 427 |
except errors.UnitParseError, err: |
428 | 428 |
msg = "'%s' (value %s) is not a valid size. error: %s" % \ |
429 | 429 |
(key, target[key], err) |
430 | 430 |
raise errors.TypeEnforcementError(msg) |
431 |
elif type == constants.VTYPE_INT: |
|
431 |
elif ktype == constants.VTYPE_INT:
|
|
432 | 432 |
try: |
433 | 433 |
target[key] = int(target[key]) |
434 | 434 |
except (ValueError, TypeError): |
... | ... | |
1526 | 1526 |
@param name: the daemon name used to derive the pidfile name |
1527 | 1527 |
|
1528 | 1528 |
""" |
1529 |
pid = os.getpid() |
|
1530 | 1529 |
pidfilename = DaemonPidFileName(name) |
1531 | 1530 |
# TODO: we could check here that the file contains our pid |
1532 | 1531 |
try: |
Also available in: Unified diff