add Vendor model to select flavor/image at Tenant creation
Change-Id: Id31ad8540fb6590805988bbbaebfef8d9886d702
diff --git a/xos/models.py b/xos/models.py
index d820ceb..7d0579f 100644
--- a/xos/models.py
+++ b/xos/models.py
@@ -1,5 +1,6 @@
from core.models.plcorebase import *
from models_decl import VBBUService_decl
+from models_decl import VBBUVendor_decl
from models_decl import VBBUTenant_decl
from django.db import models
@@ -25,6 +26,10 @@
t.save()
return t
+class VBBUVendor(VBBUVendor_decl):
+ class Meta:
+ proxy = True
+
class VBBUTenant(VBBUTenant_decl):
class Meta:
proxy = True
@@ -36,6 +41,17 @@
"provider_service").default = vbbuservice[0].id
super(VBBUTenant, self).__init__(*args, **kwargs)
+ @property
+ def image(self):
+ if not self.vbbu_vendor:
+ return super(VBBUTenant, self).image
+ return self.vbbu_vendor.image
+
+ def save_instance(self, instance):
+ if self.vbbu_vendor:
+ instance.flavor = self.vbbu_vendor.flavor
+ super(VBBUTenant, 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_vbbutenant.py b/xos/synchronizer/steps/sync_vbbutenant.py
index 1ec4528..f93e7f7 100644
--- a/xos/synchronizer/steps/sync_vbbutenant.py
+++ b/xos/synchronizer/steps/sync_vbbutenant.py
@@ -9,8 +9,6 @@
sys.path.insert(0, parentdir)
class SyncVBBUTenant(SyncInstanceUsingAnsible):
-
-
provides = [VBBUTenant]
observes = VBBUTenant
@@ -25,15 +23,11 @@
super(SyncVBBUTenant, self).__init__(*args, **kwargs)
def fetch_pending(self, deleted):
-
if (not deleted):
objs = VBBUTenant.get_tenant_objects().filter(
Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
else:
-
objs = VBBUTenant.get_deleted_tenant_objects()
return objs
- def get_extra_attributes(self, o):
- return {"display_message": o.display_message, "s1u_tag": o.s1u_tag, "s1mme_tag": o.s1mme_tag, "rru_tag": o.rru_tag}
diff --git a/xos/synchronizer/steps/vbbutenant_playbook.yaml b/xos/synchronizer/steps/vbbutenant_playbook.yaml
index de19598..74ea6bb 100644
--- a/xos/synchronizer/steps/vbbutenant_playbook.yaml
+++ b/xos/synchronizer/steps/vbbutenant_playbook.yaml
@@ -3,6 +3,7 @@
gather_facts: False
connection: ssh
user: ubuntu
- become: yes
+ sudo: yes
+ tasks:
vars:
- - tenant_message: "{{ tenant_message }}"
+
diff --git a/xos/tosca/custom_types/vbbu.m4 b/xos/tosca/custom_types/vbbu.m4
index 7c5e814..513676f 100644
--- a/xos/tosca/custom_types/vbbu.m4
+++ b/xos/tosca/custom_types/vbbu.m4
@@ -23,3 +23,18 @@
properties:
xos_base_tenant_props
+ tosca.nodes.VBBUVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VBBU 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.VBBUTenant ]
+
diff --git a/xos/tosca/custom_types/vbbu.yaml b/xos/tosca/custom_types/vbbu.yaml
index f368ba3..1fcd3a5 100644
--- a/xos/tosca/custom_types/vbbu.yaml
+++ b/xos/tosca/custom_types/vbbu.yaml
@@ -93,3 +93,18 @@
required: false
description: Service specific ID opaque to XOS but meaningful to service
+ tosca.nodes.VBBUVendor:
+ derived_from: tosca.nodes.Root
+ description: >
+ VBBU 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.VBBUTenant ]
+
diff --git a/xos/tosca/resources/vbbuvendor.py b/xos/tosca/resources/vbbuvendor.py
new file mode 100644
index 0000000..c21fb56
--- /dev/null
+++ b/xos/tosca/resources/vbbuvendor.py
@@ -0,0 +1,31 @@
+from xosresource import XOSResource
+from core.models import Tenant
+from services.vbbu.models import VBBUVendor
+
+class XOSVBBUVendor(XOSResource):
+ provides = "tosca.nodes.VBBUVendor"
+ xos_model = VBBUVendor
+ name_field = None
+ copyin_props = ( "name",)
+
+ def get_xos_args(self, throw_exception=True):
+ args = super(XOSVBBUVendor, 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(XOSVBBUVendor, self).can_delete(obj)
diff --git a/xos/vbbu-onboard.yaml b/xos/vbbu-onboard.yaml
index 1fbeb9e..99b26f1 100644
--- a/xos/vbbu-onboard.yaml
+++ b/xos/vbbu-onboard.yaml
@@ -18,6 +18,6 @@
synchronizer: synchronizer/manifest
synchronizer_run: vbbu-synchronizer.py
tosca_custom_types: tosca/custom_types/vbbu.yaml
- tosca_resource: tosca/resources/vbbutenant.py, tosca/resources/vbbuservice.py
+ tosca_resource: tosca/resources/vbbutenant.py, tosca/resources/vbbuservice.py, tosca/resources/vbbuvendor.py
private_key: file:///opt/xos/key_import/mcord_rsa
public_key: file:///opt/xos/key_import/mcord_rsa.pub
diff --git a/xos/vbbu.xproto b/xos/vbbu.xproto
index 4e00a0d..4816892 100644
--- a/xos/vbbu.xproto
+++ b/xos/vbbu.xproto
@@ -9,7 +9,16 @@
option verbose_name = "Virtual Broadband Base Unit Service";
}
+message VBBUVendor (PlCoreBase){
+ option name = "VBBUVendor";
+ option verbose_name = "Virtual Broadband Base Unit 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 VBBUTenant (TenantWithContainer){
- option name = "VBBUTenant";
- option verbose_name = "Virtual Broadband Base Unit Tenant";
+ option name = "VBBUTenant";
+ option verbose_name = "Virtual Broadband Base Unit Tenant";
+ optional manytoone vbbu_vendor->VBBUVendor:vendor_tenants = 1 [help_text = "select vendor of choice, leave blank for slice default", db_index = True, null = True, blank = True];
}