@@ -1836,3 +1836,48 @@ def take_action(self, parsed_args):
18361836
18371837 info = _format_image (image )
18381838 return zip (* sorted (info .items ()))
1839+
1840+
1841+ class StoresInfo (command .Lister ):
1842+ _description = _ (
1843+ "Get available backends (only valid with Multi-Backend support)"
1844+ )
1845+
1846+ def get_parser (self , prog_name ):
1847+ parser = super ().get_parser (prog_name )
1848+ parser .add_argument (
1849+ "--detail" ,
1850+ action = 'store_true' ,
1851+ default = None ,
1852+ help = _ (
1853+ 'Shows details of stores (admin only) '
1854+ '(requires --os-image-api-version 2.15 or later)'
1855+ ),
1856+ )
1857+ return parser
1858+
1859+ def take_action (self , parsed_args ):
1860+ image_client = self .app .client_manager .image
1861+ try :
1862+ columns = ("id" , "description" , "is_default" )
1863+ column_headers = ("ID" , "Description" , "Default" )
1864+ if parsed_args .detail :
1865+ columns += ("properties" ,)
1866+ column_headers += ("Properties" ,)
1867+
1868+ data = list (image_client .stores (details = parsed_args .detail ))
1869+ except sdk_exceptions .ResourceNotFound :
1870+ msg = _ ('Multi Backend support not enabled' )
1871+ raise exceptions .CommandError (msg )
1872+ else :
1873+ return (
1874+ column_headers ,
1875+ (
1876+ utils .get_item_properties (
1877+ store ,
1878+ columns ,
1879+ formatters = _formatters ,
1880+ )
1881+ for store in data
1882+ ),
1883+ )
0 commit comments