5
5
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
6
6
import ads
7
7
import oci
8
+ import os
8
9
import ipaddress
9
10
10
11
from dataclasses import dataclass
@@ -51,6 +52,10 @@ def update_from_dsc_model(cls, dsc_model) -> dict:
51
52
@staticmethod
52
53
def get_destination_path_and_name (dest : str ) -> (str , str ):
53
54
"""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)
54
59
55
60
Parameters
56
61
----------
@@ -62,10 +67,10 @@ def get_destination_path_and_name(dest: str) -> (str, str):
62
67
tuple
63
68
A tuple of destination path and destination directory name.
64
69
"""
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
+ )
69
74
70
75
71
76
@dataclass
@@ -199,14 +204,10 @@ def update_from_dsc_model(cls, dsc_model) -> dict:
199
204
raise ValueError (
200
205
"Missing parameter `destination_directory_name` from service. Check service log to see the error."
201
206
)
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
- )
206
207
207
208
return {
208
209
"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 } "
210
211
}
211
212
212
213
@dataclass
@@ -247,14 +248,10 @@ def update_from_dsc_model(cls, dsc_model) -> dict:
247
248
raise ValueError (
248
249
"Missing parameter `destination_directory_name` from service. Check service log to see the error."
249
250
)
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
- )
254
251
255
252
return {
256
253
"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 } "
258
255
}
259
256
260
257
0 commit comments