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

Small additions to configdb etcd interface

parent ac535be5
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ import etcd ...@@ -4,7 +4,7 @@ import etcd
import cPickle as pickle import cPickle as pickle
import os import os
from urlparse import urlparse from urlparse import urlparse
from configdb.db.interface import inmemory_interface
class EtcdSession(object): class EtcdSession(object):
"""A EtcdInterface session.""" """A EtcdInterface session."""
...@@ -43,7 +43,7 @@ class EtcdSession(object): ...@@ -43,7 +43,7 @@ class EtcdSession(object):
pass pass
class EtcdInterface(base,DbInterface): class EtcdInterface(base.DbInterface):
"""Database interface for an Etcd backend. """Database interface for an Etcd backend.
This needs the 'python-etcd' library, available at: This needs the 'python-etcd' library, available at:
...@@ -54,10 +54,14 @@ class EtcdInterface(base,DbInterface): ...@@ -54,10 +54,14 @@ class EtcdInterface(base,DbInterface):
def __init__(self, url, schema, root='/configdb', timeout=30): def __init__(self, url, schema, root='/configdb', timeout=30):
self.root = root 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): def _serialize(self, obj):
return pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL) return pickle.dumps(obj, protocol=pickle.HIGHEST_PROTOCOL)
...@@ -75,6 +79,8 @@ class EtcdInterface(base,DbInterface): ...@@ -75,6 +79,8 @@ class EtcdInterface(base,DbInterface):
raise NotImplementedError raise NotImplementedError
def create(self, entity_name, attrs, session): def create(self, entity_name, attrs, session):
entity = self.schema.get_entity(entity_name)
object =
raise NotImplementedError raise NotImplementedError
def delete(self, entity_name, object_name, session): def delete(self, entity_name, object_name, session):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment