diff options
| author | Matthew Hooker <matt@cloudscaling.com> | 2011-07-29 19:48:58 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-07-29 19:48:58 +0000 |
| commit | 6703e33a68d0653f486d679337b4dfc4239eba34 (patch) | |
| tree | b059d3f8762abcdd7086757a11a26d635ba28563 /nova/virt | |
| parent | bbfd483a5cb720eeee97787b10210129b5e4b38e (diff) | |
| parent | 798dbb567be3e36eb2d6f0fbe27aa2eced0345d4 (diff) | |
Fix various errors discovered by pylint and pyflakes.
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/xenapi/vm_utils.py | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 62863c6d8..2ed83a90a 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -85,38 +85,22 @@ class ImageType: DISK = 2 DISK_RAW = 3 DISK_VHD = 4 + _ids = (KERNEL, RAMDISK, DISK, DISK_RAW, DISK_VHD) KERNEL_STR = "kernel" RAMDISK_STR = "ramdisk" DISK_STR = "os" DISK_RAW_STR = "os_raw" DISK_VHD_STR = "vhd" + _strs = (KERNEL_STR, RAMDISK_STR, DISK_STR, DISK_RAW_STR, DISK_VHD_STR) @classmethod def to_string(cls, image_type): - if image_type == ImageType.KERNEL: - return ImageType.KERNEL_STR - elif image_type == ImageType.RAMDISK: - return ImageType.RAMDISK_STR - elif image_type == ImageType.DISK: - return ImageType.DISK_STR - elif image_type == ImageType.DISK_RAW: - return ImageType.DISK_RAW_STR - elif image_type == ImageType.DISK_VHD: - return ImageType.VHD_STR + return dict(zip(ImageType._ids, ImageType._strs)).get(image_type) @classmethod def from_string(cls, image_type_str): - if image_type_str == ImageType.KERNEL_STR: - return ImageType.KERNEL - elif image_type == ImageType.RAMDISK_STR: - return ImageType.RAMDISK - elif image_type == ImageType.DISK_STR: - return ImageType.DISK - elif image_type == ImageType.DISK_RAW_STR: - return ImageType.DISK_RAW - elif image_type == ImageType.DISK_VHD_STR: - return ImageType.VHD + return dict(zip(ImageType._strs, ImageType._ids)).get(image_type_str) class VMHelper(HelperBase): |
