1414
1515"""Volume v2 Type action implementations"""
1616
17+ import logging
18+
1719from osc_lib .cli import parseractions
1820from osc_lib .command import command
1921from osc_lib import exceptions
2426from openstackclient .identity import common as identity_common
2527
2628
29+ LOG = logging .getLogger (__name__ )
30+
31+
2732class CreateVolumeType (command .ShowOne ):
2833 """Create new volume type"""
2934
@@ -190,16 +195,15 @@ def take_action(self, parsed_args):
190195 ** kwargs
191196 )
192197 except Exception as e :
193- self . app . log .error (_ ("Failed to update volume type name or"
194- " description: %s" ) % str ( e ) )
198+ LOG .error (_ ("Failed to update volume type name or"
199+ " description: %s" ), e )
195200 result += 1
196201
197202 if parsed_args .property :
198203 try :
199204 volume_type .set_keys (parsed_args .property )
200205 except Exception as e :
201- self .app .log .error (_ ("Failed to set volume type"
202- " property: %s" ) % str (e ))
206+ LOG .error (_ ("Failed to set volume type property: %s" ), e )
203207 result += 1
204208
205209 if parsed_args .project :
@@ -213,13 +217,13 @@ def take_action(self, parsed_args):
213217 volume_client .volume_type_access .add_project_access (
214218 volume_type .id , project_info .id )
215219 except Exception as e :
216- self . app . log . error (_ ("Failed to set volume type access to"
217- " project: %s" ) % str ( e ) )
220+ LOG . error (_ ("Failed to set volume type access to "
221+ " project: %s" ), e )
218222 result += 1
219223
220224 if result > 0 :
221225 raise exceptions .CommandError (_ ("Command Failed: One or more of"
222- " the operations failed" ))
226+ " the operations failed" ))
223227
224228
225229class ShowVolumeType (command .ShowOne ):
@@ -284,8 +288,7 @@ def take_action(self, parsed_args):
284288 try :
285289 volume_type .unset_keys (parsed_args .property )
286290 except Exception as e :
287- self .app .log .error (_ ("Failed to unset volume type property: %s"
288- ) % str (e ))
291+ LOG .error (_ ("Failed to unset volume type property: %s" ), e )
289292 result += 1
290293
291294 if parsed_args .project :
@@ -299,8 +302,8 @@ def take_action(self, parsed_args):
299302 volume_client .volume_type_access .remove_project_access (
300303 volume_type .id , project_info .id )
301304 except Exception as e :
302- self . app . log . error (_ ("Failed to remove volume type access from"
303- " project: %s" ) % str ( e ) )
305+ LOG . error (_ ("Failed to remove volume type access from "
306+ " project: %s" ), e )
304307 result += 1
305308
306309 if result > 0 :
0 commit comments