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
7df1c612
Commit
7df1c612
authored
11 years ago
by
joe
Browse files
Options
Downloads
Patches
Plain Diff
Sync the etcd interface with changes in API
parent
4789208e
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
+7
-4
7 additions, 4 deletions
configdb/db/interface/etcd_interface.py
with
7 additions
and
4 deletions
configdb/db/interface/etcd_interface.py
+
7
−
4
View file @
7df1c612
...
@@ -37,7 +37,7 @@ class EtcdSession(inmemory_interface.InMemorySession):
...
@@ -37,7 +37,7 @@ class EtcdSession(inmemory_interface.InMemorySession):
return
path
return
path
def
add
(
self
,
obj
):
def
add
(
self
,
obj
,
create
=
False
):
path
=
self
.
_mkpath
(
obj
.
_entity_name
,
obj
.
name
)
path
=
self
.
_mkpath
(
obj
.
_entity_name
,
obj
.
name
)
# If we don't have a revision,
# If we don't have a revision,
rev
=
self
.
revisions
.
get
(
path
,
None
)
rev
=
self
.
revisions
.
get
(
path
,
None
)
...
@@ -47,6 +47,9 @@ class EtcdSession(inmemory_interface.InMemorySession):
...
@@ -47,6 +47,9 @@ class EtcdSession(inmemory_interface.InMemorySession):
else
:
else
:
opts
=
{
'
prevIndex
'
:
rev
}
opts
=
{
'
prevIndex
'
:
rev
}
if
create
:
opts
[
'
prevExist
'
]
=
False
# Will raise ValueError if the test fails.
# Will raise ValueError if the test fails.
try
:
try
:
r
=
self
.
db
.
conn
.
write
(
path
,
self
.
db
.
_serialize
(
obj
),
**
opts
)
r
=
self
.
db
.
conn
.
write
(
path
,
self
.
db
.
_serialize
(
obj
),
**
opts
)
...
@@ -91,7 +94,7 @@ class EtcdSession(inmemory_interface.InMemorySession):
...
@@ -91,7 +94,7 @@ class EtcdSession(inmemory_interface.InMemorySession):
def
_find
(
self
,
entity_name
):
def
_find
(
self
,
entity_name
):
path
=
self
.
_mkpath
(
entity_name
)
path
=
self
.
_mkpath
(
entity_name
)
for
r
in
self
.
db
.
conn
.
read
(
path
,
recursive
=
True
).
kvs
:
for
r
in
self
.
db
.
conn
.
read
(
path
,
recursive
=
True
).
children
:
if
not
r
.
dir
:
if
not
r
.
dir
:
curpath
=
r
.
key
.
replace
(
self
.
db
.
conn
.
key_endpoint
,
''
)
curpath
=
r
.
key
.
replace
(
self
.
db
.
conn
.
key_endpoint
,
''
)
self
.
revisions
[
curpath
]
=
r
.
modifiedIndex
self
.
revisions
[
curpath
]
=
r
.
modifiedIndex
...
@@ -154,7 +157,7 @@ class EtcdInterface(base.DbInterface):
...
@@ -154,7 +157,7 @@ class EtcdInterface(base.DbInterface):
def
create
(
self
,
entity_name
,
attrs
,
session
):
def
create
(
self
,
entity_name
,
attrs
,
session
):
entity
=
self
.
schema
.
get_entity
(
entity_name
)
entity
=
self
.
schema
.
get_entity
(
entity_name
)
obj
=
inmemory_interface
.
InMemoryObject
(
entity
,
attrs
)
obj
=
inmemory_interface
.
InMemoryObject
(
entity
,
attrs
)
session
.
add
(
obj
)
session
.
add
(
obj
,
create
=
True
)
return
obj
return
obj
def
delete
(
self
,
entity_name
,
obj_name
,
session
):
def
delete
(
self
,
entity_name
,
obj_name
,
session
):
...
@@ -218,7 +221,7 @@ class EtcdInterface(base.DbInterface):
...
@@ -218,7 +221,7 @@ class EtcdInterface(base.DbInterface):
return
[]
return
[]
log
=
[]
log
=
[]
for
result
in
data
.
kvs
:
for
result
in
data
.
children
:
obj
=
json
.
loads
(
result
.
value
)
obj
=
json
.
loads
(
result
.
value
)
if
obj
[
'
data
'
]:
if
obj
[
'
data
'
]:
obj
[
'
data
'
]
=
base64
.
b64decode
(
obj
[
'
data
'
])
obj
[
'
data
'
]
=
base64
.
b64decode
(
obj
[
'
data
'
])
...
...
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