Scott Baker | cae4241 | 2015-08-05 18:23:40 -0700 | [diff] [blame] | 1 | # note: this module named xossite.py instead of site.py due to conflict with |
| 2 | # /usr/lib/python2.7/site.py |
| 3 | |
| 4 | import os |
| 5 | import pdb |
| 6 | import sys |
| 7 | import tempfile |
| 8 | sys.path.append("/opt/tosca") |
| 9 | from translator.toscalib.tosca_template import ToscaTemplate |
| 10 | |
| 11 | from core.models import User,Deployment |
| 12 | |
| 13 | from xosresource import XOSResource |
| 14 | |
| 15 | class XOSDeployment(XOSResource): |
| 16 | provides = "tosca.nodes.Deployment" |
| 17 | xos_model = Deployment |
Scott Baker | ab49896 | 2015-09-22 17:26:31 -0700 | [diff] [blame] | 18 | copyin_props = ["accessControl"] |
Scott Baker | cae4241 | 2015-08-05 18:23:40 -0700 | [diff] [blame] | 19 | |
| 20 | def get_xos_args(self): |
Scott Baker | ab49896 | 2015-09-22 17:26:31 -0700 | [diff] [blame] | 21 | args = super(XOSDeployment, self).get_xos_args() |
Scott Baker | cae4241 | 2015-08-05 18:23:40 -0700 | [diff] [blame] | 22 | |
| 23 | return args |
| 24 | |
| 25 | def create(self): |
| 26 | xos_args = self.get_xos_args() |
| 27 | |
| 28 | slice = Deployment(**xos_args) |
| 29 | slice.caller = self.user |
| 30 | slice.save() |
| 31 | |
| 32 | self.info("Created Deployment '%s'" % (str(slice), )) |
| 33 | |
| 34 | def delete(self, obj): |
| 35 | if obj.sites.exists(): |
| 36 | self.info("Deployment %s has active sites; skipping delete" % obj.name) |
| 37 | return |
| 38 | #if obj.nodes.exists(): |
| 39 | # self.info("Deployment %s has active nodes; skipping delete" % obj.name) |
| 40 | # return |
| 41 | super(XOSDeployment, self).delete(obj) |
| 42 | |
| 43 | |
| 44 | |