1 # ============LICENSE_START===============================================
2 # Copyright (C) 2020 Nordix Foundation. 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
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.
15 # ============LICENSE_END=================================================
25 #Create a ric info json, example input: ricsim_g1_1:kista_ricsim_g1_1,stockholm_ricsim_g1_1:1,2,4 ricsim_g1_2:kista_ricsim_g1_2,stockholm_ricsim_g1_2:2
26 #Format of string <ric-id>:<comma-separated-list-of-me's>:<comma-separated-list-of-policy-type-ids>
27 #To indicate that no types exist, use 'NOTYPE'. Ex. ricsim_g1_1:kista_ricsim_g1_1,stockholm_ricsim_g1_1:NOTYPE
28 #To indicate that special STD zero length name type, use 'EMPTYTYPE'. Ex. ricsim_g1_1:kista_ricsim_g1_1,stockholm_ricsim_g1_1:EMPTYTYPE
29 #Save in indicated file
32 file_name = sys.argv[1]
33 ric_string = sys.argv[2]
34 ric_string=ric_string.strip()
35 ric_string = re.sub(' +',' ',ric_string)
37 rics=ric_string.split(' ')
38 for i in range(len(rics)):
40 items=rics[i].split(':')
41 ricDict['ricName']=items[0]
42 ricDict['managedElementIds']=items[1].split(',')
43 if (items[2] == "EMPTYTYPE"):
46 ricDict['policyTypes']=empty_arr
47 elif (items[2] == "NOTYPE"):
49 ricDict['policyTypes']=empty_arr
51 ricDict['policyTypes']=items[2].split(',')
52 ricDict['state']=items[3]
53 ric_arr.append(ricDict)
55 with open(file_name, 'w') as f:
60 except Exception as e: