Add a krbname property to afs.pts.PTEntry, which converts the
[invirt/packages/python-afs.git] / afs / pts.py
index cfbfb7d..9c44f3a 100644 (file)
@@ -1,5 +1,5 @@
 import collections
-import _pts
+from afs import _pts
 
 class PTRelationSet(collections.MutableSet):
     """Collection class for the groups/members of a PTEntry.
@@ -248,6 +248,12 @@ class PTEntry(object):
         self._name = val
     name = property(_get_name, _set_name)
 
+    def _get_krbname(self):
+        return self._pts._AfsToKrb5(self.name)
+    def _set_krbname(self, val):
+        self.name = self._pts._Krb5ToAfs(val)
+    krbname = property(_get_krbname, _set_krbname)
+
     def _get_count(self):
         self._loadEntry()
         return self._count
@@ -354,6 +360,14 @@ class PTS(_pts.PTS):
         else:
             return PTEntry(self, id=ident)
 
+    def getEntryFromKrbname(self, ident):
+        """Retrieve a PTEntry matching a given Kerberos v5 principal.
+
+        getEntryFromKrb accepts a krb5 principal, converts it to the
+        equivalent AFS principal, and returns a PTEntry for that
+        principal."""
+        return self.getEntry(self._Krb5ToAfs(ident))
+
     def expire(self):
         """Flush the cache of PTEntry objects.