Matteo Scandolo | ede125b | 2017-08-08 13:05:25 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Scott Baker | 8f32cc8 | 2016-08-08 10:34:53 -0700 | [diff] [blame] | 17 | from xosresource import XOSResource |
Zack Williams | b7e9776 | 2016-10-05 16:12:36 -0700 | [diff] [blame] | 18 | from services.hpc.models import HpcHealthCheck, HpcService |
Scott Baker | 8f32cc8 | 2016-08-08 10:34:53 -0700 | [diff] [blame] | 19 | |
| 20 | class XOSHpcHealthCheck(XOSResource): |
| 21 | provides = "tosca.nodes.HpcHealthCheck" |
| 22 | xos_model = HpcHealthCheck |
| 23 | name_field = None |
| 24 | copyin_props = ("kind", "resource_name", "result_contains") |
| 25 | |
| 26 | def get_xos_args(self, throw_exception=True): |
| 27 | args = super(XOSHpcHealthCheck, self).get_xos_args() |
| 28 | |
| 29 | service_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception) |
| 30 | if service_name: |
| 31 | args["hpcService"] = self.get_xos_object(HpcService, throw_exception=throw_exception, name=service_name) |
| 32 | |
| 33 | return args |
| 34 | |
| 35 | def get_existing_objs(self): |
| 36 | args = self.get_xos_args(throw_exception=True) |
| 37 | |
| 38 | return list( HpcHealthCheck.objects.filter(hpcService=args["hpcService"], kind=args["kind"], resource_name=args["resource_name"]) ) |
| 39 | |
| 40 | def postprocess(self, obj): |
| 41 | pass |
| 42 | |
| 43 | def can_delete(self, obj): |
| 44 | return super(XOSTenant, self).can_delete(obj) |
| 45 | |