~mordred/nova/volume-cleanup

« back to all changes in this revision

Viewing changes to nova/virt/xenapi/vm_utils.py

  • Committer: Tarmac
  • Author(s): Matthew Hooker
  • Date: 2011-07-29 19:48:58 UTC
  • mfrom: (1336.2.13 pylint-fixes)
  • Revision ID: tarmac-20110729194858-jpt7ggbes5v1z1fz
Fix various errors discovered by pylint and pyflakes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
85
85
    DISK = 2
86
86
    DISK_RAW = 3
87
87
    DISK_VHD = 4
 
88
    _ids = (KERNEL, RAMDISK, DISK, DISK_RAW, DISK_VHD)
88
89
 
89
90
    KERNEL_STR = "kernel"
90
91
    RAMDISK_STR = "ramdisk"
91
92
    DISK_STR = "os"
92
93
    DISK_RAW_STR = "os_raw"
93
94
    DISK_VHD_STR = "vhd"
 
95
    _strs = (KERNEL_STR, RAMDISK_STR, DISK_STR, DISK_RAW_STR, DISK_VHD_STR)
94
96
 
95
97
    @classmethod
96
98
    def to_string(cls, image_type):
97
 
        if image_type == ImageType.KERNEL:
98
 
            return ImageType.KERNEL_STR
99
 
        elif image_type == ImageType.RAMDISK:
100
 
            return ImageType.RAMDISK_STR
101
 
        elif image_type == ImageType.DISK:
102
 
            return ImageType.DISK_STR
103
 
        elif image_type == ImageType.DISK_RAW:
104
 
            return ImageType.DISK_RAW_STR
105
 
        elif image_type == ImageType.DISK_VHD:
106
 
            return ImageType.VHD_STR
 
99
        return dict(zip(ImageType._ids, ImageType._strs)).get(image_type)
107
100
 
108
101
    @classmethod
109
102
    def from_string(cls, image_type_str):
110
 
        if image_type_str == ImageType.KERNEL_STR:
111
 
            return ImageType.KERNEL
112
 
        elif image_type == ImageType.RAMDISK_STR:
113
 
            return ImageType.RAMDISK
114
 
        elif image_type == ImageType.DISK_STR:
115
 
            return ImageType.DISK
116
 
        elif image_type == ImageType.DISK_RAW_STR:
117
 
            return ImageType.DISK_RAW
118
 
        elif image_type == ImageType.DISK_VHD_STR:
119
 
            return ImageType.VHD
 
103
        return dict(zip(ImageType._strs, ImageType._ids)).get(image_type_str)
120
104
 
121
105
 
122
106
class VMHelper(HelperBase):