From: Scott Baker Date: Thu, 7 Aug 2008 18:55:07 +0000 (+0000) Subject: added module for misc functions X-Git-Tag: sfa-0.9-0@14641~866 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=aa042650427054eae4d128c17a19fd1995cbded5;p=sfa.git added module for misc functions --- diff --git a/util/misc.py b/util/misc.py new file mode 100644 index 00000000..140c7b52 --- /dev/null +++ b/util/misc.py @@ -0,0 +1,26 @@ +from excep import * + +def get_leaf(hrn): + parts = hrn.split(".") + return ".".join(parts[-1:]) + +def get_authority(hrn): + parts = hrn.split(".") + return ".".join(parts[:-1]) + +def get_auth_type(type): + if (type=="slice") or (type=="user") or (type=="sa"): + return "sa" + elif (type=="component") or (type=="ma"): + return "ma" + else: + raise UnknownGeniType(type) + +def hrn_to_pl_slicename(hrn): + parts = hrn.split(".") + return parts[-2] + "_" + parts[-1] + +def hrn_to_pl_authname(hrn): + parts = hrn.split(".") + return parts[-1] +