Alex Shatov | b9b955c | 2018-03-08 13:12:23 -0500 | [diff] [blame] | 1 | # ================================================================================ |
| 2 | # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. |
| 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 | # ============LICENSE_END========================================================= |
| 16 | # |
| 17 | # ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 18 | |
| 19 | """ |
| 20 | contains the base class :CustomizerBase: |
| 21 | that defines the signatures and default behavior of the methods called by the policy-handler |
| 22 | |
| 23 | the methods are expected to be overriden by the child class Cutomizer that is company specific |
| 24 | |
| 25 | :do NOT change: this class and/or this file - it is owned by ONAP |
| 26 | """ |
| 27 | |
| 28 | import logging |
| 29 | |
| 30 | class CustomizerBase(object): |
| 31 | """ |
| 32 | base class for Customizer class |
| 33 | |
| 34 | do NOT change this class and/or this file - it is owned by ONAP |
| 35 | |
| 36 | policy-hanlder is using the instance of the child Customizer class to get the overriden methods |
| 37 | |
Alex Shatov | c9ec231 | 2018-06-14 12:06:42 -0400 | [diff] [blame] | 38 | the methods defined in this class are the placeholders and are expected |
| 39 | to be overriden by the Customizer class |
Alex Shatov | b9b955c | 2018-03-08 13:12:23 -0500 | [diff] [blame] | 40 | """ |
| 41 | |
| 42 | def __init__(self): |
| 43 | """base class for customization contains the default methods""" |
| 44 | self._logger = logging.getLogger("policy_handler.customizer") |
| 45 | self._logger.info("created customizer") |
| 46 | |
| 47 | def get_service_url(self, audit, service_name, service): |
| 48 | """returns the service url when called from DiscoveryClient""" |
| 49 | service_url = "http://{0}:{1}".format( |
| 50 | service.get("ServiceAddress", ""), service.get("ServicePort", "")) |
| 51 | |
| 52 | info = "no customization for service_url: {0} on {1}".format(service_url, service_name) |
| 53 | self._logger.info(info) |
| 54 | audit.info(info) |
| 55 | return service_url |
| 56 | |
| 57 | def get_deploy_handler_kwargs(self, audit): |
Alex Shatov | d7f34d4 | 2018-08-07 12:11:35 -0400 | [diff] [blame^] | 58 | """returns the optional dict-kwargs for requests.put to deploy_handler""" |
| 59 | info = "no optional kwargs for requests.put to deploy_handler" |
Alex Shatov | b9b955c | 2018-03-08 13:12:23 -0500 | [diff] [blame] | 60 | self._logger.info(info) |
| 61 | audit.info(info) |
| 62 | kwargs = {} |
| 63 | return kwargs |