4 from geni.util.faults import *
12 def set_tree_globals(tree1, tree2):
15 global_sr_tree = tree1
16 global_cr_tree = tree2
18 def get_tree_globals():
19 return (global_sr_tree, global_cr_tree)
21 #function converts a hierarchical name from geni format to array of strings
22 def geni_to_arr(name):
25 parts = name.split(".")
26 for i in range(len(parts)):
27 arrayName.append(parts[i])
30 raise MalformedHrnException(name)
32 #used to parse the function name and the parameters specified in "operation_request"
33 def msg_to_params(str):
37 raise InvalidRPCParams(str)
39 #returns the authority hrn of a given 'hrn'
40 def obtain_authority(hrn):
41 parts = hrn.split(".")
44 auth_str = parts[0]+''
45 for i in range(1, len(parts)-1):
46 auth_str = auth_str + '.' + parts[i]
49 #returns the last element of an hrn
51 parts = hrn.split(".")
52 return parts[len(parts)-1]
54 #checks whether the 'hrn_auth' is an authority of 'hrn'
55 def check_authority(hrn, hrn_auth):
56 arr = geni_to_arr(hrn)
57 arr_auth = geni_to_arr(hrn_auth)
59 for i in range(len(arr_auth)):
60 if arr[i] != arr_auth[i]:
66 def hrn_to_tablename(hrn,type):
67 hrn = hrn.replace(".","$")