aboutsummaryrefslogtreecommitdiffstats
path: root/src/resource_inventory/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/resource_inventory/models.py')
-rw-r--r--src/resource_inventory/models.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/resource_inventory/models.py b/src/resource_inventory/models.py
index 7115ece..d1b7a75 100644
--- a/src/resource_inventory/models.py
+++ b/src/resource_inventory/models.py
@@ -155,16 +155,18 @@ class ResourceTemplate(models.Model):
# TODO: template might not be a good name because this is a collection of lots of configured resources
id = models.AutoField(primary_key=True)
- name = models.CharField(max_length=300, unique=True)
+ name = models.CharField(max_length=300)
xml = models.TextField()
owner = models.ForeignKey(User, null=True, on_delete=models.SET_NULL)
lab = models.ForeignKey(Lab, null=True, on_delete=models.SET_NULL, related_name="resourcetemplates")
description = models.CharField(max_length=1000, default="")
public = models.BooleanField(default=False)
temporary = models.BooleanField(default=False)
+ copy_of = models.ForeignKey("ResourceTemplate", null=True, on_delete=models.SET_NULL)
def getConfigs(self):
- return list(self.resourceConfigurations.all())
+ configs = self.resourceConfigurations.all()
+ return list(configs)
def __str__(self):
return self.name
@@ -191,6 +193,13 @@ class ResourceBundle(models.Model):
# TODO
pass
+ def get_template_name(self):
+ if not self.template:
+ return ""
+ if not self.template.temporary:
+ return self.template.name
+ return self.template.copy_of.name
+
class ResourceConfiguration(models.Model):
"""Model to represent a complete configuration for a single physical Resource."""
@@ -200,7 +209,7 @@ class ResourceConfiguration(models.Model):
image = models.ForeignKey("Image", on_delete=models.PROTECT)
template = models.ForeignKey(ResourceTemplate, related_name="resourceConfigurations", null=True, on_delete=models.CASCADE)
is_head_node = models.BooleanField(default=False)
- # name?
+ name = models.CharField(max_length=3000, default="<Hostname>")
def __str__(self):
return "config with " + str(self.template) + " and image " + str(self.image)
@@ -428,7 +437,7 @@ class InterfaceConfiguration(models.Model):
connections = models.ManyToManyField(NetworkConnection)
def __str__(self):
- return "type " + str(self.profile) + " on host " + str(self.host)
+ return "type " + str(self.profile) + " on host " + str(self.resource_config)
"""