fixed typo in 'image' property, now 'VSGWTenant' instead of 'VMMETenant'
added 'image_name' property to vSGW Tenant model
you can now choose which VM you want for a given instance
in tosca using the 'image_name' property
Change-Id: Idfcd29f871f31464d1c6e0717f000d0d5f603286
diff --git a/xos/admin.py b/xos/admin.py
index 8dc98d9..a7b9850 100644
--- a/xos/admin.py
+++ b/xos/admin.py
@@ -78,6 +78,7 @@
if self.instance:
self.fields['creator'].initial = self.instance.creator
self.fields['tenant_message'].initial = self.instance.tenant_message
+ self.fields['image_name'].initial = self.instance.image_name
if (not self.instance) or (not self.instance.pk):
self.fields['creator'].initial = get_request().user
@@ -87,6 +88,7 @@
def save(self, commit=True):
self.instance.creator = self.cleaned_data.get('creator')
self.instance.tenant_message = self.cleaned_data.get('tenant_message')
+ self.instance.image_name = self.cleaned_data.get('image_name')
return super(VSGWTenantForm, self).save(commit=commit)
@@ -95,11 +97,11 @@
verbose_name = TENANT_NAME_VERBOSE
verbose_name_plural = TENANT_NAME_VERBOSE_PLURAL
- list_display = ('id', 'backend_status_icon', 'instance', 'tenant_message')
- list_display_links = ('backend_status_icon', 'instance', 'tenant_message', 'id')
+ list_display = ('id', 'backend_status_icon', 'instance', 'tenant_message', 'image_name')
+ list_display_links = ('backend_status_icon', 'instance', 'tenant_message', 'id', 'image_name')
fieldsets = [(None, {
- 'fields': ['backend_status_text', 'kind', 'provider_service', 'instance', 'creator', 'tenant_message'],
+ 'fields': ['backend_status_text', 'kind', 'provider_service', 'instance', 'creator', 'tenant_message', 'image_name'],
'classes': ['suit-tab suit-tab-general'],
})]
diff --git a/xos/models.py b/xos/models.py
index b06b72f..e4f75a5 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -1,6 +1,6 @@
# models.py - vSGW Models
-from core.models import Service, TenantWithContainer
+from core.models import Service, TenantWithContainer, Image
from django.db import models, transaction
MCORD_KIND = 'EPC'
@@ -28,6 +28,7 @@
verbose_name = TENANT_NAME_VERBOSE
tenant_message = models.CharField(max_length=254, help_text="Tenant Message to Display")
+ image_name = models.CharField(max_length=254, help_text="Name of VM image")
def __init__(self, *args, **kwargs):
vsgw_service = VSGWService.get_service_objects().all()
@@ -43,6 +44,14 @@
self.cleanup_container()
super(VSGWTenant, self).delete(*args, **kwargs)
+ @property
+ def image(self):
+ img = self.image_name.strip()
+ if img.lower() != "default":
+ return Image.objects.get(name=img)
+ else:
+ return super(VSGWTenant, self).image
+
def model_policy_vsgwtenant(pk):
with transaction.atomic():
tenant = VSGWTenant.objects.select_for_update().filter(pk=pk)
diff --git a/xos/synchronizer/steps/sync_vsgw.py b/xos/synchronizer/steps/sync_vsgw.py
index ddc06e9..375c3a1 100644
--- a/xos/synchronizer/steps/sync_vsgw.py
+++ b/xos/synchronizer/steps/sync_vsgw.py
@@ -36,5 +36,6 @@
def get_extra_attributes(self, o):
fields = {}
fields['tenant_message'] = o.tenant_message
+ fields['image_name'] = o.image_name
return fields
diff --git a/xos/tosca/resources/vsgwtenant.py b/xos/tosca/resources/vsgwtenant.py
index ecf6051..f53048a 100644
--- a/xos/tosca/resources/vsgwtenant.py
+++ b/xos/tosca/resources/vsgwtenant.py
@@ -5,7 +5,7 @@
provides = "tosca.nodes.VSGWTenant"
xos_model = VSGWTenant
name_field = "service_specific_id"
- copyin_props = ("tenant_message",)
+ copyin_props = ("tenant_message", "image_name")
def get_xos_args(self, throw_exception=True):
args = super(XOSVSGWTenant, self).get_xos_args()