Scott Baker | 31acc65 | 2016-06-23 15:47:56 -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 | import pdb |
| 8 | |
Srikanth Vavilapalli | d84b7b7 | 2016-06-28 00:19:07 +0000 | [diff] [blame] | 9 | from services.monitoring.models import MonitoringChannel, CeilometerService |
Scott Baker | 31acc65 | 2016-06-23 15:47:56 -0700 | [diff] [blame] | 10 | |
| 11 | from xosresource import XOSResource |
| 12 | |
| 13 | class XOSCeilometerTenant(XOSResource): |
| 14 | provides = "tosca.nodes.CeilometerTenant" |
| 15 | xos_model = MonitoringChannel |
| 16 | name_field = None |
| 17 | |
| 18 | def get_xos_args(self, throw_exception=True): |
| 19 | args = super(XOSCeilometerTenant, self).get_xos_args() |
| 20 | |
| 21 | provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception) |
| 22 | if provider_name: |
| 23 | args["provider_service"] = self.get_xos_object(CeilometerService, throw_exception=throw_exception, name=provider_name) |
| 24 | |
| 25 | return args |
| 26 | |
| 27 | def get_existing_objs(self): |
| 28 | args = self.get_xos_args(throw_exception=False) |
| 29 | provider_service = args.get("provider", None) |
| 30 | if provider_service: |
| 31 | return [ self.get_xos_object(provider_service=provider_service) ] |
| 32 | return [] |
| 33 | |
| 34 | def postprocess(self, obj): |
| 35 | pass |
| 36 | |
| 37 | def can_delete(self, obj): |
| 38 | return super(XOSCeilometerTenant, self).can_delete(obj) |
| 39 | |