diff options
| author | Andrew Bogott <abogott@wikimedia.org> | 2012-01-13 01:40:10 +0000 |
|---|---|---|
| committer | Andrew Bogott <abogott@wikimedia.org> | 2012-01-13 18:54:43 +0000 |
| commit | 6f8e167fcaf81d3e4c221cd1d4c1bc84ceb61a9d (patch) | |
| tree | 757c9f61f876dfd432a8a02fb777bc8fa6110e3f | |
| parent | 485328e48fc7dff1ce2ebfd262c442d8f993688b (diff) | |
| download | nova-6f8e167fcaf81d3e4c221cd1d4c1bc84ceb61a9d.tar.gz nova-6f8e167fcaf81d3e4c221cd1d4c1bc84ceb61a9d.tar.xz nova-6f8e167fcaf81d3e4c221cd1d4c1bc84ceb61a9d.zip | |
Modify the fake ldap driver to fix compatibility.
The fake implementation was raising an exception during a failed
search_s where the normal python ldap module does not. So, removed
that raise.
Also added a modrdn_s implementation because I need it for a network test.
(Indirectly) for blueprint public-and-private-dns.
Change-Id: Ia86a776afe19ffce72b285bb4c96ce3ed0ae7c4a
| -rw-r--r-- | nova/auth/fakeldap.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/nova/auth/fakeldap.py b/nova/auth/fakeldap.py index f576da8e7..d092e7e42 100644 --- a/nova/auth/fakeldap.py +++ b/nova/auth/fakeldap.py @@ -266,6 +266,20 @@ class FakeLDAP(object): values.remove(v) values = store.hset(key, k, _to_json(values)) + def modrdn_s(self, dn, newrdn): + oldobj = self.search_s(dn, SCOPE_BASE) + if not oldobj: + raise NO_SUCH_OBJECT() + newdn = "%s,%s" % (newrdn, dn.partition(',')[2]) + newattrs = oldobj[0][1] + + modlist = [] + for attrtype in newattrs.keys(): + modlist.append((attrtype, newattrs[attrtype])) + + self.add_s(newdn, modlist) + self.delete_s(dn) + def search_s(self, dn, scope, query=None, fields=None): """Search for all matching objects under dn using the query. @@ -283,10 +297,14 @@ class FakeLDAP(object): raise NotImplementedError(str(scope)) store = Store.instance() if scope == SCOPE_BASE: - keys = ["%s%s" % (self.__prefix, dn)] + pattern = "%s%s" % (self.__prefix, dn) + keys = store.keys(pattern) else: keys = store.keys("%s*%s" % (self.__prefix, dn)) + if not keys: + raise NO_SUCH_OBJECT() + objects = [] for key in keys: # get the attributes from the store @@ -301,9 +319,6 @@ class FakeLDAP(object): attrs = dict([(k, v) for k, v in attrs.iteritems() if not fields or k in fields]) objects.append((key[len(self.__prefix):], attrs)) - # pylint: enable=E1103 - if objects == []: - raise NO_SUCH_OBJECT() return objects @property |
