Skip to content
Snippets Groups Projects
Commit abce8443 authored by joe's avatar joe
Browse files

Changed the encode/decode of master keys to handle how etcd works.

Also fixed a typo in calling write() with a parameter.
parent 31b1f6ab
No related branches found
No related tags found
No related merge requests found
...@@ -22,11 +22,10 @@ class EtcdSession(inmemory_interface.InMemorySession): ...@@ -22,11 +22,10 @@ class EtcdSession(inmemory_interface.InMemorySession):
self.db = db self.db = db
def _escape(self,s): def _escape(self,s):
# Hack alert! Since etcd interprets any '/' as a dir separator, return s.encode('hex')
# we simply replace it with a double backslash in the path.
# this of course introduces a potential bug. def _unescape(self, s):
s = s.replace('/','\\\\') return s.decode('hex')
return urllib.quote(s, safe='')
def _mkpath(self, entity_name, obj_name=None): def _mkpath(self, entity_name, obj_name=None):
path = os.path.join(self.db.root, self._escape(entity_name)) path = os.path.join(self.db.root, self._escape(entity_name))
...@@ -188,7 +187,7 @@ class EtcdInterface(base.DbInterface): ...@@ -188,7 +187,7 @@ class EtcdInterface(base.DbInterface):
} }
self.conn.write(path, json.dumps(audit)) self.conn.write(path, json.dumps(audit))
try: try:
self.conn.write(path, json.dumps(audit), prevExist=False) self.conn.write(path, json.dumps(audit))
except ValueError: except ValueError:
pass pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment