blob: 2c9a167aafadacb986ca9d2edec188dd7081d1f2 [file] [log] [blame]
Scott Baker8f32cc82016-08-08 10:34:53 -07001import os
2import pdb
3import sys
4import tempfile
5sys.path.append("/opt/tosca")
6from translator.toscalib.tosca_template import ToscaTemplate
7
8from services.hpc.models import ServiceProvider, HpcService
9
10from xosresource import XOSResource
11
12class 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