Scott Baker | d73afca | 2017-09-05 22:35: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 | ec4d9e4 | 2019-02-04 16:40:38 -0800 | [diff] [blame] | 17 | from xossynchronizer.modelaccessor import * |
| 18 | from xossynchronizer.model_policies.policy import Policy |
Scott Baker | d73afca | 2017-09-05 22:35:25 -0700 | [diff] [blame] | 19 | |
| 20 | class AddressManagerServiceInstancePolicy(Policy): |
| 21 | model_name = "AddressManagerServiceInstance" |
| 22 | |
| 23 | def handle_create(self, service_instance): |
| 24 | return self.handle_update(service_instance) |
| 25 | |
| 26 | def handle_update(self, service_instance): |
| 27 | if (service_instance.link_deleted_count>0) and (not service_instance.provided_links.exists()): |
| 28 | # if the last provided_link has just gone away, then self-destruct |
| 29 | self.logger.info("The last provided link has been deleted -- self-destructing."); |
| 30 | service_instance.delete() |
| 31 | return |