Loading services/webapp/code/rosetta/core_app/models.py +35 −16 Original line number Diff line number Diff line Loading @@ -19,6 +19,20 @@ class ConfigurationError(Exception): class ConsistencyError(Exception): pass def get_computing_manager(computing): from . import computing_managers # Hash table mapping managers_mapping = {} managers_mapping['cluster'+'ssh+cli'+'user_keys'+'slurm'] = computing_managers.SlurmSSHClusterComputingManager managers_mapping['standalone'+'ssh+cli'+'user_keys'+'None'] = computing_managers.SSHStandaloneComputingManager managers_mapping['standalone'+'ssh+cli'+'platform_keys'+'None'] = computing_managers.SSHStandaloneComputingManager managers_mapping['standalone'+'internal'+'internal'+'None'] = computing_managers.InternalStandaloneComputingManager try: return managers_mapping[computing.type+computing.access_mode+computing.auth_mode+str(computing.wms)](computing) except KeyError: raise ValueError('No computing manager defined for type="{}", access_mode="{}", auth_mode="{}", wms="{}"' .format(computing.type, computing.access_mode, computing.auth_mode, computing.wms)) from None # Setup logging import logging Loading Loading @@ -232,6 +246,25 @@ class Computing(models.Model): else: return str('Computing "{}"'.format(self.name)) def save(self, *args, **kwargs): if not self.container_engines: self.container_engines = None if not self.supported_archs: self.supported_archs = None if not self.emulated_archs: self.emulated_archs = None if not self.conf: self.conf = None try: get_computing_manager(self) except: raise raise ValueError('Unsupported combination of type, access_mode, auth_mode, and wms') super(Computing, self).save(*args, **kwargs) @property def uuid_as_str(self): return str(self.uuid) Loading Loading @@ -276,29 +309,15 @@ class Computing(models.Model): @property def manager(self): from . import computing_managers # Hash table mapping managers_mapping = {} managers_mapping['cluster'+'ssh+cli'+'user_keys'+'slurm'] = computing_managers.SlurmSSHClusterComputingManager managers_mapping['standalone'+'ssh+cli'+'user_keys'+'None'] = computing_managers.SSHStandaloneComputingManager managers_mapping['standalone'+'ssh+cli'+'platform_keys'+'None'] = computing_managers.SSHStandaloneComputingManager managers_mapping['standalone'+'internal'+'internal'+'None'] = computing_managers.InternalStandaloneComputingManager # Instantiate the computing manager and return (if not already done) try: return self._manager except AttributeError: try: self._manager = managers_mapping[self.type+self.access_mode+self.auth_mode+str(self.wms)](self) except KeyError: raise ValueError('No computing resource manager for type="{}", access_mode="{}", auth_mode="{}", wms="{}"' .format(self.type, self.access_mode, self.auth_mode, self.wms)) from None else: self._manager = get_computing_manager(self) return self._manager #========================= # Tasks #========================= Loading services/webapp/code/rosetta/core_app/templates/add_computing.html 0 → 100644 +111 −0 Original line number Diff line number Diff line {% load static %} {% include "header.html" %} {% include "navigation.html" %} {% include "logo.html" %} <div class="container"> <div class="dashboard"> <div class="span8 offset2"> <h1><a href="/computing">Computing resources</a> <span style="font-size:18px"> / add</span></h1> <hr> {% if data.error %} <div class="alert alert-danger">{{ data.error }}</div> {% endif %} {% if data.added %} <div class="alert alert-success">Resource added successfully.</div> {% endif %} <form action="#" method="POST"> {% csrf_token %} <table class="dashboard" style="width:500px; margin-bottom:25px"> <tr> <td><b>Name</b></td> <td><input type="text" name="name" value="" size="30" required /></td> </tr> <tr> <td><b>Description</b></td> <td><textarea name="description" rows="3" cols="30"></textarea></td> </tr> <tr> <td><b>Group</b></td> <td> <select name="group_id" style="width: 220px;"> <option value="">None</option> {% for group in data.groups %} <option value="{{ group.id }}">{{ group.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td><b>Type</b></td> <td> <select name="type" style="width: 220px;" required> <option value="cluster">cluster</option> <option value="standalone">standalone</option> </select> </td> </tr> <tr> <td><b>Arch</b></td> <td><input type="text" name="arch" value="" size="30" required /></td> </tr> <tr> <td><b>Access mode</b></td> <td> <select name="access_mode" style="width: 220px;" required> <option value="ssh+cli">ssh+cli</option> <option value="internal">internal</option> </select> </td> </tr> <tr> <td><b>Auth mode</b></td> <td> <select name="auth_mode" style="width: 220px;" required> <option value="user_keys">user_keys</option> <option value="platform_keys">platform_keys</option> <option value="internal">internal</option> </select> </td> </tr> <tr> <td><b>WMS</b></td> <td> <select name="wms" style="width: 220px;"> <option value="">None</option> <option value="slurm">slurm</option> </select> </td> </tr> <tr> <td><b>Container engines</b><br/><span style="font-size:0.8em">(JSON list)</span></td> <td><textarea name="container_engines" rows="2" cols="30" required></textarea></td> </tr> <tr> <td><b>Supported archs</b><br/><span style="font-size:0.8em">(JSON list)</span></td> <td><textarea name="supported_archs" rows="2" cols="30"></textarea></td> </tr> <tr> <td><b>Emulated archs</b><br/><span style="font-size:0.8em">(JSON dict)</span></td> <td><textarea name="emulated_archs" rows="2" cols="30"></textarea></td> </tr> <tr> <td><b>Conf</b><br/><span style="font-size:0.8em">(JSON dict)</span></td> <td><textarea name="conf" rows="2" cols="30"></textarea></td> </tr> </table> <table style="width:500px; border:0; background:#ffffff; margin-top:20px"> <tr><td align="center"> <a href="/computing" class="btn btn-primary" style="margin-left:10px">Back</a> <input type="submit" value="Add" class="btn btn-primary"> </td></tr> </table> </form> </div> </div> </div> {% include "footer.html" %} No newline at end of file services/webapp/code/rosetta/core_app/templates/components/computing.html +2 −2 Original line number Diff line number Diff line Loading @@ -51,12 +51,12 @@ <tr> <td><b>Container engines</b></td> <td>{{ data.computing.container_engines }}</td> <td>{{ data.computing.container_engines_json }}</td> </tr> <tr> <td><b>Emulated archs</b></td> <td>{{ data.computing.emulated_archs }}</td> <td>{{ data.computing.emulated_archs_json }}</td> </tr> <tr> Loading services/webapp/code/rosetta/core_app/templates/computing.html +3 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ {% endif %} <hr/> {% if request.user.is_staff %} {% if not data.computing %} <div class="form-filter" style="margin-bottom:20px"> <form action="" method="POST"> Loading @@ -37,10 +38,11 @@ </select> {% csrf_token %} <button type="submit" class="btn btn-secondary">Go</button> <font size=4.0em>|</font> <a href="#" class="disabled" style="pointer-events: none; color: #aaa;">Add new...</a> <font size=4.0em>|</font> <a href="/add_computing">Add new...</a> </form> </div> {% endif %} {% endif %} <div class="row" style="padding:5px"> {% if data.computing %} Loading services/webapp/code/rosetta/core_app/templates/edit_computing.html +25 −4 Original line number Diff line number Diff line Loading @@ -40,7 +40,12 @@ </tr> <tr> <td><b>Type</b></td> <td><input type="text" name="type" value="{{ data.computing.type }}" size="30" required /></td> <td> <select name="type" style="width: 220px;" required> <option value="cluster" {% if data.computing.type == 'cluster' %}selected{% endif %}>cluster</option> <option value="standalone" {% if data.computing.type == 'standalone' %}selected{% endif %}>standalone</option> </select> </td> </tr> <tr> <td><b>Arch</b></td> Loading @@ -48,15 +53,31 @@ </tr> <tr> <td><b>Access mode</b></td> <td><input type="text" name="access_mode" value="{{ data.computing.access_mode }}" size="30" required /></td> <td> <select name="access_mode" style="width: 220px;" required> <option value="ssh+cli" {% if data.computing.access_mode == 'ssh+cli' %}selected{% endif %}>ssh+cli</option> <option value="internal" {% if data.computing.access_mode == 'internal' %}selected{% endif %}>internal</option> </select> </td> </tr> <tr> <td><b>Auth mode</b></td> <td><input type="text" name="auth_mode" value="{{ data.computing.auth_mode }}" size="30" required /></td> <td> <select name="auth_mode" style="width: 220px;" required> <option value="user_keys" {% if data.computing.auth_mode == 'user_keys' %}selected{% endif %}>user_keys</option> <option value="platform_keys" {% if data.computing.auth_mode == 'platform_keys' %}selected{% endif %}>platform_keys</option> <option value="internal" {% if data.computing.auth_mode == 'internal' %}selected{% endif %}>internal</option> </select> </td> </tr> <tr> <td><b>WMS</b></td> <td><input type="text" name="wms" value="{{ data.computing.wms }}" size="30" /></td> <td> <select name="wms" style="width: 220px;"> <option value="" {% if not data.computing.wms %}selected{% endif %}>None</option> <option value="slurm" {% if data.computing.wms == 'slurm' %}selected{% endif %}>slurm</option> </select> </td> </tr> <tr> <td><b>Container engines</b><br/><span style="font-size:0.8em">(JSON list)</span></td> Loading Loading
services/webapp/code/rosetta/core_app/models.py +35 −16 Original line number Diff line number Diff line Loading @@ -19,6 +19,20 @@ class ConfigurationError(Exception): class ConsistencyError(Exception): pass def get_computing_manager(computing): from . import computing_managers # Hash table mapping managers_mapping = {} managers_mapping['cluster'+'ssh+cli'+'user_keys'+'slurm'] = computing_managers.SlurmSSHClusterComputingManager managers_mapping['standalone'+'ssh+cli'+'user_keys'+'None'] = computing_managers.SSHStandaloneComputingManager managers_mapping['standalone'+'ssh+cli'+'platform_keys'+'None'] = computing_managers.SSHStandaloneComputingManager managers_mapping['standalone'+'internal'+'internal'+'None'] = computing_managers.InternalStandaloneComputingManager try: return managers_mapping[computing.type+computing.access_mode+computing.auth_mode+str(computing.wms)](computing) except KeyError: raise ValueError('No computing manager defined for type="{}", access_mode="{}", auth_mode="{}", wms="{}"' .format(computing.type, computing.access_mode, computing.auth_mode, computing.wms)) from None # Setup logging import logging Loading Loading @@ -232,6 +246,25 @@ class Computing(models.Model): else: return str('Computing "{}"'.format(self.name)) def save(self, *args, **kwargs): if not self.container_engines: self.container_engines = None if not self.supported_archs: self.supported_archs = None if not self.emulated_archs: self.emulated_archs = None if not self.conf: self.conf = None try: get_computing_manager(self) except: raise raise ValueError('Unsupported combination of type, access_mode, auth_mode, and wms') super(Computing, self).save(*args, **kwargs) @property def uuid_as_str(self): return str(self.uuid) Loading Loading @@ -276,29 +309,15 @@ class Computing(models.Model): @property def manager(self): from . import computing_managers # Hash table mapping managers_mapping = {} managers_mapping['cluster'+'ssh+cli'+'user_keys'+'slurm'] = computing_managers.SlurmSSHClusterComputingManager managers_mapping['standalone'+'ssh+cli'+'user_keys'+'None'] = computing_managers.SSHStandaloneComputingManager managers_mapping['standalone'+'ssh+cli'+'platform_keys'+'None'] = computing_managers.SSHStandaloneComputingManager managers_mapping['standalone'+'internal'+'internal'+'None'] = computing_managers.InternalStandaloneComputingManager # Instantiate the computing manager and return (if not already done) try: return self._manager except AttributeError: try: self._manager = managers_mapping[self.type+self.access_mode+self.auth_mode+str(self.wms)](self) except KeyError: raise ValueError('No computing resource manager for type="{}", access_mode="{}", auth_mode="{}", wms="{}"' .format(self.type, self.access_mode, self.auth_mode, self.wms)) from None else: self._manager = get_computing_manager(self) return self._manager #========================= # Tasks #========================= Loading
services/webapp/code/rosetta/core_app/templates/add_computing.html 0 → 100644 +111 −0 Original line number Diff line number Diff line {% load static %} {% include "header.html" %} {% include "navigation.html" %} {% include "logo.html" %} <div class="container"> <div class="dashboard"> <div class="span8 offset2"> <h1><a href="/computing">Computing resources</a> <span style="font-size:18px"> / add</span></h1> <hr> {% if data.error %} <div class="alert alert-danger">{{ data.error }}</div> {% endif %} {% if data.added %} <div class="alert alert-success">Resource added successfully.</div> {% endif %} <form action="#" method="POST"> {% csrf_token %} <table class="dashboard" style="width:500px; margin-bottom:25px"> <tr> <td><b>Name</b></td> <td><input type="text" name="name" value="" size="30" required /></td> </tr> <tr> <td><b>Description</b></td> <td><textarea name="description" rows="3" cols="30"></textarea></td> </tr> <tr> <td><b>Group</b></td> <td> <select name="group_id" style="width: 220px;"> <option value="">None</option> {% for group in data.groups %} <option value="{{ group.id }}">{{ group.name }}</option> {% endfor %} </select> </td> </tr> <tr> <td><b>Type</b></td> <td> <select name="type" style="width: 220px;" required> <option value="cluster">cluster</option> <option value="standalone">standalone</option> </select> </td> </tr> <tr> <td><b>Arch</b></td> <td><input type="text" name="arch" value="" size="30" required /></td> </tr> <tr> <td><b>Access mode</b></td> <td> <select name="access_mode" style="width: 220px;" required> <option value="ssh+cli">ssh+cli</option> <option value="internal">internal</option> </select> </td> </tr> <tr> <td><b>Auth mode</b></td> <td> <select name="auth_mode" style="width: 220px;" required> <option value="user_keys">user_keys</option> <option value="platform_keys">platform_keys</option> <option value="internal">internal</option> </select> </td> </tr> <tr> <td><b>WMS</b></td> <td> <select name="wms" style="width: 220px;"> <option value="">None</option> <option value="slurm">slurm</option> </select> </td> </tr> <tr> <td><b>Container engines</b><br/><span style="font-size:0.8em">(JSON list)</span></td> <td><textarea name="container_engines" rows="2" cols="30" required></textarea></td> </tr> <tr> <td><b>Supported archs</b><br/><span style="font-size:0.8em">(JSON list)</span></td> <td><textarea name="supported_archs" rows="2" cols="30"></textarea></td> </tr> <tr> <td><b>Emulated archs</b><br/><span style="font-size:0.8em">(JSON dict)</span></td> <td><textarea name="emulated_archs" rows="2" cols="30"></textarea></td> </tr> <tr> <td><b>Conf</b><br/><span style="font-size:0.8em">(JSON dict)</span></td> <td><textarea name="conf" rows="2" cols="30"></textarea></td> </tr> </table> <table style="width:500px; border:0; background:#ffffff; margin-top:20px"> <tr><td align="center"> <a href="/computing" class="btn btn-primary" style="margin-left:10px">Back</a> <input type="submit" value="Add" class="btn btn-primary"> </td></tr> </table> </form> </div> </div> </div> {% include "footer.html" %} No newline at end of file
services/webapp/code/rosetta/core_app/templates/components/computing.html +2 −2 Original line number Diff line number Diff line Loading @@ -51,12 +51,12 @@ <tr> <td><b>Container engines</b></td> <td>{{ data.computing.container_engines }}</td> <td>{{ data.computing.container_engines_json }}</td> </tr> <tr> <td><b>Emulated archs</b></td> <td>{{ data.computing.emulated_archs }}</td> <td>{{ data.computing.emulated_archs_json }}</td> </tr> <tr> Loading
services/webapp/code/rosetta/core_app/templates/computing.html +3 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ {% endif %} <hr/> {% if request.user.is_staff %} {% if not data.computing %} <div class="form-filter" style="margin-bottom:20px"> <form action="" method="POST"> Loading @@ -37,10 +38,11 @@ </select> {% csrf_token %} <button type="submit" class="btn btn-secondary">Go</button> <font size=4.0em>|</font> <a href="#" class="disabled" style="pointer-events: none; color: #aaa;">Add new...</a> <font size=4.0em>|</font> <a href="/add_computing">Add new...</a> </form> </div> {% endif %} {% endif %} <div class="row" style="padding:5px"> {% if data.computing %} Loading
services/webapp/code/rosetta/core_app/templates/edit_computing.html +25 −4 Original line number Diff line number Diff line Loading @@ -40,7 +40,12 @@ </tr> <tr> <td><b>Type</b></td> <td><input type="text" name="type" value="{{ data.computing.type }}" size="30" required /></td> <td> <select name="type" style="width: 220px;" required> <option value="cluster" {% if data.computing.type == 'cluster' %}selected{% endif %}>cluster</option> <option value="standalone" {% if data.computing.type == 'standalone' %}selected{% endif %}>standalone</option> </select> </td> </tr> <tr> <td><b>Arch</b></td> Loading @@ -48,15 +53,31 @@ </tr> <tr> <td><b>Access mode</b></td> <td><input type="text" name="access_mode" value="{{ data.computing.access_mode }}" size="30" required /></td> <td> <select name="access_mode" style="width: 220px;" required> <option value="ssh+cli" {% if data.computing.access_mode == 'ssh+cli' %}selected{% endif %}>ssh+cli</option> <option value="internal" {% if data.computing.access_mode == 'internal' %}selected{% endif %}>internal</option> </select> </td> </tr> <tr> <td><b>Auth mode</b></td> <td><input type="text" name="auth_mode" value="{{ data.computing.auth_mode }}" size="30" required /></td> <td> <select name="auth_mode" style="width: 220px;" required> <option value="user_keys" {% if data.computing.auth_mode == 'user_keys' %}selected{% endif %}>user_keys</option> <option value="platform_keys" {% if data.computing.auth_mode == 'platform_keys' %}selected{% endif %}>platform_keys</option> <option value="internal" {% if data.computing.auth_mode == 'internal' %}selected{% endif %}>internal</option> </select> </td> </tr> <tr> <td><b>WMS</b></td> <td><input type="text" name="wms" value="{{ data.computing.wms }}" size="30" /></td> <td> <select name="wms" style="width: 220px;"> <option value="" {% if not data.computing.wms %}selected{% endif %}>None</option> <option value="slurm" {% if data.computing.wms == 'slurm' %}selected{% endif %}>slurm</option> </select> </td> </tr> <tr> <td><b>Container engines</b><br/><span style="font-size:0.8em">(JSON list)</span></td> Loading