commit | b9b955c0c2875effc1ce02d5576f0d2a59284c5d | [log] [tgz] |
---|---|---|
author | Alex Shatov <alexs@att.com> | Thu Mar 08 13:12:23 2018 -0500 |
committer | Alex Shatov <alexs@att.com> | Thu Mar 08 13:12:23 2018 -0500 |
tree | c073f6678be20cc4371bd1e91ca2796a6abf330d | |
parent | dfd79f0cb9f8d418871b5fb7f3616554c3261800 [diff] |
2.2.0 policy-handler - customization per company - added etc_customize/ folder and customize.sh script = customize.sh script is expected to be overridden by company to customize Docker image build = the whole etc_customize/ folder is copied into docker image = it is up to the company what to put into that folder - any files - added customize/ folder with CustomizeBase and Customize classes = CustomizeBase defines the interface and the default=ONAP behavior = CustomizeBase is owned by ONAP and should not be changed by the company = Customize inherits CustomizeBase = policy-handler instantiates Customize to get the customized behavior = Customize is owned by the company and should be changed by the company = ONAP is not going to change Customize = the methods of Customize are expected to be overridden by the company to change the behavior of the policy-handler = sample Customize class can be found in README.md = Company is allowed to add more files to customize/ folder if that is required for better structuring of their code as soon as it is invoked by the methods of Customize Change-Id: I46f8170afaaa48e1005e4398a768a781db0a0e6c Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-379
virtualenv policy_venv
cd policy_venv
source bin/activate
cd ../policy_handler
pip install -r requirements.txt
cd policy_venv
source bin/activate
cd ../policy_handler
in folder policy_handler
:
- `config.json` contains - `"scope_prefixes" : ["DCAE.Config_"]` - the list of policy-scope-class values - `"policy_engine"` - the http connect info to ONAP **policy-engine** - headers.ClientAuth : base64(<mech-id with namespace>:<password>) - headers.Authorization : base64(<policy-engine server auth>) - `"deploy_handler"` - the http connect info to _policy part_ of the **deploy-handler** - `policy_engine.properties` contains config info for the client lib of ONAP **policy-engine** that receives push notifications from the ONAP **policy-engine** server - CLIENT_ID is the mech-id with the namespace - need to register with policy-engine team thru email - CLIENT_KEY is the base64 of the mech-id password - separate passwords for TEST versus PROD
in folder policy_handler
:
./run_policy.sh
etc_customize/
foldercompany is expected to place any company specific files required to be in the docker image in the folder etc_customize/
change the etc_customize/customize.sh
script to perform company specific actions during docker image build
etc_customize/customize.sh
script is expected to be overridden by company to customize docker image build
policyhandler/customize/
foldercontains CustomizeBase
and Customize
classes
CustomizeBase
defines the interface and the default=ONAP behavior
CustomizeBase
is owned by ONAP and should not be changed by the company
Customize
inherits CustomizeBase
policy-handler instantiates Customize
to get the customized behavior
Customize
is owned by the company and should be changed by the company
ONAP is not going to change Customize
the methods of Customize
are expected to be overridden by the company to change the behavior of the policy-handler
samples are provided for methods in Customize
class as the commented out lines
Company is allowed to add more files to customize/ folder if that is required for better structuring of their code as soon as it is invoked by the methods of Customize
here is an example of customizer.py
"""contains the Customizer class with method overrides per company specification""" from .customizer_base import CustomizerBase class Customizer(CustomizerBase): """ the Customizer class inherits CustomizerBase that is owned by ONAP :Customizer: class is owned by the company that needs to customize the policy-handler :override: any method defined in the CustomizerBase class to customize the behavior of the policy-handler """ def __init__(self): """class that contains the customization""" super(Customizer, self).__init__() def get_service_url(self, audit, service_name, service): """ returns the service url when called from DiscoveryClient this is just a sample code - replace it with the real customization """ service_url = super(Customizer, self).get_service_url(audit, service_name, service) audit.info("TODO: customization for service_url on {0}".format(service_name)) return service_url def get_deploy_handler_kwargs(self, audit): """ returns the optional dict-kwargs for requests.post to deploy-handler this is just a sample code - replace it with the real customization """ kwargs = {"verify": "/usr/local/share/ca-certificates/aafcacert.crt"} audit.info("kwargs for requests.post to deploy-handler: {0}".format(json.dumps(kwargs))) return kwargs