@@ -559,6 +559,25 @@ def get_parser(self, prog_name):
559559 'in the database with no regard to actual status, '
560560 'exercise caution when using)' ),
561561 )
562+ attached_group = parser .add_mutually_exclusive_group ()
563+ attached_group .add_argument (
564+ "--attached" ,
565+ action = "store_true" ,
566+ help = _ ('Set volume attachment status to "attached" '
567+ '(admin only) '
568+ '(This option simply changes the state of the volume '
569+ 'in the database with no regard to actual status, '
570+ 'exercise caution when using)' ),
571+ )
572+ attached_group .add_argument (
573+ "--detached" ,
574+ action = "store_true" ,
575+ help = _ ('Set volume attachment status to "detached" '
576+ '(admin only) '
577+ '(This option simply changes the state of the volume '
578+ 'in the database with no regard to actual status, '
579+ 'exercise caution when using)' ),
580+ )
562581 parser .add_argument (
563582 '--type' ,
564583 metavar = '<volume-type>' ,
@@ -645,6 +664,22 @@ def take_action(self, parsed_args):
645664 except Exception as e :
646665 LOG .error (_ ("Failed to set volume state: %s" ), e )
647666 result += 1
667+ if parsed_args .attached :
668+ try :
669+ volume_client .volumes .reset_state (
670+ volume .id , state = None ,
671+ attach_status = "attached" )
672+ except Exception as e :
673+ LOG .error (_ ("Failed to set volume attach-status: %s" ), e )
674+ result += 1
675+ if parsed_args .detached :
676+ try :
677+ volume_client .volumes .reset_state (
678+ volume .id , state = None ,
679+ attach_status = "detached" )
680+ except Exception as e :
681+ LOG .error (_ ("Failed to set volume attach-status: %s" ), e )
682+ result += 1
648683 if parsed_args .bootable or parsed_args .non_bootable :
649684 try :
650685 volume_client .volumes .set_bootable (
0 commit comments