check in latest updates to documentation
[sfa.git] / util / misc.py
1 from excep import *
2
3 def get_leaf(hrn):
4     parts = hrn.split(".")
5     return ".".join(parts[-1:])
6
7 def get_authority(hrn):
8     parts = hrn.split(".")\r
9     return ".".join(parts[:-1])\r
10
11 def get_auth_type(type):
12     if (type=="slice") or (type=="user") or (type=="sa"):
13         return "sa"
14     elif (type=="component") or (type=="ma"):
15         return "ma"
16     else:
17         raise UnknownGeniType(type)
18
19 def hrn_to_pl_slicename(hrn):
20     parts = hrn.split(".")
21     return parts[-2] + "_" + parts[-1]
22
23 # assuming hrn is the hrn of an authority, return the plc authority name
24 def hrn_to_pl_authname(hrn):
25     parts = hrn.split(".")
26     return parts[-1]
27
28 # assuming hrn is the hrn of an authority, return the plc login_base
29 def hrn_to_pl_login_base(hrn):
30     return hrn_to_pl_authname(hrn)
31