Revision 2584d4a4
b/lib/cmdlib.py | ||
---|---|---|
538 | 538 |
raise errors.OpPrereqError("Invalid mac prefix given '%s'" % |
539 | 539 |
self.op.mac_prefix) |
540 | 540 |
|
541 |
if self.op.hypervisor_type not in hypervisor.VALID_HTYPES:
|
|
541 |
if self.op.hypervisor_type not in constants.HYPER_TYPES:
|
|
542 | 542 |
raise errors.OpPrereqError("Invalid hypervisor type given '%s'" % |
543 | 543 |
self.op.hypervisor_type) |
544 | 544 |
|
b/lib/constants.py | ||
---|---|---|
147 | 147 |
INSTANCE_REBOOT_SOFT = "soft" |
148 | 148 |
INSTANCE_REBOOT_HARD = "hard" |
149 | 149 |
INSTANCE_REBOOT_FULL = "full" |
150 |
|
|
151 |
# Hypervisor constants |
|
152 |
HT_XEN30 = "xen-3.0" |
|
153 |
HT_FAKE = "fake" |
|
154 |
|
|
155 |
HYPER_TYPES = frozenset([HT_XEN30, HT_FAKE]) |
b/lib/hypervisor.py | ||
---|---|---|
33 | 33 |
from ganeti import constants |
34 | 34 |
from ganeti.errors import HypervisorError |
35 | 35 |
|
36 |
_HT_XEN30 = "xen-3.0" |
|
37 |
_HT_FAKE = "fake" |
|
38 |
|
|
39 |
VALID_HTYPES = (_HT_XEN30, _HT_FAKE) |
|
40 | 36 |
|
41 | 37 |
def GetHypervisor(): |
42 | 38 |
"""Return a Hypervisor instance. |
... | ... | |
46 | 42 |
|
47 | 43 |
""" |
48 | 44 |
ht_kind = ssconf.SimpleStore().GetHypervisorType() |
49 |
if ht_kind == _HT_XEN30:
|
|
45 |
if ht_kind == constants.HT_XEN30:
|
|
50 | 46 |
cls = XenHypervisor |
51 |
elif ht_kind == _HT_FAKE:
|
|
47 |
elif ht_kind == constants.HT_FAKE:
|
|
52 | 48 |
cls = FakeHypervisor |
53 | 49 |
else: |
54 | 50 |
raise HypervisorError("Unknown hypervisor type '%s'" % ht_kind) |
Also available in: Unified diff