Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
configdb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai
configdb
Commits
de438e7b
Commit
de438e7b
authored
11 years ago
by
joe
Browse files
Options
Downloads
Patches
Plain Diff
Small additions to configdb etcd interface
parent
ac535be5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
configdb/db/interface/etcd_interface.py
+11
-5
11 additions, 5 deletions
configdb/db/interface/etcd_interface.py
with
11 additions
and
5 deletions
configdb/db/interface/etcd_interface.py
+
11
−
5
View file @
de438e7b
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment