55# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
66import ads
77import oci
8+ import os
89import ipaddress
910
1011from dataclasses import dataclass
@@ -51,6 +52,10 @@ def update_from_dsc_model(cls, dsc_model) -> dict:
5152 @staticmethod
5253 def get_destination_path_and_name (dest : str ) -> (str , str ):
5354 """Gets the destination path and destination directory name from dest.
55+ Example:
56+ dir - "fss" & path - "/opc" : mount happens under "/opc/fss"
57+ dir - "fss" & path - "/" : mount happens under "/fss"
58+ dir - "fss" & path - omitted : mount happens under "/mnt/fss" (for backward compatibility)
5459
5560 Parameters
5661 ----------
@@ -62,10 +67,10 @@ def get_destination_path_and_name(dest: str) -> (str, str):
6267 tuple
6368 A tuple of destination path and destination directory name.
6469 """
65- directory_index = dest . rfind ( "/" )
66- directory_name = dest [ directory_index + 1 :]
67- path = "/" if directory_index <= 0 else dest [: directory_index ]
68- return ( path , directory_name )
70+ return (
71+ os . path . dirname ( dest . rstrip ( "/" )),
72+ os . path . basename ( dest . rstrip ( "/" ))
73+ )
6974
7075
7176@dataclass
@@ -199,14 +204,10 @@ def update_from_dsc_model(cls, dsc_model) -> dict:
199204 raise ValueError (
200205 "Missing parameter `destination_directory_name` from service. Check service log to see the error."
201206 )
202- if not dsc_model .destination_path :
203- raise ValueError (
204- "Missing parameter `destination_path` from service. Check service log to see the error."
205- )
206207
207208 return {
208209 "src" : f"{ dsc_model .mount_target_id } :{ dsc_model .export_id } " ,
209- "dest" : f"{ dsc_model .destination_path .rstrip ('/' )} /{ dsc_model .destination_directory_name } "
210+ "dest" : f"{ ( dsc_model .destination_path or '' ) .rstrip ('/' )} /{ dsc_model .destination_directory_name } "
210211 }
211212
212213@dataclass
@@ -247,14 +248,10 @@ def update_from_dsc_model(cls, dsc_model) -> dict:
247248 raise ValueError (
248249 "Missing parameter `destination_directory_name` from service. Check service log to see the error."
249250 )
250- if not dsc_model .destination_path :
251- raise ValueError (
252- "Missing parameter `destination_path` from service. Check service log to see the error."
253- )
254251
255252 return {
256253 "src" : f"oci://{ dsc_model .bucket } @{ dsc_model .namespace } /{ dsc_model .prefix or '' } " ,
257- "dest" : f"{ dsc_model .destination_path .rstrip ('/' )} /{ dsc_model .destination_directory_name } "
254+ "dest" : f"{ ( dsc_model .destination_path or '' ) .rstrip ('/' )} /{ dsc_model .destination_directory_name } "
258255 }
259256
260257
0 commit comments