added 'image_name' property to vPGWC Tenant model
you can now choose which VM you want for a given instance
in tosca using the 'image_name' property
Change-Id: I2f889caf6640d96c18f2cb006d3270cd8cb4555a
diff --git a/xos/models.py b/xos/models.py
index 987260b..f52a8ac 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -60,7 +60,7 @@
# default_attributes is used cleanly indicate what the default values for
# the fields are.
- default_attributes = {"display_message": "New vPGWC Component", "s5s8_pgw_tag": "300"}
+ default_attributes = {"display_message": "New vPGWC Component", "s5s8_pgw_tag": "300", "image_name": "default"}
def __init__(self, *args, **kwargs):
pgwc_services = VPGWCService.get_service_objects().all()
# When the tenant is created the default service in the form is set
@@ -183,6 +183,15 @@
(a, b, c, d) = ip.split('.')
return "02:42:%02x:%02x:%02x:%02x" % (int(a), int(b), int(c), int(d))
+
+ @property
+ def image(self):
+ img = self.image_name.strip()
+ if img.lower() != "default":
+ return Image.objects.get(name=img)
+ else:
+ return super(VMMETenant, self).image
+
# Getter for the message that will appear on the webpage
# By default it is "Hello World!"
@property
@@ -196,6 +205,16 @@
self.set_attribute("display_message", value)
@property
+ def image_name(self):
+ return self.get_attribute(
+ "image_name",
+ self.default_attributes['image_name'])
+
+ @image_name.setter
+ def image_name(self, value):
+ self.set_attribute("image_name", value)
+
+ @property
def s5s8_pgw_tag(self):
return self.get_attribute(
"s5s8_pgw_tag",