mirror of
https://github.com/gryf/mistral-evacuate.git
synced 2026-02-16 14:05:54 +01:00
Small code refactoring
This commit is contained in:
@@ -8,6 +8,10 @@ from mistral.actions.openstack.actions import NovaAction
|
|||||||
from mistral.workflow.utils import Result
|
from mistral.workflow.utils import Result
|
||||||
|
|
||||||
|
|
||||||
|
class FilterVmException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FilterVmAction(NovaAction):
|
class FilterVmAction(NovaAction):
|
||||||
"""
|
"""
|
||||||
Filter and return VMs whith the flag 'evacuate' either on vm metadtata
|
Filter and return VMs whith the flag 'evacuate' either on vm metadtata
|
||||||
@@ -31,11 +35,10 @@ class FilterVmAction(NovaAction):
|
|||||||
return Result(error='evacuate for vm %s is disabled' % self._uuid)
|
return Result(error='evacuate for vm %s is disabled' % self._uuid)
|
||||||
|
|
||||||
# ether is no metadata for vm - check flavor
|
# ether is no metadata for vm - check flavor
|
||||||
flavors = client.flavors.list()
|
|
||||||
try:
|
try:
|
||||||
flavor = filter(lambda x: x.id == self._flavor, flavors)[0]
|
flavor = [x for x in client.flavors.list() if x.id == '1'][0]
|
||||||
except:
|
except IndexError:
|
||||||
raise Exception('Flavor not found')
|
raise FilterVmException('Flavor not found')
|
||||||
|
|
||||||
evacuate = flavor.get_keys().get('evacuation:evacuate')
|
evacuate = flavor.get_keys().get('evacuation:evacuate')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user