Revision e687ec01
b/daemons/import-export | ||
---|---|---|
128 | 128 |
@param port: TCP/UDP port |
129 | 129 |
|
130 | 130 |
""" |
131 |
assert isinstance(port, (int, long)) and 0 < port < 2**16
|
|
131 |
assert isinstance(port, (int, long)) and 0 < port < (2 ** 16)
|
|
132 | 132 |
self._data.listen_port = port |
133 | 133 |
|
134 | 134 |
def GetListenPort(self): |
b/lib/asyncnotifier.py | ||
---|---|---|
34 | 34 |
from ganeti import daemon |
35 | 35 |
from ganeti import errors |
36 | 36 |
|
37 |
|
|
37 | 38 |
# We contributed the AsyncNotifier class back to python-pyinotify, and it's |
38 | 39 |
# part of their codebase since version 0.8.7. This code can be removed once |
39 | 40 |
# we'll be ready to depend on python-pyinotify >= 0.8.7 |
b/lib/backend.py | ||
---|---|---|
730 | 730 |
# we don't want to report such volumes as existing, since they |
731 | 731 |
# don't really hold data |
732 | 732 |
continue |
733 |
lvs[vg_name+"/"+name] = (size, inactive, online)
|
|
733 |
lvs[vg_name + "/" + name] = (size, inactive, online)
|
|
734 | 734 |
|
735 | 735 |
return lvs |
736 | 736 |
|
... | ... | |
2359 | 2359 |
config.set(constants.INISECT_INS, "nic%d_%s" % (nic_count, param), |
2360 | 2360 |
"%s" % nic.nicparams.get(param, None)) |
2361 | 2361 |
# TODO: redundant: on load can read nics until it doesn't exist |
2362 |
config.set(constants.INISECT_INS, "nic_count" , "%d" % nic_total)
|
|
2362 |
config.set(constants.INISECT_INS, "nic_count", "%d" % nic_total) |
|
2363 | 2363 |
|
2364 | 2364 |
disk_total = 0 |
2365 | 2365 |
for disk_count, disk in enumerate(snap_disks): |
... | ... | |
2372 | 2372 |
config.set(constants.INISECT_INS, "disk%d_size" % disk_count, |
2373 | 2373 |
("%d" % disk.size)) |
2374 | 2374 |
|
2375 |
config.set(constants.INISECT_INS, "disk_count" , "%d" % disk_total)
|
|
2375 |
config.set(constants.INISECT_INS, "disk_count", "%d" % disk_total) |
|
2376 | 2376 |
|
2377 | 2377 |
# New-style hypervisor/backend parameters |
2378 | 2378 |
|
... | ... | |
3378 | 3378 |
else: |
3379 | 3379 |
_Fail("Unknown hooks phase '%s'", phase) |
3380 | 3380 |
|
3381 |
|
|
3382 | 3381 |
subdir = "%s-%s.d" % (hpath, suffix) |
3383 | 3382 |
dir_name = utils.PathJoin(self._BASE_DIR, subdir) |
3384 | 3383 |
|
b/lib/bdev.py | ||
---|---|---|
321 | 321 |
is_degraded=is_degraded, |
322 | 322 |
ldisk_status=ldisk_status) |
323 | 323 |
|
324 |
|
|
325 | 324 |
def SetInfo(self, text): |
326 | 325 |
"""Update metadata with info text. |
327 | 326 |
|
... | ... | |
408 | 407 |
pvs_info.sort() |
409 | 408 |
pvs_info.reverse() |
410 | 409 |
|
411 |
pvlist = [ pv[1] for pv in pvs_info ]
|
|
410 |
pvlist = [pv[1] for pv in pvs_info]
|
|
412 | 411 |
if compat.any(":" in v for v in pvlist): |
413 | 412 |
_ThrowError("Some of your PVs have the invalid character ':' in their" |
414 | 413 |
" name, this is not supported - please filter them out" |
415 | 414 |
" in lvm.conf using either 'filter' or 'preferred_names'") |
416 |
free_size = sum([ pv[0] for pv in pvs_info ])
|
|
415 |
free_size = sum([pv[0] for pv in pvs_info])
|
|
417 | 416 |
current_pvs = len(pvlist) |
418 | 417 |
stripes = min(current_pvs, constants.LVM_STRIPECOUNT) |
419 | 418 |
|
... | ... | |
1113 | 1112 |
super(DRBD8, self).__init__(unique_id, children, size) |
1114 | 1113 |
self.major = self._DRBD_MAJOR |
1115 | 1114 |
version = self._GetVersion(self._GetProcData()) |
1116 |
if version["k_major"] != 8 :
|
|
1115 |
if version["k_major"] != 8: |
|
1117 | 1116 |
_ThrowError("Mismatch in DRBD kernel version and requested ganeti" |
1118 | 1117 |
" usage: kernel is %s.%s, ganeti wants 8.x", |
1119 | 1118 |
version["k_major"], version["k_minor"]) |
... | ... | |
1194 | 1193 |
# this also converts the value to an int |
1195 | 1194 |
number = pyp.Word(pyp.nums).setParseAction(lambda s, l, t: int(t[0])) |
1196 | 1195 |
|
1197 |
comment = pyp.Literal ("#") + pyp.Optional(pyp.restOfLine)
|
|
1196 |
comment = pyp.Literal("#") + pyp.Optional(pyp.restOfLine) |
|
1198 | 1197 |
defa = pyp.Literal("_is_default").suppress() |
1199 | 1198 |
dbl_quote = pyp.Literal('"').suppress() |
1200 | 1199 |
|
b/lib/bootstrap.py | ||
---|---|---|
270 | 270 |
" entries: %s" % invalid_hvs, |
271 | 271 |
errors.ECODE_INVAL) |
272 | 272 |
|
273 |
|
|
274 | 273 |
ipcls = None |
275 | 274 |
if primary_ip_version == constants.IP4_VERSION: |
276 | 275 |
ipcls = netutils.IP4Address |
... | ... | |
661 | 660 |
|
662 | 661 |
master_ip = sstore.GetMasterIP() |
663 | 662 |
total_timeout = 30 |
663 |
|
|
664 | 664 |
# Here we have a phase where no master should be running |
665 | 665 |
def _check_ip(): |
666 | 666 |
if netutils.TcpPing(master_ip, constants.DEFAULT_NODED_PORT): |
b/lib/cli.py | ||
---|---|---|
728 | 728 |
type="keyval", default={}, |
729 | 729 |
help="Backend parameters") |
730 | 730 |
|
731 |
HVOPTS_OPT = cli_option("-H", "--hypervisor-parameters", type="keyval",
|
|
732 |
default={}, dest="hvparams",
|
|
733 |
help="Hypervisor parameters")
|
|
731 |
HVOPTS_OPT = cli_option("-H", "--hypervisor-parameters", type="keyval", |
|
732 |
default={}, dest="hvparams", |
|
733 |
help="Hypervisor parameters") |
|
734 | 734 |
|
735 | 735 |
HYPERVISOR_OPT = cli_option("-H", "--hypervisor-parameters", dest="hypervisor", |
736 | 736 |
help="Hypervisor and hypervisor options, in the" |
... | ... | |
2815 | 2815 |
@return: a string with the formatted timestamp |
2816 | 2816 |
|
2817 | 2817 |
""" |
2818 |
if not isinstance (ts, (tuple, list)) or len(ts) != 2:
|
|
2818 |
if not isinstance(ts, (tuple, list)) or len(ts) != 2: |
|
2819 | 2819 |
return "?" |
2820 | 2820 |
sec, usec = ts |
2821 | 2821 |
return time.strftime("%F %T", time.localtime(sec)) + ".%06d" % usec |
b/lib/client/gnt_debug.py | ||
---|---|---|
113 | 113 |
t3 = time.time() |
114 | 114 |
ToStdout("C:op %4d" % op_cnt) |
115 | 115 |
ToStdout("C:job %4d" % job_cnt) |
116 |
ToStdout("T:submit %4.4f" % (t2-t1))
|
|
117 |
ToStdout("T:exec %4.4f" % (t3-t2))
|
|
118 |
ToStdout("T:total %4.4f" % (t3-t1))
|
|
116 |
ToStdout("T:submit %4.4f" % (t2 - t1))
|
|
117 |
ToStdout("T:exec %4.4f" % (t3 - t2))
|
|
118 |
ToStdout("T:total %4.4f" % (t3 - t1))
|
|
119 | 119 |
return 0 |
120 | 120 |
|
121 | 121 |
|
... | ... | |
689 | 689 |
"allocator": "iallocator", |
690 | 690 |
} |
691 | 691 |
|
692 |
|
|
692 | 693 |
def Main(): |
693 | 694 |
return GenericMain(commands, aliases=aliases) |
b/lib/client/gnt_instance.py | ||
---|---|---|
1119 | 1119 |
if isinstance(elem, tuple)] or [0]) |
1120 | 1120 |
for elem in data: |
1121 | 1121 |
if isinstance(elem, basestring): |
1122 |
buf.write("%*s%s\n" % (2*indent_level, "", elem))
|
|
1122 |
buf.write("%*s%s\n" % (2 * indent_level, "", elem))
|
|
1123 | 1123 |
elif isinstance(elem, tuple): |
1124 | 1124 |
key, value = elem |
1125 | 1125 |
spacer = "%*s" % (max_tlen - len(key), "") |
1126 |
buf.write("%*s%s:%s %s\n" % (2*indent_level, "", key, spacer, value))
|
|
1126 |
buf.write("%*s%s:%s %s\n" % (2 * indent_level, "", key, spacer, value))
|
|
1127 | 1127 |
elif isinstance(elem, list): |
1128 |
_FormatList(buf, elem, indent_level+1)
|
|
1128 |
_FormatList(buf, elem, indent_level + 1)
|
|
1129 | 1129 |
|
1130 | 1130 |
|
1131 | 1131 |
def ShowInstanceConfig(opts, args): |
... | ... | |
1179 | 1179 |
buf.write(" Operating system: %s\n" % instance["os"]) |
1180 | 1180 |
FormatParameterDict(buf, instance["os_instance"], instance["os_actual"], |
1181 | 1181 |
level=2) |
1182 |
if instance.has_key("network_port"):
|
|
1182 |
if "network_port" in instance:
|
|
1183 | 1183 |
buf.write(" Allocated network port: %s\n" % |
1184 | 1184 |
compat.TryToRoman(instance["network_port"], |
1185 | 1185 |
convert=opts.roman_integers)) |
b/lib/cmdlib.py | ||
---|---|---|
4085 | 4085 |
raise errors.OpExecError("Check of out-of-band payload failed due to %s" % |
4086 | 4086 |
utils.CommaJoin(errs)) |
4087 | 4087 |
|
4088 |
|
|
4088 | 4089 |
class _OsQuery(_QueryBase): |
4089 | 4090 |
FIELDS = query.OS_FIELDS |
4090 | 4091 |
|
... | ... | |
7950 | 7951 |
|
7951 | 7952 |
if disk_template not in req_size_dict: |
7952 | 7953 |
raise errors.ProgrammerError("Disk template '%s' size requirement" |
7953 |
" is unknown" % disk_template)
|
|
7954 |
" is unknown" % disk_template) |
|
7954 | 7955 |
|
7955 | 7956 |
return req_size_dict[disk_template] |
7956 | 7957 |
|
... | ... | |
7972 | 7973 |
|
7973 | 7974 |
if disk_template not in req_size_dict: |
7974 | 7975 |
raise errors.ProgrammerError("Disk template '%s' size requirement" |
7975 |
" is unknown" % disk_template)
|
|
7976 |
" is unknown" % disk_template) |
|
7976 | 7977 |
|
7977 | 7978 |
return req_size_dict[disk_template] |
7978 | 7979 |
|
... | ... | |
8886 | 8887 |
# 'fake' LV disks with the old data, plus the new unique_id |
8887 | 8888 |
tmp_disks = [objects.Disk.FromDict(v.ToDict()) for v in disks] |
8888 | 8889 |
rename_to = [] |
8889 |
for t_dsk, a_dsk in zip (tmp_disks, self.disks):
|
|
8890 |
for t_dsk, a_dsk in zip(tmp_disks, self.disks): |
|
8890 | 8891 |
rename_to.append(t_dsk.logical_id) |
8891 | 8892 |
t_dsk.logical_id = (t_dsk.logical_id[0], a_dsk[constants.IDISK_ADOPT]) |
8892 | 8893 |
self.cfg.SetDiskID(t_dsk, pnode_name) |
... | ... | |
10826 | 10827 |
if msg: |
10827 | 10828 |
# Assume the primary node is unreachable and go ahead |
10828 | 10829 |
self.warn.append("Can't get info from primary node %s: %s" % |
10829 |
(pnode, msg))
|
|
10830 |
(pnode, msg)) |
|
10830 | 10831 |
elif not isinstance(pninfo.payload.get("memory_free", None), int): |
10831 | 10832 |
self.warn.append("Node data from primary node %s doesn't contain" |
10832 | 10833 |
" free memory information" % pnode) |
... | ... | |
12143 | 12144 |
return result |
12144 | 12145 |
|
12145 | 12146 |
|
12146 |
|
|
12147 | 12147 |
class LUGroupRemove(LogicalUnit): |
12148 | 12148 |
HPATH = "group-remove" |
12149 | 12149 |
HTYPE = constants.HTYPE_GROUP |
b/lib/compat.py | ||
---|---|---|
67 | 67 |
return False |
68 | 68 |
return True |
69 | 69 |
|
70 |
|
|
70 | 71 |
def _any(seq): |
71 | 72 |
"""Returns True if any element of the iterable are True. |
72 | 73 |
|
... | ... | |
75 | 76 |
return True |
76 | 77 |
return False |
77 | 78 |
|
79 |
|
|
78 | 80 |
try: |
79 | 81 |
# pylint: disable-msg=E0601 |
80 | 82 |
# pylint: disable-msg=W0622 |
... | ... | |
89 | 91 |
except NameError: |
90 | 92 |
any = _any |
91 | 93 |
|
94 |
|
|
92 | 95 |
def partition(seq, pred=bool): # pylint: disable-msg=W0622 |
93 | 96 |
"""Partition a list in two, based on the given predicate. |
94 | 97 |
|
b/lib/confd/__init__.py | ||
---|---|---|
50 | 50 |
raise errors.ConfdMagicError("UDP payload contains an unkown fourcc") |
51 | 51 |
|
52 | 52 |
return payload[_FOURCC_LEN:] |
53 |
|
b/lib/confd/client.py | ||
---|---|---|
333 | 333 |
elif peer_cnt < 5: |
334 | 334 |
return peer_cnt - 1 |
335 | 335 |
else: |
336 |
return int(peer_cnt/2) + 1
|
|
336 |
return int(peer_cnt / 2) + 1
|
|
337 | 337 |
|
338 | 338 |
def WaitForReply(self, salt, timeout=constants.CONFD_CLIENT_EXPIRE_TIMEOUT): |
339 | 339 |
"""Wait for replies to a given request. |
b/lib/config.py | ||
---|---|---|
539 | 539 |
cluster.SimpleFillND(nodegroup.ndparams), |
540 | 540 |
constants.NDS_PARAMETER_TYPES) |
541 | 541 |
|
542 |
|
|
543 | 542 |
# drbd minors check |
544 | 543 |
_, duplicates = self._UnlockedComputeDRBDMap() |
545 | 544 |
for node, minor, instance_a, instance_b in duplicates: |
b/lib/constants.py | ||
---|---|---|
102 | 102 |
|
103 | 103 |
# Wipe |
104 | 104 |
DD_CMD = "dd" |
105 |
WIPE_BLOCK_SIZE = 1024**2
|
|
105 |
WIPE_BLOCK_SIZE = 1024 ** 2
|
|
106 | 106 |
MAX_WIPE_CHUNK = 1024 # 1GB |
107 | 107 |
MIN_WIPE_CHUNK_PERCENT = 10 |
108 | 108 |
|
... | ... | |
125 | 125 |
ADOPTABLE_BLOCKDEV_ROOT = "/dev/disk/" |
126 | 126 |
# keep RUN_GANETI_DIR first here, to make sure all get created when the node |
127 | 127 |
# daemon is started (this takes care of RUN_DIR being tmpfs) |
128 |
SUB_RUN_DIRS = [ RUN_GANETI_DIR, BDEV_CACHE_DIR, DISK_LINKS_DIR ] |
|
128 |
SUB_RUN_DIRS = [ |
|
129 |
RUN_GANETI_DIR, |
|
130 |
BDEV_CACHE_DIR, |
|
131 |
DISK_LINKS_DIR, |
|
132 |
] |
|
129 | 133 |
LOCK_DIR = _autoconf.LOCALSTATEDIR + "/lock" |
130 | 134 |
SSCONF_LOCK_FILE = LOCK_DIR + "/ganeti-ssconf.lock" |
131 | 135 |
# User-id pool lock directory |
... | ... | |
1209 | 1213 |
#: Dictionary with special field cases and their verbose/terse formatting |
1210 | 1214 |
RSS_DESCRIPTION = { |
1211 | 1215 |
RS_UNKNOWN: ("(unknown)", "??"), |
1212 |
RS_NODATA: ("(nodata)", "?"),
|
|
1216 |
RS_NODATA: ("(nodata)", "?"),
|
|
1213 | 1217 |
RS_OFFLINE: ("(offline)", "*"), |
1214 | 1218 |
RS_UNAVAIL: ("(unavail)", "-"), |
1215 | 1219 |
} |
... | ... | |
1440 | 1444 |
|
1441 | 1445 |
# User-id pool minimum/maximum acceptable user-ids. |
1442 | 1446 |
UIDPOOL_UID_MIN = 0 |
1443 |
UIDPOOL_UID_MAX = 2**32-1 # Assuming 32 bit user-ids
|
|
1447 |
UIDPOOL_UID_MAX = 2 ** 32 - 1 # Assuming 32 bit user-ids
|
|
1444 | 1448 |
|
1445 | 1449 |
# Name or path of the pgrep command |
1446 | 1450 |
PGREP = "pgrep" |
b/lib/errors.py | ||
---|---|---|
482 | 482 |
error = GetEncodedError(result) |
483 | 483 |
if error: |
484 | 484 |
(errcls, args) = error |
485 |
raise errcls, args |
|
485 |
raise errcls(args) |
b/lib/http/client.py | ||
---|---|---|
319 | 319 |
|
320 | 320 |
""" |
321 | 321 |
try: |
322 |
pclient = self._pool.pop(identity)
|
|
322 |
pclient = self._pool.pop(identity) |
|
323 | 323 |
except KeyError: |
324 | 324 |
# Need to create new client |
325 | 325 |
client = self._GetHttpClientCreator()(self._curl_config_fn) |
b/lib/hypervisor/hv_base.py | ||
---|---|---|
386 | 386 |
key = splitfields[0].strip() |
387 | 387 |
val = splitfields[1].strip() |
388 | 388 |
if key == "MemTotal": |
389 |
result["memory_total"] = int(val.split()[0])/1024
|
|
389 |
result["memory_total"] = int(val.split()[0]) / 1024
|
|
390 | 390 |
elif key in ("MemFree", "Buffers", "Cached"): |
391 |
sum_free += int(val.split()[0])/1024
|
|
391 |
sum_free += int(val.split()[0]) / 1024
|
|
392 | 392 |
elif key == "Active": |
393 |
result["memory_dom0"] = int(val.split()[0])/1024
|
|
393 |
result["memory_dom0"] = int(val.split()[0]) / 1024
|
|
394 | 394 |
except (ValueError, TypeError), err: |
395 | 395 |
raise errors.HypervisorError("Failed to compute memory usage: %s" % |
396 | 396 |
(err,)) |
b/lib/hypervisor/hv_kvm.py | ||
---|---|---|
267 | 267 |
|
268 | 268 |
arg_list = cmdline.split("\x00") |
269 | 269 |
while arg_list: |
270 |
arg = arg_list.pop(0)
|
|
270 |
arg = arg_list.pop(0) |
|
271 | 271 |
if arg == "-name": |
272 | 272 |
instance = arg_list.pop(0) |
273 | 273 |
elif arg == "-m": |
... | ... | |
526 | 526 |
""" |
527 | 527 |
_, v_major, v_min, _ = self._GetKVMVersion() |
528 | 528 |
|
529 |
pidfile = self._InstancePidFile(instance.name)
|
|
529 |
pidfile = self._InstancePidFile(instance.name) |
|
530 | 530 |
kvm = constants.KVM_PATH |
531 | 531 |
kvm_cmd = [kvm] |
532 | 532 |
# used just by the vnc server, if enabled |
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
163 | 163 |
@return: tuple (name, id, memory, vcpus, stat, times) |
164 | 164 |
|
165 | 165 |
""" |
166 |
xm_list = self._GetXMList(instance_name=="Domain-0")
|
|
166 |
xm_list = self._GetXMList(instance_name == "Domain-0")
|
|
167 | 167 |
result = None |
168 | 168 |
for data in xm_list: |
169 | 169 |
if data[0] == instance_name: |
b/lib/netutils.py | ||
---|---|---|
58 | 58 |
|
59 | 59 |
# Dict used to convert from a string representing an IP family to an IP |
60 | 60 |
# version |
61 |
_NAME_TO_IP_VER = {
|
|
61 |
_NAME_TO_IP_VER = { |
|
62 | 62 |
"inet": constants.IP4_VERSION, |
63 | 63 |
"inet6": constants.IP6_VERSION, |
64 | 64 |
} |
... | ... | |
417 | 417 |
assert 0 <= prefix <= cls.iplen |
418 | 418 |
target_int = cls._GetIPIntFromString(subnet[0]) |
419 | 419 |
# Convert prefix netmask to integer value of netmask |
420 |
netmask_int = (2**cls.iplen)-1 ^ ((2**cls.iplen)-1 >> prefix)
|
|
420 |
netmask_int = (2 ** cls.iplen) - 1 ^ ((2 ** cls.iplen) - 1 >> prefix)
|
|
421 | 421 |
# Calculate hostmask |
422 |
hostmask_int = netmask_int ^ (2**cls.iplen)-1
|
|
422 |
hostmask_int = netmask_int ^ (2 ** cls.iplen) - 1
|
|
423 | 423 |
# Calculate network address by and'ing netmask |
424 | 424 |
network_int = target_int & netmask_int |
425 | 425 |
# Calculate broadcast address by or'ing hostmask |
b/lib/objects.py | ||
---|---|---|
662 | 662 |
|
663 | 663 |
""" |
664 | 664 |
if self.dev_type == constants.LD_LV: |
665 |
val = "<LogicalVolume(/dev/%s/%s" % self.logical_id
|
|
665 |
val = "<LogicalVolume(/dev/%s/%s" % self.logical_id |
|
666 | 666 |
elif self.dev_type in constants.LDS_DRBD: |
667 | 667 |
node_a, node_b, port, minor_a, minor_b = self.logical_id[:5] |
668 | 668 |
val = "<DRBD8(" |
... | ... | |
789 | 789 |
node = self.primary_node |
790 | 790 |
|
791 | 791 |
if lvmap is None: |
792 |
lvmap = { node : [] } |
|
792 |
lvmap = { |
|
793 |
node: [], |
|
794 |
} |
|
793 | 795 |
ret = lvmap |
794 | 796 |
else: |
795 | 797 |
if not node in lvmap: |
... | ... | |
801 | 803 |
|
802 | 804 |
for dev in devs: |
803 | 805 |
if dev.dev_type == constants.LD_LV: |
804 |
lvmap[node].append(dev.logical_id[0]+"/"+dev.logical_id[1])
|
|
806 |
lvmap[node].append(dev.logical_id[0] + "/" + dev.logical_id[1])
|
|
805 | 807 |
|
806 | 808 |
elif dev.dev_type in constants.LDS_DRBD: |
807 | 809 |
if dev.children: |
b/lib/opcodes.py | ||
---|---|---|
1536 | 1536 |
("name", ht.NoDefault, ht.TMaybeString, None), |
1537 | 1537 |
] |
1538 | 1538 |
|
1539 |
|
|
1539 | 1540 |
# Test opcodes |
1540 | 1541 |
class OpTestDelay(OpCode): |
1541 | 1542 |
"""Sleeps for a configured amount of time. |
b/lib/rapi/baserlib.py | ||
---|---|---|
53 | 53 |
(field_id, field_uri) = uri_fields |
54 | 54 |
|
55 | 55 |
def _MapId(m_id): |
56 |
return { field_id: m_id, field_uri: uri_format % m_id, } |
|
56 |
return { |
|
57 |
field_id: m_id, |
|
58 |
field_uri: uri_format % m_id, |
|
59 |
} |
|
57 | 60 |
|
58 | 61 |
# Make sure the result is sorted, makes it nicer to look at and simplifies |
59 | 62 |
# unittests. |
b/lib/rapi/rlib2.py | ||
---|---|---|
664 | 664 |
}) |
665 | 665 |
|
666 | 666 |
|
667 |
|
|
668 | 667 |
class R_2_groups_name_modify(baserlib.R_Generic): |
669 | 668 |
"""/2/groups/[group_name]/modify resource. |
670 | 669 |
|
b/lib/runtime.py | ||
---|---|---|
187 | 187 |
_priv_lock.release() |
188 | 188 |
|
189 | 189 |
return _priv |
190 |
|
b/lib/server/confd.py | ||
---|---|---|
82 | 82 |
logging.debug(err) |
83 | 83 |
return |
84 | 84 |
|
85 |
answer = self.processor.ExecQuery(query, ip, port)
|
|
85 |
answer = self.processor.ExecQuery(query, ip, port) |
|
86 | 86 |
if answer is not None: |
87 | 87 |
try: |
88 | 88 |
self.enqueue_send(ip, port, confd.PackMagic(answer)) |
b/lib/server/masterd.py | ||
---|---|---|
113 | 113 |
|
114 | 114 |
""" |
115 | 115 |
_MAX_UNHANDLED = 1 |
116 |
|
|
116 | 117 |
def __init__(self, server, connected_socket, client_address, family): |
117 | 118 |
daemon.AsyncTerminatedMessageStream.__init__(self, connected_socket, |
118 | 119 |
client_address, |
b/lib/server/noded.py | ||
---|---|---|
711 | 711 |
""" |
712 | 712 |
return backend.DemoteFromMC() |
713 | 713 |
|
714 |
|
|
715 | 714 |
@staticmethod |
716 | 715 |
def perspective_node_powercycle(params): |
717 | 716 |
"""Tries to powercycle the nod. |
... | ... | |
720 | 719 |
hypervisor_type = params[0] |
721 | 720 |
return backend.PowercycleNode(hypervisor_type) |
722 | 721 |
|
723 |
|
|
724 | 722 |
# cluster -------------------------- |
725 | 723 |
|
726 | 724 |
@staticmethod |
b/lib/utils/io.py | ||
---|---|---|
511 | 511 |
try: |
512 | 512 |
fd.seek(0, 2) |
513 | 513 |
pos = fd.tell() |
514 |
pos = max(0, pos-4096)
|
|
514 |
pos = max(0, pos - 4096)
|
|
515 | 515 |
fd.seek(pos, 0) |
516 | 516 |
raw_data = fd.read() |
517 | 517 |
finally: |
b/lib/utils/process.py | ||
---|---|---|
84 | 84 |
__slots__ = ["exit_code", "signal", "stdout", "stderr", |
85 | 85 |
"failed", "fail_reason", "cmd"] |
86 | 86 |
|
87 |
|
|
88 | 87 |
def __init__(self, exit_code, signal_, stdout, stderr, cmd, timeout_action, |
89 | 88 |
timeout): |
90 | 89 |
self.cmd = cmd |
b/lib/utils/retry.py | ||
---|---|---|
206 | 206 |
|
207 | 207 |
""" |
208 | 208 |
rdict = {} |
209 |
|
|
209 | 210 |
def helper(*innerargs): |
210 | 211 |
# pylint: disable-msg=W0142 |
211 | 212 |
result = rdict["result"] = fn(*innerargs) |
b/lib/utils/text.py | ||
---|---|---|
338 | 338 |
resu = "" |
339 | 339 |
for char in text: |
340 | 340 |
c = ord(char) |
341 |
if char == "\t":
|
|
341 |
if char == "\t": |
|
342 | 342 |
resu += r"\t" |
343 | 343 |
elif char == "\n": |
344 | 344 |
resu += r"\n" |
b/lib/watcher/nodemaint.py | ||
---|---|---|
131 | 131 |
|
132 | 132 |
""" |
133 | 133 |
my_name = netutils.Hostname.GetSysName() |
134 |
req = confd.client.ConfdClientRequest(type=
|
|
135 |
constants.CONFD_REQ_NODE_ROLE_BYNAME,
|
|
136 |
query=my_name)
|
|
134 |
req = \
|
|
135 |
confd.client.ConfdClientRequest(type=constants.CONFD_REQ_NODE_ROLE_BYNAME,
|
|
136 |
query=my_name) |
|
137 | 137 |
self.confd_client.SendRequest(req, async=False, coverage=-1) |
138 | 138 |
timed_out, _, _ = self.confd_client.WaitForReply(req.rsalt) |
139 | 139 |
if not timed_out: |
b/tools/burnin | ||
---|---|---|
51 | 51 |
2: "" |
52 | 52 |
} |
53 | 53 |
|
54 |
|
|
54 | 55 |
class InstanceDown(Exception): |
55 | 56 |
"""The checked instance was not up""" |
56 | 57 |
|
... | ... | |
73 | 74 |
""" |
74 | 75 |
if args: |
75 | 76 |
msg = msg % args |
76 |
indent = kwargs.get('indent', 0)
|
|
77 |
sys.stdout.write("%*s%s%s\n" % (2*indent, "",
|
|
77 |
indent = kwargs.get("indent", 0)
|
|
78 |
sys.stdout.write("%*s%s%s\n" % (2 * indent, "",
|
|
78 | 79 |
LOG_HEADERS.get(indent, " "), msg)) |
79 | 80 |
sys.stdout.flush() |
80 | 81 |
|
... | ... | |
564 | 565 |
Log(msg, indent=2) |
565 | 566 |
|
566 | 567 |
op = opcodes.OpInstanceCreate(instance_name=instance, |
567 |
disks = [ {"size": size}
|
|
568 |
for size in self.disk_size],
|
|
568 |
disks=[{"size": size}
|
|
569 |
for size in self.disk_size], |
|
569 | 570 |
disk_template=self.opts.disk_template, |
570 | 571 |
nics=self.opts.nics, |
571 | 572 |
mode=constants.INSTANCE_CREATE, |
... | ... | |
719 | 720 |
ignore_failures=True) |
720 | 721 |
imp_dir = utils.PathJoin(constants.EXPORT_DIR, full_name) |
721 | 722 |
imp_op = opcodes.OpInstanceCreate(instance_name=instance, |
722 |
disks = [ {"size": size}
|
|
723 |
for size in self.disk_size],
|
|
723 |
disks=[{"size": size}
|
|
724 |
for size in self.disk_size], |
|
724 | 725 |
disk_template=self.opts.disk_template, |
725 | 726 |
nics=self.opts.nics, |
726 | 727 |
mode=constants.INSTANCE_IMPORT, |
... | ... | |
996 | 997 |
if opts.do_replace1 and opts.disk_template in constants.DTS_INT_MIRROR: |
997 | 998 |
self.BurnReplaceDisks1D8() |
998 | 999 |
if (opts.do_replace2 and len(self.nodes) > 2 and |
999 |
opts.disk_template in constants.DTS_INT_MIRROR) :
|
|
1000 |
opts.disk_template in constants.DTS_INT_MIRROR): |
|
1000 | 1001 |
self.BurnReplaceDisks2() |
1001 | 1002 |
|
1002 | 1003 |
if (opts.disk_template in constants.DTS_GROWABLE and |
b/tools/cluster-merge | ||
---|---|---|
134 | 134 |
constants.INSTST_RUNNING, |
135 | 135 |
constants.INSTST_ERRORUP, |
136 | 136 |
]) |
137 |
|
|
137 | 138 |
def __init__(self, clusters, pause_period, groups, restart, params, |
138 | 139 |
stop_instances): |
139 | 140 |
"""Initialize object with sane defaults and infos required. |
... | ... | |
160 | 161 |
if self.restart == _RESTART_UP: |
161 | 162 |
raise NotImplementedError |
162 | 163 |
|
163 |
|
|
164 | 164 |
def Setup(self): |
165 | 165 |
"""Sets up our end so we can do the merger. |
166 | 166 |
|
b/tools/ganeti-listrunner | ||
---|---|---|
338 | 338 |
|
339 | 339 |
WriteLog("SUCCESS: command output follows", logfile) |
340 | 340 |
for line in output.split("\n"): |
341 |
WriteLog("output = %s" %line, logfile) |
|
341 |
WriteLog("output = %s" % line, logfile)
|
|
342 | 342 |
WriteLog("command execution completed", logfile) |
343 | 343 |
session.close() |
344 | 344 |
|
b/tools/lvmstrap | ||
---|---|---|
85 | 85 |
|
86 | 86 |
#: Minimum partition size to be considered (1 GB) |
87 | 87 |
PART_MINSIZE = 1024 * 1024 * 1024 |
88 |
MBR_MAX_SIZE = 2 * 10**12 |
|
88 |
MBR_MAX_SIZE = 2 * (10 ** 12) |
|
89 |
|
|
89 | 90 |
|
90 | 91 |
class Error(Exception): |
91 | 92 |
"""Generic exception""" |
... | ... | |
192 | 193 |
action="store_true", default=False, |
193 | 194 |
help="use sfdisk instead of parted") |
194 | 195 |
|
195 |
|
|
196 | 196 |
options, args = parser.parse_args() |
197 | 197 |
if len(args) != 1: |
198 | 198 |
Usage() |
... | ... | |
232 | 232 |
match = PART_RE.match(disk) |
233 | 233 |
if match: |
234 | 234 |
# this is a partition, which resides in /sys/block under a different name |
235 |
disk = "%s/%s" % (match.group(1), disk)
|
|
235 |
disk = "%s/%s" % (match.group(1), disk) |
|
236 | 236 |
return "/sys/block/%s" % disk |
237 | 237 |
|
238 | 238 |
|
... | ... | |
776 | 776 |
result = ExecCommand("parted -s /dev/%s mklabel %s" % (name, label_type)) |
777 | 777 |
if result.failed: |
778 | 778 |
raise OperationalError("Critical: failed to create %s label on %s" % |
779 |
(label_type,name)) |
|
779 |
(label_type, name))
|
|
780 | 780 |
result = ExecCommand("parted -s /dev/%s mkpart pri ext2 1 100%%" % name) |
781 | 781 |
if result.failed: |
782 | 782 |
raise OperationalError("Critical: failed to create partition on %s" % |
... | ... | |
892 | 892 |
" LV count: %s, size: %s, free: %s." % |
893 | 893 |
(vgname, lv_count, vg_size, vg_free)) |
894 | 894 |
|
895 |
|
|
896 | 895 |
disklist = ValidateDiskList(options) |
897 | 896 |
|
898 | 897 |
for disk in disklist: |
Also available in: Unified diff