Completed
Pull Request — master (#415)
by Anthony
02:06
created

GetImageByNameAction.run()   A

Complexity

Conditions 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 7
rs 9.4285
1
from lib import actions
2
3
__all__ = [
4
    'GetImageByNameAction',
5
]
6
7
8
class GetImageByNameAction(actions.BaseAction):
9
10
    def run(self, region, location, image_name):
11
        driver = self._get_compute_driver(region)
12
        location = driver.ex_get_location_by_id(location)
13
        images = driver.list_images(location=location)
14
        image = list(filter(lambda x: x.name == image_name,
15
                            images))[0]
16
        return self.resultsets.formatter(image)
17