diff --git a/services/webapp/code/rosetta/core_app/computing_managers.py b/services/webapp/code/rosetta/core_app/computing_managers.py index 7e916e7133083a0e5c0054466a12f8a4cbba794a..8894ad6c008e21d5b0c4c36e05f62bcf9b45a01b 100644 --- a/services/webapp/code/rosetta/core_app/computing_managers.py +++ b/services/webapp/code/rosetta/core_app/computing_managers.py @@ -131,8 +131,30 @@ class InternalStandaloneComputingManager(StandaloneComputingManager): # User data volume #run_command += ' -v {}/user-{}:/data'.format(settings.LOCAL_USER_DATA_DIR, task.user.id) + # Handle storages (binds) + binds = '' + storages = Storage.objects.filter(computing=self.computing) + for storage in storages: + if storage.type == 'generic_posix' and storage.bind_path: + + # Expand the base path + expanded_base_path = storage.base_path + if '$USER' in expanded_base_path: + expanded_base_path = expanded_base_path.replace('$USER', task.user.username) + + # Expand the bind_path + expanded_bind_path = storage.bind_path + if '$USER' in expanded_bind_path: + expanded_bind_path = expanded_bind_path.replace('$USER', task.user.username) + + # Add the bind + if not binds: + binds = '-v{}:{}'.format(expanded_base_path, expanded_bind_path) + else: + binds += ' -v{}:{}'.format(expanded_base_path, expanded_bind_path) + # Host name, image entry command - run_command += ' -h task-{} --name task-{} -d -t {}/{}:{}'.format(task.short_uuid, task.short_uuid, task.container.registry, task.container.image_name, task.container.image_tag) + run_command += ' {} -h task-{} --name task-{} -d -t {}/{}:{}'.format(binds, task.short_uuid, task.short_uuid, task.container.registry, task.container.image_name, task.container.image_tag) # Debug logger.debug('Running new task with command="{}"'.format(run_command)) @@ -166,6 +188,10 @@ class InternalStandaloneComputingManager(StandaloneComputingManager): out = os_shell(stop_command, capture=True) if out.exit_code != 0: if 'No such container' in out.stderr: + # No container was found + pass + elif 'requires at least 1 argument' in out.stderr: + # No container was found pass else: raise Exception(out.stderr) diff --git a/services/webapp/code/rosetta/core_app/models.py b/services/webapp/code/rosetta/core_app/models.py index 29ffa5d03c47312aa447b816bcbdde084ebb157b..76061c1d7034322f66e79b3c051fbc3c23d9152f 100644 --- a/services/webapp/code/rosetta/core_app/models.py +++ b/services/webapp/code/rosetta/core_app/models.py @@ -398,7 +398,11 @@ class Storage(models.Model): # Include as browsable in the file manager? browsable = models.BooleanField('Browsable in the file manager?', default=True) - + def save(self, *args, **kwargs): + if self.access_mode == 'internal' and self.browsable: + raise ValueError('A storage with "internal" access mode cannot be marked as browsable since it is not yet supported by the file manager') + super(Storage, self).save(*args, **kwargs) + class Meta: ordering = ['name']