diff options
author | Parker Berberian <pberberian@iol.unh.edu> | 2019-01-18 16:30:27 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2019-01-18 16:30:27 +0000 |
commit | 9fc7bfe1b88a720b381ef49bb98cc594924de605 (patch) | |
tree | d22b902a67a0cb9c9c6f49d0bfe05e390080e327 /src/resource_inventory/models.py | |
parent | 184dd8ad3a2e2b58f7d25ac6fa1e7ac80c1c5511 (diff) | |
parent | d8e2dbb57cc90ebdffb9ca463b91948b9b634918 (diff) |
Merge "Add Quick-Booking Workflow"
Diffstat (limited to 'src/resource_inventory/models.py')
-rw-r--r-- | src/resource_inventory/models.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/resource_inventory/models.py b/src/resource_inventory/models.py index b56317b..5b07077 100644 --- a/src/resource_inventory/models.py +++ b/src/resource_inventory/models.py @@ -25,7 +25,7 @@ class HostProfile(models.Model): labs = models.ManyToManyField(Lab, related_name="hostprofiles") def validate(self): - validname = re.compile("^[A-Za-z0-9\-\_\.\/\, ]+$") + validname = re.compile(r"^[A-Za-z0-9\-\_\.\/\, ]+$") if not validname.match(self.name): return "Invalid host profile name given. Name must only use A-Z, a-z, 0-9, hyphens, underscores, dots, commas, or spaces." else: @@ -147,7 +147,7 @@ class GenericResourceBundle(models.Model): class GenericResource(models.Model): bundle = models.ForeignKey(GenericResourceBundle, related_name='generic_resources', on_delete=models.DO_NOTHING) - hostname_validchars = RegexValidator(regex='(?=^.{1,253}$)(?=(^([A-Za-z0-9\-\_]{1,62}\.)*[A-Za-z0-9\-\_]{1,63}$))', message="Enter a valid hostname. Full domain name may be 1-253 characters, each hostname 1-63 characters (including suffixed dot), and valid characters for hostnames are A-Z, a-z, 0-9, hyphen (-), and underscore (_)") + hostname_validchars = RegexValidator(regex=r'(?=^.{1,253}$)(?=(^([A-Za-z0-9\-\_]{1,62}\.)*[A-Za-z0-9\-\_]{1,63}$))', message="Enter a valid hostname. Full domain name may be 1-253 characters, each hostname 1-63 characters (including suffixed dot), and valid characters for hostnames are A-Z, a-z, 0-9, hyphen (-), and underscore (_)") name = models.CharField(max_length=200, validators=[hostname_validchars]) def getHost(self): @@ -157,7 +157,7 @@ class GenericResource(models.Model): return self.name def validate(self): - validname = re.compile('(?=^.{1,253}$)(?=(^([A-Za-z0-9\-\_]{1,62}\.)*[A-Za-z0-9\-\_]{1,63}$))') + validname = re.compile(r'(?=^.{1,253}$)(?=(^([A-Za-z0-9\-\_]{1,62}\.)*[A-Za-z0-9\-\_]{1,63}$))') if not validname.match(self.name): return "Enter a valid hostname. Full domain name may be 1-253 characters, each hostname 1-63 characters (including suffixed dot), and valid characters for hostnames are A-Z, a-z, 0-9, hyphen (-), and underscore (_)" else: @@ -265,6 +265,7 @@ class Image(models.Model): # may need to change host_type.on_delete to models.SET() once images are transferrable between compatible host types host_type = models.ForeignKey(HostProfile, on_delete=models.CASCADE) description = models.TextField() + os = models.ForeignKey(Opsys, null=True, on_delete=models.CASCADE) def __str__(self): return self.name |