add Vendor model to select flavor/image at Tenant creation
Change-Id: Ifde87eaa83b0559c83afd7010068dd5465125e37
diff --git a/xos/models.py b/xos/models.py
index d6fcdcd..1a109d8 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -1,5 +1,6 @@
from core.models.plcorebase import *
from models_decl import VSGWUService_decl
+from models_decl import VSGWUVendor_decl
from models_decl import VSGWUTenant_decl
from django.db import models
@@ -25,6 +26,10 @@
t.save()
return t
+class VSGWUVendor(VSGWUVendor_decl):
+ class Meta:
+ proxy = True
+
class VSGWUTenant(VSGWUTenant_decl):
class Meta:
proxy = True
@@ -36,6 +41,17 @@
"provider_service").default = vsgwuservice[0].id
super(VSGWUTenant, self).__init__(*args, **kwargs)
+ @property
+ def image(self):
+ if not self.vsgwu_vendor:
+ return super(VSGWUTenant, self).image
+ return self.vsgwu_vendor.image
+
+ def save_instance(self, instance):
+ if self.vsgwu_vendor:
+ instance.flavor = self.vsgwu_vendor.flavor
+ super(VSGWUTenant, self).save_instance(instance)
+
def save(self, *args, **kwargs):
if not self.creator:
if not getattr(self, "caller", None):
diff --git a/xos/synchronizer/steps/sync_vsgwutenant.py b/xos/synchronizer/steps/sync_vsgwutenant.py
index 5215a34..331a923 100644
--- a/xos/synchronizer/steps/sync_vsgwutenant.py
+++ b/xos/synchronizer/steps/sync_vsgwutenant.py
@@ -8,7 +8,6 @@
sys.path.insert(0, parentdir)
class SyncVSGWUTenant(SyncInstanceUsingAnsible):
-
provides = [VSGWUTenant]
observes = VSGWUTenant
@@ -23,7 +22,6 @@
super(SyncVSGWUTenant, self).__init__(*args, **kwargs)
def fetch_pending(self, deleted):
-
if (not deleted):
objs = VSGWUTenant.get_tenant_objects().filter(
Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
@@ -33,8 +31,3 @@
return objs
- def get_extra_attributes(self, o):
- fields = {}
- fields['tenant_message'] = o.tenant_message
- return fields
-
diff --git a/xos/synchronizer/steps/vsgwutenant_playbook.yaml b/xos/synchronizer/steps/vsgwutenant_playbook.yaml
index ede8674..4d6f0dc 100644
--- a/xos/synchronizer/steps/vsgwutenant_playbook.yaml
+++ b/xos/synchronizer/steps/vsgwutenant_playbook.yaml
@@ -1,11 +1,9 @@
---
- hosts: {{ instance_name }}
+ gather_facts: False
connection: ssh
user: ubuntu
- become: yes
- gather_facts: no
+ sudo: yes
tasks:
-
vars:
- - tenant_message: "{{ tenant_message }}"
diff --git a/xos/tosca/custom_types/vsgwu.m4 b/xos/tosca/custom_types/vsgwu.m4
index ef81b31..566715c 100644
--- a/xos/tosca/custom_types/vsgwu.m4
+++ b/xos/tosca/custom_types/vsgwu.m4
@@ -22,3 +22,19 @@
VSGWU Tenant
properties:
xos_base_tenant_props
+
+ tosca.nodes.VSGWUVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VSGWU Vendor
+ capabilities:
+ xos_bas_service_caps
+ properties:
+ name:
+ type: string
+ required: true
+
+ tosca.relationships.VendorOfTenant:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.VSGWUTenant ]
+
diff --git a/xos/tosca/custom_types/vsgwu.yaml b/xos/tosca/custom_types/vsgwu.yaml
index b231cf3..5f81a89 100644
--- a/xos/tosca/custom_types/vsgwu.yaml
+++ b/xos/tosca/custom_types/vsgwu.yaml
@@ -92,3 +92,19 @@
type: string
required: false
description: Service specific ID opaque to XOS but meaningful to service
+
+ tosca.nodes.VSGWUVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VSGWU Vendor
+ capabilities:
+ xos_bas_service_caps
+ properties:
+ name:
+ type: string
+ required: true
+
+ tosca.relationships.VendorOfTenant:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.VSGWUTenant ]
+
diff --git a/xos/tosca/resources/vsgwuvendor.py b/xos/tosca/resources/vsgwuvendor.py
new file mode 100644
index 0000000..4fffecf
--- /dev/null
+++ b/xos/tosca/resources/vsgwuvendor.py
@@ -0,0 +1,32 @@
+from xosresource import XOSResource
+from core.models import Tenant
+from services.vsgwu.models import VSGWUVendor
+
+class XOSVSGWUVendor(XOSResource):
+ provides = "tosca.nodes.VSGWUVendor"
+ xos_model = VSGWUVendor
+ name_field = None
+ copyin_props = ( "name",)
+
+ def get_xos_args(self, throw_exception=True):
+ args = super(XOSVSGWUVendor, self).get_xos_args()
+
+ tenant_name = self.get_requirement("tosca.relationships.VendorOfTenant", throw_exception=throw_exception)
+ if tenant_name:
+ args["provider_tenant"] = self.get_xos_object(Tenant, throw_exception=throw_exception, name=tenant_name)
+
+ return args
+
+ def get_existing_objs(self):
+ args = self.get_xos_args(throw_exception=False)
+ provider_tenant = args.get("provider", None)
+ if provider_tenant:
+ return [ self.get_xos_object(provider_tenant=provider_tenant) ]
+ return []
+
+ def postprocess(self, obj):
+ pass
+
+ def can_delete(self, obj):
+ return super(XOSVSGWUVendor, self).can_delete(obj)
+
diff --git a/xos/vsgwu-onboard.yaml b/xos/vsgwu-onboard.yaml
index e70a6c8..d63b6d0 100644
--- a/xos/vsgwu-onboard.yaml
+++ b/xos/vsgwu-onboard.yaml
@@ -17,7 +17,7 @@
synchronizer: synchronizer/manifest
synchronizer_run: vsgwu-synchronizer.py
tosca_custom_types: tosca/custom_types/vsgwu.yaml
- tosca_resource: tosca/resources/vsgwutenant.py, tosca/resources/vsgwuservice.py
+ tosca_resource: tosca/resources/vsgwutenant.py, tosca/resources/vsgwuservice.py, tosca/resources/vsgwuvendor.py
private_key: file:///opt/xos/key_import/mcord_rsa
public_key: file:///opt/xos/key_import/mcord_rsa.pub
diff --git a/xos/vsgwu.xproto b/xos/vsgwu.xproto
index 1ffdf94..cdcc822 100644
--- a/xos/vsgwu.xproto
+++ b/xos/vsgwu.xproto
@@ -6,10 +6,19 @@
message VSGWUService (Service){
option name = "VSGWUService";
- option verbose_name = "Virtual Serving Gateway -- User Plane Service ";
+ option verbose_name = "Virtual Serving Gateway -- User Plane Service";
+}
+
+message VSGWUVendor (PlCoreBase){
+ option name = "VSGWUVendor";
+ option verbose_name = "Virtual Serving Gateway -- User Plane Vendor";
+ required string name = 1 [help_text = "vendor name", max_length = 32, null = False, db_index = False, blank = False];
+ required manytoone image->Image:+ = 2 [help_text = "select image for this vendor", db_index = True, null = False, blank = False];
+ required manytoone flavor->Flavor:+ = 3 [help_text = "select openstack flavor for vendor image", db_index = True, null = False, blank = False];
}
message VSGWUTenant (TenantWithContainer){
- option name = "VSGWUTenant";
- option verbose_name = "Virtual Serving Gateway -- User Plane Tenant";
+ option name = "VSGWUTenant";
+ option verbose_name = "Virtual Serving Gateway -- User Plane Tenant";
+ optional manytoone vsgwu_vendor->VSGWUVendor:vendor_tenants = 1 [help_text = "select vendor of choice, leave blank for slice default", db_index = True, null = True, blank = True];
}