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 ContentProvider, ServiceProvider |
| 9 | |
| 10 | from xosresource import XOSResource |
| 11 | |
| 12 | class 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 | |