Scott Baker | 8f32cc8 | 2016-08-08 10:34:53 -0700 | [diff] [blame] | 1 | import os |
| 2 | import pdb |
| 3 | import sys |
| 4 | import tempfile |
| 5 | sys.path.append("/opt/tosca") |
| 6 | from translator.toscalib.tosca_template import ToscaTemplate |
| 7 | |
| 8 | from services.hpc.models import ServiceProvider, HpcService |
| 9 | |
| 10 | from xosresource import XOSResource |
| 11 | |
| 12 | class XOSServiceProvider(XOSResource): |
| 13 | provides = "tosca.nodes.ServiceProvider" |
| 14 | xos_model = ServiceProvider |
| 15 | copyin_props = [] |
| 16 | |
| 17 | def get_xos_args(self): |
| 18 | hpc_service_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=True) |
| 19 | hpc_service = self.get_xos_object(HpcService, name=hpc_service_name) |
| 20 | return {"name": self.obj_name, |
| 21 | "hpcService": hpc_service} |
| 22 | |
| 23 | def can_delete(self, obj): |
| 24 | if obj.contentprovider_set.exists(): |
| 25 | self.info("%s %s has active content providers; skipping delete" % (self.xos_model.__class__, obj.name)) |
| 26 | return False |
| 27 | return super(XOSServiceProvider, self).can_delete(obj) |
| 28 | |