@@ -510,20 +510,32 @@ def get_parser(self, prog_name):
510510 metavar = '<device>' ,
511511 help = _ ('Server internal device name for volume' ),
512512 )
513+ parser .add_argument (
514+ '--tag' ,
515+ metavar = '<tag>' ,
516+ help = _ (
517+ "Tag for the attached volume. "
518+ "(Supported by API versions '2.49' - '2.latest')"
519+ ),
520+ )
513521 termination_group = parser .add_mutually_exclusive_group ()
514522 termination_group .add_argument (
515523 '--enable-delete-on-termination' ,
516524 action = 'store_true' ,
517- help = _ ("Specify if the attached volume should be deleted when "
518- "the server is destroyed. (Supported with "
519- "``--os-compute-api-version`` 2.79 or greater.)" ),
525+ help = _ (
526+ "Specify if the attached volume should be deleted when the "
527+ "server is destroyed. "
528+ "(Supported by API versions '2.79' - '2.latest')"
529+ ),
520530 )
521531 termination_group .add_argument (
522532 '--disable-delete-on-termination' ,
523533 action = 'store_true' ,
524- help = _ ("Specify if the attached volume should not be deleted "
525- "when the server is destroyed. (Supported with "
526- "``--os-compute-api-version`` 2.79 or greater.)" ),
534+ help = _ (
535+ "Specify if the attached volume should not be deleted when "
536+ "the server is destroyed. "
537+ "(Supported by API versions '2.79' - '2.latest')"
538+ ),
527539 )
528540 return parser
529541
@@ -540,28 +552,38 @@ def take_action(self, parsed_args):
540552 parsed_args .volume ,
541553 )
542554
543- support_set_delete_on_termination = (compute_client .api_version >=
544- api_versions .APIVersion ('2.79' ))
545-
546- if not support_set_delete_on_termination :
547- if parsed_args .enable_delete_on_termination :
548- msg = _ ('--os-compute-api-version 2.79 or greater '
549- 'is required to support the '
550- '--enable-delete-on-termination option.' )
551- raise exceptions .CommandError (msg )
552- if parsed_args .disable_delete_on_termination :
553- msg = _ ('--os-compute-api-version 2.79 or greater '
554- 'is required to support the '
555- '--disable-delete-on-termination option.' )
556- raise exceptions .CommandError (msg )
557-
558555 kwargs = {
559556 "device" : parsed_args .device
560557 }
561558
559+ if parsed_args .tag :
560+ if compute_client .api_version < api_versions .APIVersion ('2.49' ):
561+ msg = _ (
562+ '--os-compute-api-version 2.49 or greater is required to '
563+ 'support the --tag option'
564+ )
565+ raise exceptions .CommandError (msg )
566+
567+ kwargs ['tag' ] = parsed_args .tag
568+
562569 if parsed_args .enable_delete_on_termination :
570+ if compute_client .api_version < api_versions .APIVersion ('2.79' ):
571+ msg = _ (
572+ '--os-compute-api-version 2.79 or greater is required to '
573+ 'support the --enable-delete-on-termination option.'
574+ )
575+ raise exceptions .CommandError (msg )
576+
563577 kwargs ['delete_on_termination' ] = True
578+
564579 if parsed_args .disable_delete_on_termination :
580+ if compute_client .api_version < api_versions .APIVersion ('2.79' ):
581+ msg = _ (
582+ '--os-compute-api-version 2.79 or greater is required to '
583+ 'support the --disable-delete-on-termination option.'
584+ )
585+ raise exceptions .CommandError (msg )
586+
565587 kwargs ['delete_on_termination' ] = False
566588
567589 compute_client .volumes .create_server_volume (
0 commit comments