@@ -548,24 +548,25 @@ def get_parser(self, prog_name):
548548 return parser
549549
550550 def take_action (self , parsed_args ):
551- compute_client = self .app .client_manager .compute
552- volume_client = self .app .client_manager .volume
551+ compute_client = self .app .client_manager .sdk_connection . compute
552+ volume_client = self .app .client_manager .sdk_connection . volume
553553
554- server = utils .find_resource (
555- compute_client .servers ,
554+ server = compute_client .find_server (
556555 parsed_args .server ,
556+ ignore_missing = False ,
557557 )
558- volume = utils .find_resource (
559- volume_client .volumes ,
558+ volume = volume_client .find_volume (
560559 parsed_args .volume ,
560+ ignore_missing = False ,
561561 )
562562
563563 kwargs = {
564+ "volumeId" : volume .id ,
564565 "device" : parsed_args .device
565566 }
566567
567568 if parsed_args .tag :
568- if compute_client . api_version < api_versions . APIVersion ( '2.49' ):
569+ if not sdk_utils . supports_microversion ( compute_client , '2.49' ):
569570 msg = _ (
570571 '--os-compute-api-version 2.49 or greater is required to '
571572 'support the --tag option'
@@ -575,7 +576,7 @@ def take_action(self, parsed_args):
575576 kwargs ['tag' ] = parsed_args .tag
576577
577578 if parsed_args .enable_delete_on_termination :
578- if compute_client . api_version < api_versions . APIVersion ( '2.79' ):
579+ if not sdk_utils . supports_microversion ( compute_client , '2.79' ):
579580 msg = _ (
580581 '--os-compute-api-version 2.79 or greater is required to '
581582 'support the --enable-delete-on-termination option.'
@@ -585,7 +586,7 @@ def take_action(self, parsed_args):
585586 kwargs ['delete_on_termination' ] = True
586587
587588 if parsed_args .disable_delete_on_termination :
588- if compute_client . api_version < api_versions . APIVersion ( '2.79' ):
589+ if not sdk_utils . supports_microversion ( compute_client , '2.79' ):
589590 msg = _ (
590591 '--os-compute-api-version 2.79 or greater is required to '
591592 'support the --disable-delete-on-termination option.'
@@ -594,28 +595,23 @@ def take_action(self, parsed_args):
594595
595596 kwargs ['delete_on_termination' ] = False
596597
597- volume_attachment = compute_client .volumes .create_server_volume (
598- server .id ,
599- volume .id ,
600- ** kwargs
598+ volume_attachment = compute_client .create_volume_attachment (
599+ server ,
600+ ** kwargs ,
601601 )
602602
603- columns = ('id' , 'serverId ' , 'volumeId ' , 'device' )
603+ columns = ('id' , 'server id ' , 'volume id ' , 'device' )
604604 column_headers = ('ID' , 'Server ID' , 'Volume ID' , 'Device' )
605- if compute_client . api_version >= api_versions . APIVersion ( '2.49' ):
605+ if sdk_utils . supports_microversion ( compute_client , '2.49' ):
606606 columns += ('tag' ,)
607607 column_headers += ('Tag' ,)
608- if compute_client . api_version >= api_versions . APIVersion ( '2.79' ):
608+ if sdk_utils . supports_microversion ( compute_client , '2.79' ):
609609 columns += ('delete_on_termination' ,)
610610 column_headers += ('Delete On Termination' ,)
611611
612612 return (
613613 column_headers ,
614- utils .get_item_properties (
615- volume_attachment ,
616- columns ,
617- mixed_case_fields = ('serverId' , 'volumeId' ),
618- )
614+ utils .get_item_properties (volume_attachment , columns ,)
619615 )
620616
621617
0 commit comments