add Vendor model to select flavor/image at Tenant creation
Change-Id: I3dc5cb6235c77e9c1b84be58a0b6d6c9d254ffa2
diff --git a/xos/models.py b/xos/models.py
index 16bc8c2..cc2132b 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -1,5 +1,6 @@
from core.models.plcorebase import *
from models_decl import VSGWCService_decl
+from models_decl import VSGWCVendor_decl
from models_decl import VSGWCTenant_decl
from django.db import models
@@ -25,6 +26,10 @@
t.save()
return t
+class VSGWCVendor(VSGWCVendor_decl):
+ class Meta:
+ proxy = True
+
class VSGWCTenant(VSGWCTenant_decl):
class Meta:
proxy = True
@@ -36,6 +41,17 @@
"provider_service").default = vsgwcservice[0].id
super(VSGWCTenant, self).__init__(*args, **kwargs)
+ @property
+ def image(self):
+ if not self.vsgwc_vendor:
+ return super(VSGWCTenant, self).image
+ return self.vsgwc_vendor.image
+
+ def save_instance(self, instance):
+ if self.vsgwc_vendor:
+ instance.flavor = self.vsgwc_vendor.flavor
+ super(VSGWCTenant, 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_vsgwctenant.py b/xos/synchronizer/steps/sync_vsgwctenant.py
index 31583f2..d54262c 100644
--- a/xos/synchronizer/steps/sync_vsgwctenant.py
+++ b/xos/synchronizer/steps/sync_vsgwctenant.py
@@ -8,7 +8,6 @@
sys.path.insert(0, parentdir)
class SyncVSGWCTenant(SyncInstanceUsingAnsible):
-
provides = [VSGWCTenant]
observes = VSGWCTenant
@@ -23,7 +22,6 @@
super(SyncVSGWCTenant, self).__init__(*args, **kwargs)
def fetch_pending(self, deleted):
-
if (not deleted):
objs = VSGWCTenant.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/vsgwctenant_playbook.yaml b/xos/synchronizer/steps/vsgwctenant_playbook.yaml
index ede8674..74ea6bb 100644
--- a/xos/synchronizer/steps/vsgwctenant_playbook.yaml
+++ b/xos/synchronizer/steps/vsgwctenant_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/vsgwc.m4 b/xos/tosca/custom_types/vsgwc.m4
index 9e24b92..25f2f91 100644
--- a/xos/tosca/custom_types/vsgwc.m4
+++ b/xos/tosca/custom_types/vsgwc.m4
@@ -22,3 +22,19 @@
VSGWC Tenant
properties:
xos_base_tenant_props
+
+ tosca.nodes.VSGWCVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VSGWC 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.VSGWCTenant ]
+
diff --git a/xos/tosca/custom_types/vsgwc.yaml b/xos/tosca/custom_types/vsgwc.yaml
index de51ecd..0940165 100644
--- a/xos/tosca/custom_types/vsgwc.yaml
+++ b/xos/tosca/custom_types/vsgwc.yaml
@@ -92,3 +92,19 @@
type: string
required: false
description: Service specific ID opaque to XOS but meaningful to service
+
+ tosca.nodes.VSGWCVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VSGWC 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.VSGWCTenant ]
+
diff --git a/xos/tosca/resources/vsgwcvendor.py b/xos/tosca/resources/vsgwcvendor.py
new file mode 100644
index 0000000..a7e9cba
--- /dev/null
+++ b/xos/tosca/resources/vsgwcvendor.py
@@ -0,0 +1,32 @@
+from xosresource import XOSResource
+from core.models import Tenant
+from services.vsgwc.models import VSGWCVendor
+
+class XOSVSGWCVendor(XOSResource):
+ provides = "tosca.nodes.VSGWCVendor"
+ xos_model = VSGWCVendor
+ name_field = None
+ copyin_props = ( "name",)
+
+ def get_xos_args(self, throw_exception=True):
+ args = super(XOSVSGWCVendor, 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(XOSVSGWCVendor, self).can_delete(obj)
+
diff --git a/xos/vsgwc-onboard.yaml b/xos/vsgwc-onboard.yaml
index fb01bf6..244583e 100644
--- a/xos/vsgwc-onboard.yaml
+++ b/xos/vsgwc-onboard.yaml
@@ -17,7 +17,7 @@
synchronizer: synchronizer/manifest
synchronizer_run: vsgwc-synchronizer.py
tosca_custom_types: tosca/custom_types/vsgwc.yaml
- tosca_resource: tosca/resources/vsgwctenant.py, tosca/resources/vsgwcservice.py
+ tosca_resource: tosca/resources/vsgwctenant.py, tosca/resources/vsgwcservice.py, tosca/resources/vsgwcvendor.py
private_key: file:///opt/xos/key_import/mcord_rsa
public_key: file:///opt/xos/key_import/mcord_rsa.pub
diff --git a/xos/vsgwc.xproto b/xos/vsgwc.xproto
index a84f7cf..6757ae1 100644
--- a/xos/vsgwc.xproto
+++ b/xos/vsgwc.xproto
@@ -9,7 +9,16 @@
option verbose_name = "Virtual Serving Gateway -- Control Plane Service";
}
+message VSGWCVendor (PlCoreBase){
+ option name = "VSGWCVendor";
+ option verbose_name = "Virtual Serving Gateway -- Control 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 VSGWCTenant (TenantWithContainer){
- option name = "VSGWCTenant";
- option verbose_name = "Virtual Serving Gateway -- Control Plane Tenant";
+ option name = "VSGWCTenant";
+ option verbose_name = "Virtual Serving Gateway -- Control Plane Tenant";
+ optional manytoone vsgwc_vendor->VSGWCVendor:vendor_tenants = 1 [help_text = "select vendor of choice, leave blank for slice default", db_index = True, null = True, blank = True];
}