@@ -52,6 +52,7 @@ def __init__(self, config: traitlets.config.Config) -> None:
5252 self ._content_managers = {}
5353 self ._max_files_listed = 1025
5454 self ._drives = None
55+ self ._external_drives = {}
5556
5657 # instate fsspec file system
5758 self ._file_system = fsspec .filesystem (self ._config .provider , asynchronous = True )
@@ -178,7 +179,7 @@ async def list_drives(self):
178179 """
179180 data = []
180181 if self ._config .access_key_id and self ._config .secret_access_key :
181- if self ._drives is None :
182+ if self ._drives is None and len ( self . _external_drives ) == 0 :
182183 raise tornado .web .HTTPError (
183184 status_code = httpx .codes .NOT_IMPLEMENTED ,
184185 reason = "Listing drives not supported for given provider." ,
@@ -187,7 +188,7 @@ async def list_drives(self):
187188 results = []
188189 for drive in self ._drives :
189190 try :
190- results += drive .list_containers ()
191+ results += drive .list_containers ()
191192 except Exception as e :
192193 raise tornado .web .HTTPError (
193194 status_code = httpx .codes .BAD_REQUEST ,
@@ -204,6 +205,23 @@ async def list_drives(self):
204205 "provider" : self ._config .provider
205206 }
206207 )
208+
209+ if len (self ._external_drives ) != 0 :
210+ for drive in self ._external_drives .values ():
211+ try :
212+ data .append ({
213+ "name" : drive ['url' ],
214+ "region" : self ._config .region_name ,
215+ "creationDate" : datetime .now ().isoformat (timespec = 'milliseconds' ).replace ('+00:00' , 'Z' ),
216+ "mounted" : False if result .name not in self ._content_managers else True ,
217+ "provider" : self ._config .provider
218+ })
219+ except Exception as e :
220+ raise tornado .web .HTTPError (
221+ status_code = httpx .codes .BAD_REQUEST ,
222+ reason = f"The following error occured when listing drives: { e } " ,
223+ )
224+
207225 else :
208226 raise tornado .web .HTTPError (
209227 status_code = httpx .codes .BAD_REQUEST ,
@@ -624,6 +642,26 @@ async def new_drive(self, new_drive_name, location='us-east-1'):
624642
625643 return
626644
645+ async def add_public_drive (self , drive_name ):
646+ """Mount a drive.
647+
648+ Args:
649+ drive_name: name of public bucket to mount
650+ """
651+ try :
652+ drive = {
653+ "is_public" : True ,
654+ "url" : drive_name
655+ };
656+ self ._external_drives [drive_name ] = drive ;
657+ except Exception as e :
658+ raise tornado .web .HTTPError (
659+ status_code = httpx .codes .BAD_REQUEST ,
660+ reason = f"The following error occured when adding the public drive: { e } "
661+ )
662+
663+ return
664+
627665 async def _get_drive_location (self , drive_name ):
628666 """Helping function for getting drive region.
629667
0 commit comments