From de438e7b145ff4fe5681307bbdad7f2d6821e719 Mon Sep 17 00:00:00 2001 From: joe <joe@autistici.org> Date: Mon, 4 Nov 2013 07:53:58 +0100 Subject: [PATCH] Small additions to configdb etcd interface --- configdb/db/interface/etcd_interface.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/configdb/db/interface/etcd_interface.py b/configdb/db/interface/etcd_interface.py index 682ed27..faef00c 100644 --- a/configdb/db/interface/etcd_interface.py +++ b/configdb/db/interface/etcd_interface.py @@ -4,7 +4,7 @@ import etcd import cPickle as pickle import os from urlparse import urlparse - +from configdb.db.interface import inmemory_interface class EtcdSession(object): """A EtcdInterface session.""" @@ -43,7 +43,7 @@ class EtcdSession(object): pass -class EtcdInterface(base,DbInterface): +class EtcdInterface(base.DbInterface): """Database interface for an Etcd backend. This needs the 'python-etcd' library, available at: @@ -54,10 +54,14 @@ class EtcdInterface(base,DbInterface): def __init__(self, url, schema, root='/configdb', timeout=30): self.root = root - res = + try: + p = urlparse(url) + host, port = p.netloc.split(':') + except ValueError: + raise ValueError('Url {} is not in the host:port format'.format(p.netloc)) + + self.conn = etcd.Client(host=host, port=port, protocol = p.schema, allow_reconnect = True) - self.conn = etcd.Client() - pass def _serialize(self, obj): return pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL) @@ -75,6 +79,8 @@ class EtcdInterface(base,DbInterface): raise NotImplementedError def create(self, entity_name, attrs, session): + entity = self.schema.get_entity(entity_name) + object = raise NotImplementedError def delete(self, entity_name, object_name, session): -- GitLab