Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 1 | import os |
| 2 | from django.db import models |
Siobhan Tully | 30fd429 | 2013-05-10 08:59:56 -0400 | [diff] [blame] | 3 | from core.models import PlCoreBase |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 4 | from core.models import Deployment,Controller,ControllerLinkManager,ControllerLinkDeletionManager |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 5 | |
| 6 | # Create your models here. |
| 7 | |
| 8 | class Image(PlCoreBase): |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 9 | name = models.CharField(max_length=256, unique=True) |
| 10 | disk_format = models.CharField(max_length=256) |
| 11 | container_format = models.CharField(max_length=256) |
Tony Mack | bf39d9f | 2014-05-06 21:42:36 -0400 | [diff] [blame] | 12 | path = models.CharField(max_length=256, null=True, blank=True, help_text="Path to image on local disk") |
Scott Baker | 5308f0a | 2014-12-22 15:59:05 -0800 | [diff] [blame] | 13 | deployments = models.ManyToManyField('Deployment', through='ImageDeployments', blank=True, help_text="Select which images should be instantiated on this deployment", related_name='images') |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 14 | |
| 15 | def __unicode__(self): return u'%s' % (self.name) |
Tony Mack | bf39d9f | 2014-05-06 21:42:36 -0400 | [diff] [blame] | 16 | |
Tony Mack | 336e0f9 | 2014-11-30 15:53:08 -0500 | [diff] [blame] | 17 | class ImageDeployments(PlCoreBase): |
| 18 | image = models.ForeignKey(Image,related_name='imagedeployments') |
| 19 | deployment = models.ForeignKey(Deployment,related_name='imagedeployments') |
| 20 | |
| 21 | def __unicode__(self): return u'%s %s' % (self.image, self.deployment) |
| 22 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 23 | class ControllerImages(PlCoreBase): |
| 24 | objects = ControllerLinkManager() |
| 25 | deleted_objects = ControllerLinkDeletionManager() |
| 26 | image = models.ForeignKey(Image,related_name='controllerimages') |
| 27 | controller = models.ForeignKey(Controller,related_name='controllerimages') |
Tony Mack | bf39d9f | 2014-05-06 21:42:36 -0400 | [diff] [blame] | 28 | glance_image_id = models.CharField(null=True, blank=True, max_length=200, help_text="Glance image id") |
| 29 | |
Tony Mack | f3bbe47 | 2014-11-30 15:33:35 -0500 | [diff] [blame] | 30 | def __unicode__(self): return u'%s %s' % (self.image, self.controller) |
Tony Mack | bf39d9f | 2014-05-06 21:42:36 -0400 | [diff] [blame] | 31 | |
| 32 | |