blob: 66742ea2d033befb76c077d940c3ecb5a8945240 [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 ContentProvider, ServiceProvider
9
10from xosresource import XOSResource
11
12class XOSContentProvider(XOSResource):
13 provides = "tosca.nodes.ContentProvider"
14 xos_model = ContentProvider
15 copyin_props = []
16
17 def get_xos_args(self):
18 sp_name = self.get_requirement("tosca.relationships.MemberOfServiceProvider", throw_exception=True)
19 sp = self.get_xos_object(ServiceProvider, name=sp_name)
20 return {"name": self.obj_name,
21 "serviceProvider": sp}
22
23 def can_delete(self, obj):
24 if obj.cdnprefix_set.exists():
25 self.info("%s %s has active CDN prefixes; skipping delete" % (self.xos_model.__class__, obj.name))
26 return False
27 return super(XOSContentProvider, self).can_delete(obj)
28