1 # -------------------------------------------------------------------------
2 # Copyright (c) 2015-2017 AT&T Intellectual Property
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 # -------------------------------------------------------------------------
23 def get_local_policies(local_policy_folder, local_policy_list, policy_id_list=None):
25 Get policies from a local file system.
26 Required for the following scenarios:
27 (a) doing work-arounds (e.g. if we are asked to drop some policies for testing purposes)
28 (b) work-arounds when policy platform is giving issues (e.g. if dev/IST policies are wiped out in an upgrade)
29 :param local_policy_folder: where the policy files are present
30 :param local_policy_list: list of local policies
31 :param policy_id_list: list of policies to get (if unspecified or None, get all)
35 for fname in local_policy_list: # ugly removal of .json from file name
36 if policy_id_list and fname[:-5] not in policy_id_list:
38 with open(os.path.join(local_policy_folder, fname)) as fid:
39 policies.append(json.load(fid))