Revision 0b5303da
b/lib/backend.py | ||
---|---|---|
76 | 76 |
_IES_PID_FILE = "pid" |
77 | 77 |
_IES_CA_FILE = "ca" |
78 | 78 |
|
79 |
#: Valid LVS output line regex |
|
80 |
_LVSLINE_REGEX = re.compile("^ *([^|]+)\|([0-9.]+)\|([^|]{6})\|?$") |
|
81 |
|
|
79 | 82 |
|
80 | 83 |
class RPCFail(Exception): |
81 | 84 |
"""Class denoting RPC failure. |
... | ... | |
643 | 646 |
if result.failed: |
644 | 647 |
_Fail("Failed to list logical volumes, lvs output: %s", result.output) |
645 | 648 |
|
646 |
valid_line_re = re.compile("^ *([^|]+)\|([0-9.]+)\|([^|]{6})\|?$") |
|
647 | 649 |
for line in result.stdout.splitlines(): |
648 | 650 |
line = line.strip() |
649 |
match = valid_line_re.match(line)
|
|
651 |
match = _LVSLINE_REGEX.match(line)
|
|
650 | 652 |
if not match: |
651 | 653 |
logging.error("Invalid line returned from lvs output: '%s'", line) |
652 | 654 |
continue |
b/lib/cmdlib.py | ||
---|---|---|
1233 | 1233 |
ETYPE_ERROR = "ERROR" |
1234 | 1234 |
ETYPE_WARNING = "WARNING" |
1235 | 1235 |
|
1236 |
_HOOKS_INDENT_RE = re.compile("^", re.M) |
|
1237 |
|
|
1236 | 1238 |
class NodeImage(object): |
1237 | 1239 |
"""A class representing the logical and physical status of a node. |
1238 | 1240 |
|
... | ... | |
2267 | 2269 |
# their results |
2268 | 2270 |
if phase == constants.HOOKS_PHASE_POST: |
2269 | 2271 |
# Used to change hooks' output to proper indentation |
2270 |
indent_re = re.compile('^', re.M) |
|
2271 | 2272 |
feedback_fn("* Hooks Results") |
2272 | 2273 |
assert hooks_results, "invalid result from hooks" |
2273 | 2274 |
|
... | ... | |
2288 | 2289 |
self._ErrorIf(test, self.ENODEHOOKS, node_name, |
2289 | 2290 |
"Script %s failed, output:", script) |
2290 | 2291 |
if test: |
2291 |
output = indent_re.sub(' ', output)
|
|
2292 |
output = self._HOOKS_INDENT_RE.sub(' ', output)
|
|
2292 | 2293 |
feedback_fn("%s" % output) |
2293 | 2294 |
lu_result = 0 |
2294 | 2295 |
|
b/lib/rapi/connector.py | ||
---|---|---|
92 | 92 |
"""/ resource. |
93 | 93 |
|
94 | 94 |
""" |
95 |
@staticmethod |
|
96 |
def GET(): |
|
95 |
_ROOT_PATTERN = re.compile("^R_([a-zA-Z0-9]+)$") |
|
96 |
|
|
97 |
@classmethod |
|
98 |
def GET(cls): |
|
97 | 99 |
"""Show the list of mapped resources. |
98 | 100 |
|
99 | 101 |
@return: a dictionary with 'name' and 'uri' keys for each of them. |
100 | 102 |
|
101 | 103 |
""" |
102 |
root_pattern = re.compile('^R_([a-zA-Z0-9]+)$') |
|
103 |
|
|
104 | 104 |
rootlist = [] |
105 | 105 |
for handler in CONNECTOR.values(): |
106 |
m = root_pattern.match(handler.__name__)
|
|
106 |
m = cls._ROOT_PATTERN.match(handler.__name__)
|
|
107 | 107 |
if m: |
108 | 108 |
name = m.group(1) |
109 | 109 |
if name != 'root': |
b/lib/utils.py | ||
---|---|---|
100 | 100 |
_TIMEOUT_TERM, |
101 | 101 |
_TIMEOUT_KILL) = range(3) |
102 | 102 |
|
103 |
#: Shell param checker regexp |
|
104 |
_SHELLPARAM_REGEX = re.compile(r"^[-a-zA-Z0-9._+/:%@]+$") |
|
105 |
|
|
106 |
#: Unit checker regexp |
|
107 |
_PARSEUNIT_REGEX = re.compile(r"^([.\d]+)\s*([a-zA-Z]+)?$") |
|
108 |
|
|
109 |
#: ASN1 time regexp |
|
110 |
_ANS1_TIME_REGEX = re.compile(r"^(\d+)([-+]\d\d)(\d\d)$") |
|
111 |
|
|
103 | 112 |
|
104 | 113 |
class RunResult(object): |
105 | 114 |
"""Holds the result of running external programs. |
... | ... | |
1345 | 1354 |
@return: True if the word is 'safe' |
1346 | 1355 |
|
1347 | 1356 |
""" |
1348 |
return bool(re.match("^[-a-zA-Z0-9._+/:%@]+$", word))
|
|
1357 |
return bool(_SHELLPARAM_REGEX.match(word))
|
|
1349 | 1358 |
|
1350 | 1359 |
|
1351 | 1360 |
def BuildShellCmd(template, *args): |
... | ... | |
1414 | 1423 |
is always an int in MiB. |
1415 | 1424 |
|
1416 | 1425 |
""" |
1417 |
m = re.match('^([.\d]+)\s*([a-zA-Z]+)?$', str(input_string))
|
|
1426 |
m = _PARSEUNIT_REGEX.match(str(input_string))
|
|
1418 | 1427 |
if not m: |
1419 | 1428 |
raise errors.UnitParseError("Invalid format") |
1420 | 1429 |
|
... | ... | |
2805 | 2814 |
@param value: ASN1 GENERALIZEDTIME timestamp |
2806 | 2815 |
|
2807 | 2816 |
""" |
2808 |
m = re.match(r"^(\d+)([-+]\d\d)(\d\d)$", value)
|
|
2817 |
m = _ANS1_TIME_REGEX.match(value)
|
|
2809 | 2818 |
if m: |
2810 | 2819 |
# We have an offset |
2811 | 2820 |
asn1time = m.group(1) |
Also available in: Unified diff