Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-ganeti
Commits
a9369c6e
Commit
a9369c6e
authored
16 years ago
by
Michael Hanselmann
Browse files
Options
Downloads
Patches
Plain Diff
Use dict instead of if/elif map for hypervisor classes
Reviewed-by: iustinp
parent
a2d32034
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/hypervisor/__init__.py
+11
-7
11 additions, 7 deletions
lib/hypervisor/__init__.py
with
11 additions
and
7 deletions
lib/hypervisor/__init__.py
+
11
−
7
View file @
a9369c6e
...
...
@@ -31,6 +31,13 @@ from ganeti.hypervisor import hv_fake
from
ganeti.hypervisor
import
hv_xen
_HYPERVISOR_MAP
=
{
constants
.
HT_XEN_PVM30
:
hv_xen
.
XenPvmHypervisor
,
constants
.
HT_XEN_HVM31
:
hv_xen
.
XenHvmHypervisor
,
constants
.
HT_FAKE
:
hv_fake
.
FakeHypervisor
,
}
def
GetHypervisor
():
"""
Return a Hypervisor instance.
...
...
@@ -39,12 +46,9 @@ def GetHypervisor():
"""
ht_kind
=
ssconf
.
SimpleStore
().
GetHypervisorType
()
if
ht_kind
==
constants
.
HT_XEN_PVM30
:
cls
=
hv_xen
.
XenPvmHypervisor
elif
ht_kind
==
constants
.
HT_XEN_HVM31
:
cls
=
hv_xen
.
XenHvmHypervisor
elif
ht_kind
==
constants
.
HT_FAKE
:
cls
=
hv_fake
.
FakeHypervisor
else
:
if
ht_kind
not
in
_HYPERVISOR_MAP
:
raise
errors
.
HypervisorError
(
"
Unknown hypervisor type
'
%s
'"
%
ht_kind
)
cls
=
_HYPERVISOR_MAP
[
ht_kind
]
return
cls
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment