attach TenantView to MyDeployment
diff --git a/xos/configurations/common/mydeployment.yaml b/xos/configurations/common/mydeployment.yaml
index 9d2c951..66bb75d 100644
--- a/xos/configurations/common/mydeployment.yaml
+++ b/xos/configurations/common/mydeployment.yaml
@@ -38,13 +38,16 @@
node: MyDeployment
relationship: tosca.relationships.SiteDeployment
- # Include the Tenant view so we can make it a default of padmin@vicci.org
+ # Attach the Tenant view to the MyDeployment deployment
Tenant:
type: tosca.nodes.DashboardView
properties:
no-create: true
- no-update: true
no-delete: true
+ requirements:
+ - deployment:
+ node: MyDeployment
+ relationship: tosca.relationships.SupportsDeployment
padmin@vicci.org:
type: tosca.nodes.User
@@ -62,3 +65,5 @@
node: Tenant
relationship: tosca.relationships.UsesDashboard
+
+
diff --git a/xos/tosca/resources/dashboardview.py b/xos/tosca/resources/dashboardview.py
index 9f7687c..3bce58d 100644
--- a/xos/tosca/resources/dashboardview.py
+++ b/xos/tosca/resources/dashboardview.py
@@ -17,6 +17,14 @@
def get_xos_args(self):
return super(XOSDashboardView, self).get_xos_args()
+ def postprocess(self, obj):
+ for deployment_name in self.get_requirements("tosca.relationships.SupportsDeployment"):
+ deployment = self.get_xos_object(Deployment, deployment_name)
+ if not deployment in obj.deployments.all():
+ print "attaching dashboardview %s to deployment %s" % (obj, deployment)
+ obj.deployments.add(deployment)
+ obj.save()
+
def can_delete(self, obj):
return super(XOSDashboardView, self).can_delete(obj)