Loading services/webapp/code/rosetta/base_app/management/commands/base_app_populate.py +13 −2 Original line number Diff line number Diff line from django.core.management.base import BaseCommand from django.contrib.auth.models import User from ...models import Profile, Container from ...models import Profile, Container, Computing class Command(BaseCommand): help = 'Adds the admin superuser with \'a\' password.' Loading Loading @@ -71,9 +71,20 @@ class Command(BaseCommand): # Computing resources #Computing.objects.create(user = None, # name = 'L', # type = '') # Computing resources #Computing.objects.create(user = None, # name = 'L', # type = '') # Computing resources #Computing.objects.create(user = None, # name = 'L', # type = '') services/webapp/code/rosetta/base_app/models.py +61 −37 Original line number Diff line number Diff line Loading @@ -49,6 +49,56 @@ class LoginToken(models.Model): token = models.CharField('Login token', max_length=36) #========================= # Containers #========================= class Container(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user = models.ForeignKey(User, related_name='+', on_delete=models.CASCADE, null=True) # If a container has no user, it will be available to anyone. Can be created, edited and deleted only by admins. image = models.CharField('Container image', max_length=255, blank=False, null=False) type = models.CharField('Container type', max_length=36, blank=False, null=False) registry = models.CharField('Container registry', max_length=255, blank=False, null=False) service_ports = models.CharField('Container service ports', max_length=36, blank=True, null=True) #private = models.BooleanField('Container is private and needs auth to be pulled from the registry') def __str__(self): return str('Container of type "{}" with image "{}" from registry "{}" of user "{}"'.format(self.type, self.image, self.registry, self.user)) @property def id(self): return str(self.uuid).split('-')[0] #@property #def name(self): # return self.image.split(':')[0].replace('_',' ').replace('-', ' ').replace('/', ' ').title() #========================= # Computing resources #========================= # TODO: this must be an abstract class. Or maybe not? Maybe Add ComputingConfiguration/Handler with the relevant fields and methods? # ...so that can be used as foreign key in the tasks as well? Examples: ComputingConfiguration ComputingType ComputingHandler class Computing(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user = models.ForeignKey(User, related_name='+', on_delete=models.CASCADE, null=True) # If a compute resource has no user, it will be available to anyone. Can be created, edited and deleted only by admins. name = models.CharField('Computing Name', max_length=255, blank=False, null=False) def __str__(self): return str('Computing Resource "{}" of user "{}"'.format(self.name, self.user)) @property def id(self): return str(self.uuid).split('-')[0] #========================= # Tasks #========================= Loading @@ -59,7 +109,7 @@ class Task(models.Model): name = models.CharField('Task name', max_length=36, blank=False, null=False) status = models.CharField('Task status', max_length=36, blank=True, null=True) created = models.DateTimeField('Created on', default=timezone.now) compute = models.CharField('Task compute', max_length=36, blank=True, null=True) computing = models.ForeignKey(Computing, related_name='+', on_delete=models.CASCADE) pid = models.IntegerField('Task pid', blank=True, null=True) port = models.IntegerField('Task port', blank=True, null=True) ip = models.CharField('Task ip address', max_length=36, blank=True, null=True) Loading @@ -84,7 +134,7 @@ class Task(models.Model): def update_status(self): if self.compute == 'local': if self.computing == 'local': check_command = 'sudo docker inspect --format \'{{.State.Status}}\' ' + self.tid # or, .State.Running out = os_shell(check_command, capture=True) Loading @@ -111,30 +161,4 @@ class Task(models.Model): #========================= # Containers #========================= class Container(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user = models.ForeignKey(User, related_name='+', on_delete=models.CASCADE, null=True) # If a container has no user, it will be available to anyone. Can be created, edited and deleted only by admins. image = models.CharField('Container image', max_length=255, blank=False, null=False) type = models.CharField('Container type', max_length=36, blank=False, null=False) registry = models.CharField('Container registry', max_length=255, blank=False, null=False) service_ports = models.CharField('Container service ports', max_length=36, blank=True, null=True) #private = models.BooleanField('Container is private and needs auth to be pulled from the registry') def __str__(self): return str('Container of type "{}" with image "{}" from registry "{}" of user "{}"'.format(self.type, self.image, self.registry, self.user)) @property def id(self): return str(self.uuid).split('-')[0] #@property #def name(self): # return self.image.split(':')[0].replace('_',' ').replace('-', ' ').replace('/', ' ').title() services/webapp/code/rosetta/base_app/templates/computings.html 0 → 100644 +53 −0 Original line number Diff line number Diff line {% load static %} {% include "header.html" %} {% include "navigation.html" with main_path='/main/' %} <br/> <br/> <div class="container"> <div class="dashboard"> <div class="span8 offset2"> {% if data.computing %} <h1><a href="/computings">Computing Resources List</a> > {{ data.computing.id }} </h1> {% else %} <h1>Computing Resources List</h1> {% endif %} <hr/> {% if data.computing %} {% include "components/computing.html" with computing=data.computing %} {% else %} {% for computing in data.platform_computings %} {% include "components/computing.html" with computing=computing %} <br /> {% endfor %} {% for computing in data.user_computings %} {% include "components/computing.html" with computing=computing %} <br /> {% endfor %} <br /> <a href="/add_computing">Add new...</a> {% endif %} <br /> <br /> <br /> <br /> </div> </div> </div> {% include "footer.html" %} services/webapp/code/rosetta/base_app/templates/create_task.html +2 −2 Original line number Diff line number Diff line Loading @@ -64,12 +64,12 @@ <tr> <td><b>Computing resource</b></td><td> <select name="task_compute" > <select name="task_computing" > <option value="local" selected>Local</option> <option value="demoremote">Demo remote</option> <option value="demoslurm">Demo Slurm cluster</option> </select> | <a href="/add_compute">Add new...</a> | <a href="/add_computing">Add new...</a> </td> </tr> Loading services/webapp/code/rosetta/base_app/templates/navigation.html +3 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ {% if user.is_authenticated %} <li> <a href="/computings" onclick = $("#menu-close").click(); >Computing</a> </li> <li> <a href="/containers" onclick = $("#menu-close").click(); >Containers</a> </li> Loading Loading
services/webapp/code/rosetta/base_app/management/commands/base_app_populate.py +13 −2 Original line number Diff line number Diff line from django.core.management.base import BaseCommand from django.contrib.auth.models import User from ...models import Profile, Container from ...models import Profile, Container, Computing class Command(BaseCommand): help = 'Adds the admin superuser with \'a\' password.' Loading Loading @@ -71,9 +71,20 @@ class Command(BaseCommand): # Computing resources #Computing.objects.create(user = None, # name = 'L', # type = '') # Computing resources #Computing.objects.create(user = None, # name = 'L', # type = '') # Computing resources #Computing.objects.create(user = None, # name = 'L', # type = '')
services/webapp/code/rosetta/base_app/models.py +61 −37 Original line number Diff line number Diff line Loading @@ -49,6 +49,56 @@ class LoginToken(models.Model): token = models.CharField('Login token', max_length=36) #========================= # Containers #========================= class Container(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user = models.ForeignKey(User, related_name='+', on_delete=models.CASCADE, null=True) # If a container has no user, it will be available to anyone. Can be created, edited and deleted only by admins. image = models.CharField('Container image', max_length=255, blank=False, null=False) type = models.CharField('Container type', max_length=36, blank=False, null=False) registry = models.CharField('Container registry', max_length=255, blank=False, null=False) service_ports = models.CharField('Container service ports', max_length=36, blank=True, null=True) #private = models.BooleanField('Container is private and needs auth to be pulled from the registry') def __str__(self): return str('Container of type "{}" with image "{}" from registry "{}" of user "{}"'.format(self.type, self.image, self.registry, self.user)) @property def id(self): return str(self.uuid).split('-')[0] #@property #def name(self): # return self.image.split(':')[0].replace('_',' ').replace('-', ' ').replace('/', ' ').title() #========================= # Computing resources #========================= # TODO: this must be an abstract class. Or maybe not? Maybe Add ComputingConfiguration/Handler with the relevant fields and methods? # ...so that can be used as foreign key in the tasks as well? Examples: ComputingConfiguration ComputingType ComputingHandler class Computing(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user = models.ForeignKey(User, related_name='+', on_delete=models.CASCADE, null=True) # If a compute resource has no user, it will be available to anyone. Can be created, edited and deleted only by admins. name = models.CharField('Computing Name', max_length=255, blank=False, null=False) def __str__(self): return str('Computing Resource "{}" of user "{}"'.format(self.name, self.user)) @property def id(self): return str(self.uuid).split('-')[0] #========================= # Tasks #========================= Loading @@ -59,7 +109,7 @@ class Task(models.Model): name = models.CharField('Task name', max_length=36, blank=False, null=False) status = models.CharField('Task status', max_length=36, blank=True, null=True) created = models.DateTimeField('Created on', default=timezone.now) compute = models.CharField('Task compute', max_length=36, blank=True, null=True) computing = models.ForeignKey(Computing, related_name='+', on_delete=models.CASCADE) pid = models.IntegerField('Task pid', blank=True, null=True) port = models.IntegerField('Task port', blank=True, null=True) ip = models.CharField('Task ip address', max_length=36, blank=True, null=True) Loading @@ -84,7 +134,7 @@ class Task(models.Model): def update_status(self): if self.compute == 'local': if self.computing == 'local': check_command = 'sudo docker inspect --format \'{{.State.Status}}\' ' + self.tid # or, .State.Running out = os_shell(check_command, capture=True) Loading @@ -111,30 +161,4 @@ class Task(models.Model): #========================= # Containers #========================= class Container(models.Model): uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user = models.ForeignKey(User, related_name='+', on_delete=models.CASCADE, null=True) # If a container has no user, it will be available to anyone. Can be created, edited and deleted only by admins. image = models.CharField('Container image', max_length=255, blank=False, null=False) type = models.CharField('Container type', max_length=36, blank=False, null=False) registry = models.CharField('Container registry', max_length=255, blank=False, null=False) service_ports = models.CharField('Container service ports', max_length=36, blank=True, null=True) #private = models.BooleanField('Container is private and needs auth to be pulled from the registry') def __str__(self): return str('Container of type "{}" with image "{}" from registry "{}" of user "{}"'.format(self.type, self.image, self.registry, self.user)) @property def id(self): return str(self.uuid).split('-')[0] #@property #def name(self): # return self.image.split(':')[0].replace('_',' ').replace('-', ' ').replace('/', ' ').title()
services/webapp/code/rosetta/base_app/templates/computings.html 0 → 100644 +53 −0 Original line number Diff line number Diff line {% load static %} {% include "header.html" %} {% include "navigation.html" with main_path='/main/' %} <br/> <br/> <div class="container"> <div class="dashboard"> <div class="span8 offset2"> {% if data.computing %} <h1><a href="/computings">Computing Resources List</a> > {{ data.computing.id }} </h1> {% else %} <h1>Computing Resources List</h1> {% endif %} <hr/> {% if data.computing %} {% include "components/computing.html" with computing=data.computing %} {% else %} {% for computing in data.platform_computings %} {% include "components/computing.html" with computing=computing %} <br /> {% endfor %} {% for computing in data.user_computings %} {% include "components/computing.html" with computing=computing %} <br /> {% endfor %} <br /> <a href="/add_computing">Add new...</a> {% endif %} <br /> <br /> <br /> <br /> </div> </div> </div> {% include "footer.html" %}
services/webapp/code/rosetta/base_app/templates/create_task.html +2 −2 Original line number Diff line number Diff line Loading @@ -64,12 +64,12 @@ <tr> <td><b>Computing resource</b></td><td> <select name="task_compute" > <select name="task_computing" > <option value="local" selected>Local</option> <option value="demoremote">Demo remote</option> <option value="demoslurm">Demo Slurm cluster</option> </select> | <a href="/add_compute">Add new...</a> | <a href="/add_computing">Add new...</a> </td> </tr> Loading
services/webapp/code/rosetta/base_app/templates/navigation.html +3 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,9 @@ {% if user.is_authenticated %} <li> <a href="/computings" onclick = $("#menu-close").click(); >Computing</a> </li> <li> <a href="/containers" onclick = $("#menu-close").click(); >Containers</a> </li> Loading