Revision 53fde1ac
b/lib/hypervisor/hv_base.py | ||
---|---|---|
1 | 1 |
# |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. |
|
4 |
# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2012, 2013 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
520 | 520 |
result = utils.RunCmd(["reboot", "-n", "-f"]) |
521 | 521 |
if not result: |
522 | 522 |
logging.error("Can't run shutdown: %s", result.output) |
523 |
|
|
524 |
@staticmethod |
|
525 |
def _FormatVerifyResults(msgs): |
|
526 |
"""Formats the verification results, given a list of errors. |
|
527 |
|
|
528 |
@param msgs: list of errors, possibly empty |
|
529 |
@return: overall problem description if something is wrong, |
|
530 |
C{None} otherwise |
|
531 |
|
|
532 |
""" |
|
533 |
if msgs: |
|
534 |
return "; ".join(msgs) |
|
535 |
else: |
|
536 |
return None |
b/test/py/ganeti.hypervisor_unittest.py | ||
---|---|---|
1 | 1 |
#!/usr/bin/python |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2010 Google Inc. |
|
4 |
# Copyright (C) 2010, 2013 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
28 | 28 |
from ganeti import objects |
29 | 29 |
from ganeti import errors |
30 | 30 |
from ganeti import hypervisor |
31 |
from ganeti.hypervisor import hv_base |
|
31 | 32 |
|
32 | 33 |
import testutils |
33 | 34 |
|
... | ... | |
48 | 49 |
(hv, pname)) |
49 | 50 |
|
50 | 51 |
|
52 |
class TestBase(unittest.TestCase): |
|
53 |
def testVerifyResults(self): |
|
54 |
fn = hv_base.BaseHypervisor._FormatVerifyResults |
|
55 |
# FIXME: use assertIsNone when py 2.7 is minimum supported version |
|
56 |
self.assertEqual(fn([]), None) |
|
57 |
self.assertEqual(fn(["a"]), "a") |
|
58 |
self.assertEqual(fn(["a", "b"]), "a; b") |
|
59 |
|
|
60 |
|
|
51 | 61 |
if __name__ == "__main__": |
52 | 62 |
testutils.GanetiTestProgram() |
Also available in: Unified diff