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 CDNPrefix, ContentProvider |
Scott Baker | 8f32cc8 | 2016-08-08 10:34:53 -0700 | [diff] [blame] | 19 | |
| 20 | class XOSCDNPrefix(XOSResource): |
| 21 | provides = "tosca.nodes.CDNPrefix" |
| 22 | xos_model = CDNPrefix |
| 23 | name_field = "prefix" |
| 24 | copyin_props = [] |
| 25 | |
| 26 | def get_xos_args(self): |
| 27 | args = {"prefix": self.obj_name} |
| 28 | |
| 29 | cp_name = self.get_requirement("tosca.relationships.MemberOfContentProvider") |
| 30 | if cp_name: |
| 31 | args["contentProvider"] = self.get_xos_object(ContentProvider, name=cp_name) |
| 32 | |
| 33 | default_os = self.get_requirement("tosca.relationships.DefaultOriginServer") |
| 34 | if default_os: |
| 35 | args["defaultOriginServer"] = self.engine.name_to_xos_model(self.user, default_os) |
| 36 | |
| 37 | return args |
| 38 | |
| 39 | def can_delete(self, obj): |
| 40 | return super(XOSCDNPrefix, self).can_delete(obj) |
| 41 | |