@@ -394,32 +394,59 @@ def take_action(self, parsed_args):
394394 volume_client = self .app .client_manager .volume
395395 volume = utils .find_resource (volume_client .volumes , parsed_args .volume )
396396
397+ result = 0
397398 if parsed_args .size :
398- if volume .status != 'available' :
399- LOG .error (_ ("Volume is in %s state, it must be available "
400- "before size can be extended" ), volume .status )
401- return
402- if parsed_args .size <= volume .size :
403- LOG .error (_ ("New size must be greater than %s GB" ),
404- volume .size )
405- return
406- volume_client .volumes .extend (volume .id , parsed_args .size )
399+ try :
400+ if volume .status != 'available' :
401+ msg = (_ ("Volume is in %s state, it must be available "
402+ "before size can be extended" ), volume .status )
403+ raise exceptions .CommandError (msg )
404+ if parsed_args .size <= volume .size :
405+ msg = _ ("New size must be greater than %s GB" ), volume .size
406+ raise exceptions .CommandError (msg )
407+ volume_client .volumes .extend (volume .id , parsed_args .size )
408+ except Exception as e :
409+ LOG .error (_ ("Failed to set volume size: %s" ), e )
410+ result += 1
407411
408412 if parsed_args .property :
409- volume_client .volumes .set_metadata (volume .id , parsed_args .property )
413+ try :
414+ volume_client .volumes .set_metadata (
415+ volume .id , parsed_args .property )
416+ except Exception as e :
417+ LOG .error (_ ("Failed to set volume property: %s" ), e )
418+ result += 1
410419 if parsed_args .image_property :
411- volume_client .volumes .set_image_metadata (
412- volume .id , parsed_args .image_property )
420+ try :
421+ volume_client .volumes .set_image_metadata (
422+ volume .id , parsed_args .image_property )
423+ except Exception as e :
424+ LOG .error (_ ("Failed to set image property: %s" ), e )
425+ result += 1
413426 if parsed_args .state :
414- volume_client .volumes .reset_state (volume .id , parsed_args .state )
427+ try :
428+ volume_client .volumes .reset_state (
429+ volume .id , parsed_args .state )
430+ except Exception as e :
431+ LOG .error (_ ("Failed to set volume state: %s" ), e )
432+ result += 1
415433
416434 kwargs = {}
417435 if parsed_args .name :
418436 kwargs ['display_name' ] = parsed_args .name
419437 if parsed_args .description :
420438 kwargs ['display_description' ] = parsed_args .description
421439 if kwargs :
422- volume_client .volumes .update (volume .id , ** kwargs )
440+ try :
441+ volume_client .volumes .update (volume .id , ** kwargs )
442+ except Exception as e :
443+ LOG .error (_ ("Failed to update volume display name "
444+ "or display description: %s" ), e )
445+ result += 1
446+
447+ if result > 0 :
448+ raise exceptions .CommandError (_ ("One or more of the "
449+ "set operations failed" ))
423450
424451
425452class ShowVolume (command .ShowOne ):
0 commit comments