44from oslo_log import log as logging
55from webob import exc
66
7+ from coriolis import exception
78from coriolis .api import common
9+ from coriolis .api import wsgi as api_wsgi
810from coriolis .api .v1 import utils as api_utils
911from coriolis .api .v1 .views import deployment_view
10- from coriolis .api import wsgi as api_wsgi
1112from coriolis .deployments import api
1213from coriolis .endpoints import api as endpoints_api
13- from coriolis import exception
1414from coriolis .policies import deployments as deployment_policies
1515
16-
1716LOG = logging .getLogger (__name__ )
1817
1918
@@ -27,23 +26,24 @@ def show(self, req, id):
2726 context = req .environ ["coriolis.context" ]
2827 context .can (deployment_policies .get_deployments_policy_label ("show" ))
2928 include_task_info = api_utils .get_bool_url_arg (
30- req , "include_task_info" , default = False )
29+ req , "include_task_info" , default = False
30+ )
3131 deployment = self ._deployment_api .get_deployment (
32- context , id ,
33- include_task_info = include_task_info )
32+ context , id , include_task_info = include_task_info
33+ )
3434 if not deployment :
3535 raise exc .HTTPNotFound ()
3636
3737 return deployment_view .single (deployment )
3838
3939 def _list (self , req ):
40- show_deleted = api_utils .get_bool_url_arg (
41- req , "show_deleted" , default = False )
40+ show_deleted = api_utils .get_bool_url_arg (req , "show_deleted" , default = False )
4241 context = req .environ ["coriolis.context" ]
4342 context .show_deleted = show_deleted
4443 context .can (deployment_policies .get_deployments_policy_label ("list" ))
4544 include_task_info = api_utils .get_bool_url_arg (
46- req , "include_task_info" , default = False )
45+ req , "include_task_info" , default = False
46+ )
4747
4848 marker , limit = common .get_paging_params (req )
4949 sort_keys , sort_dirs = common .get_sort_params (req )
@@ -53,9 +53,12 @@ def _list(self, req):
5353 context ,
5454 include_tasks = include_task_info ,
5555 include_task_info = include_task_info ,
56- marker = marker , limit = limit ,
57- sort_keys = sort_keys , sort_dirs = sort_dirs ,
58- ))
56+ marker = marker ,
57+ limit = limit ,
58+ sort_keys = sort_keys ,
59+ sort_dirs = sort_dirs ,
60+ )
61+ )
5962
6063 def index (self , req ):
6164 return self ._list (req )
@@ -72,36 +75,51 @@ def _validate_deployment_input(self, context, body):
7275 if not transfer_id :
7376 raise exc .HTTPBadRequest (
7477 explanation = "Missing 'transfer_id' field from deployment "
75- "body. A deployment can be created strictly "
76- "based on an existing Transfer." )
78+ "body. A deployment can be created strictly "
79+ "based on an existing Transfer."
80+ )
7781
7882 clone_disks = deployment .get ("clone_disks" , True )
7983 force = deployment .get ("force" , False )
8084 skip_os_morphing = deployment .get ("skip_os_morphing" , False )
8185 instance_osmorphing_minion_pool_mappings = deployment .get (
82- 'instance_osmorphing_minion_pool_mappings' , {})
86+ 'instance_osmorphing_minion_pool_mappings' , {}
87+ )
8388 user_scripts = deployment .get ('user_scripts' , {})
8489 api_utils .validate_user_scripts (user_scripts )
8590 return (
86- transfer_id , force , clone_disks , skip_os_morphing ,
91+ transfer_id ,
92+ force ,
93+ clone_disks ,
94+ skip_os_morphing ,
8795 instance_osmorphing_minion_pool_mappings ,
88- user_scripts )
96+ user_scripts ,
97+ )
8998
9099 def create (self , req , body ):
91100 context = req .environ ['coriolis.context' ]
92101 context .can (deployment_policies .get_deployments_policy_label ("create" ))
93102
94- (transfer_id , force , clone_disks , skip_os_morphing ,
95- instance_osmorphing_minion_pool_mappings ,
96- user_scripts ) = self ._validate_deployment_input (
97- context , body )
103+ (
104+ transfer_id ,
105+ force ,
106+ clone_disks ,
107+ skip_os_morphing ,
108+ instance_osmorphing_minion_pool_mappings ,
109+ user_scripts ,
110+ ) = self ._validate_deployment_input (context , body )
98111
99112 # NOTE: destination environment for transfer should have been
100113 # validated upon its creation.
101114 deployment = self ._deployment_api .deploy_transfer_instances (
102- context , transfer_id , instance_osmorphing_minion_pool_mappings ,
103- clone_disks , force , skip_os_morphing ,
104- user_scripts = user_scripts )
115+ context ,
116+ transfer_id ,
117+ instance_osmorphing_minion_pool_mappings ,
118+ clone_disks ,
119+ force ,
120+ skip_os_morphing ,
121+ user_scripts = user_scripts ,
122+ )
105123
106124 return deployment_view .single (deployment )
107125
0 commit comments