git://git.onelab.eu
/
plcapi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
====
[plcapi.git]
/
tools
/
dzombie.py
diff --git
a/tools/dzombie.py
b/tools/dzombie.py
index
6ccc58a
..
2095c96
100755
(executable)
--- a/
tools/dzombie.py
+++ b/
tools/dzombie.py
@@
-37,8
+37,11
@@
try:
line = lines[index].strip()
# find all created objects
if line.startswith("CREATE"):
line = lines[index].strip()
# find all created objects
if line.startswith("CREATE"):
- item_type = line.split(" ")[1].strip()
- item_name = line.split(" ")[2].strip()
+ line_parts = line.split(" ")
+ if line_parts[1:3] == ['OR', 'REPLACE']:
+ line_parts = line_parts[2:]
+ item_type = line_parts[1].strip()
+ item_name = line_parts[2].strip()
if item_type.upper() in ['TABLE']:
while index < len(lines):
index = index + 1
if item_type.upper() in ['TABLE']:
while index < len(lines):
index = index + 1
@@
-72,7
+75,7
@@
try:
# do not delete from primary tables
if foreign_key_parts[0] in ['addresses', 'boot_states', 'conf_files', \
# do not delete from primary tables
if foreign_key_parts[0] in ['addresses', 'boot_states', 'conf_files', \
- 'keys', 'messages', 'nodegroups', '
nodenetwork
s', 'nodes', 'pcus', 'peers' \
+ 'keys', 'messages', 'nodegroups', '
interface
s', 'nodes', 'pcus', 'peers' \
'persons', 'roles', 'sessions', 'sites', 'slices']:
#print "skipping table %s" % foreign_key_parts[0]
continue
'persons', 'roles', 'sessions', 'sites', 'slices']:
#print "skipping table %s" % foreign_key_parts[0]
continue
@@
-108,7
+111,7
@@
try:
# delete these zombie records
if zombie_keys_list:
print " -> Deleting %d zombie record(s) from %s after checking %s" % \
# delete these zombie records
if zombie_keys_list:
print " -> Deleting %d zombie record(s) from %s after checking %s" % \
- (len(zombie_keys_list), foreign_key
[0], primary_key
[0])
+ (len(zombie_keys_list), foreign_key
_parts[0], primary_key_parts
[0])
sql_delete = 'DELETE FROM %s WHERE %s IN %s' % \
(foreign_key_parts[0], foreign_key_parts[1], tuple(zombie_keys_list))
cursor.execute(sql_delete)
sql_delete = 'DELETE FROM %s WHERE %s IN %s' % \
(foreign_key_parts[0], foreign_key_parts[1], tuple(zombie_keys_list))
cursor.execute(sql_delete)