Skip to content

Commit 8f034a2

Browse files
committed
feat: convert openBIS cloud storage configurations into valid rclone configurations before starting a session (next try)
1 parent bce8bcf commit 8f034a2

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

components/renku_data_services/notebooks/api/schemas/cloud_storage.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,38 +226,37 @@ def config_string(self, name: str) -> str:
226226
if not self.configuration:
227227
raise ValidationError("Missing configuration for cloud storage")
228228
# TODO Use RCloneValidator.get_real_configuration(...) instead.
229-
real_config = dict(self.configuration)
230229
# Transform configuration for polybox, switchDrive or openBIS
231230
storage_type = self.configuration.get("type", "")
232231
access = self.configuration.get("provider", "")
233232

234233
if storage_type == "polybox" or storage_type == "switchDrive":
235-
real_config["type"] = "webdav"
236-
real_config["provider"] = ""
234+
self.configuration["type"] = "webdav"
235+
self.configuration["provider"] = ""
237236
elif storage_type == "s3" and access == "Switch":
238237
# Switch is a fake provider we add for users, we need to replace it since rclone itself
239238
# doesn't know it
240-
real_config["provider"] = "Other"
239+
self.configuration["provider"] = "Other"
241240
elif storage_type == "openbis":
242-
real_config["type"] = "sftp"
243-
real_config["port"] = "2222"
244-
real_config["user"] = "?"
245-
real_config["pass"] = real_config.pop("session_token")
241+
self.configuration["type"] = "sftp"
242+
self.configuration["port"] = "2222"
243+
self.configuration["user"] = "?"
244+
self.configuration["pass"] = self.configuration.pop("session_token", self.configuration["pass"])
246245

247246
if access == "shared" and storage_type == "polybox":
248-
real_config["url"] = "https://polybox.ethz.ch/public.php/webdav/"
247+
self.configuration["url"] = "https://polybox.ethz.ch/public.php/webdav/"
249248
elif access == "shared" and storage_type == "switchDrive":
250-
real_config["url"] = "https://drive.switch.ch/public.php/webdav/"
249+
self.configuration["url"] = "https://drive.switch.ch/public.php/webdav/"
251250
elif access == "personal" and storage_type == "polybox":
252-
real_config["url"] = "https://polybox.ethz.ch/remote.php/webdav/"
251+
self.configuration["url"] = "https://polybox.ethz.ch/remote.php/webdav/"
253252
elif access == "personal" and storage_type == "switchDrive":
254-
real_config["url"] = "https://drive.switch.ch/remote.php/webdav/"
253+
self.configuration["url"] = "https://drive.switch.ch/remote.php/webdav/"
255254

256255
# Extract the user from the public link
257256
if access == "shared" and storage_type in {"polybox", "switchDrive"}:
258257
public_link = self.configuration.get("public_link", "")
259258
user_identifier = public_link.split("/")[-1]
260-
real_config["user"] = user_identifier
259+
self.configuration["user"] = user_identifier
261260

262261
parser = ConfigParser()
263262
parser.add_section(name)
@@ -267,7 +266,7 @@ def _stringify(value: Any) -> str:
267266
return "true" if value else "false"
268267
return str(value)
269268

270-
for k, v in real_config.items():
269+
for k, v in self.configuration.items():
271270
parser.set(name, k, _stringify(v))
272271
stringio = StringIO()
273272
parser.write(stringio)

0 commit comments

Comments
 (0)