From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci/utils luci_admin
Date: 13 Jun 2006 17:36:20 -0000 [thread overview]
Message-ID: <20060613173620.6987.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-06-13 17:36:20
Modified files:
luci/utils : luci_admin
Log message:
new backup
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/utils/luci_admin.diff?cvsroot=cluster&r1=1.4&r2=1.5
--- conga/luci/utils/luci_admin 2006/06/06 21:05:43 1.4
+++ conga/luci/utils/luci_admin 2006/06/13 17:36:20 1.5
@@ -12,17 +12,10 @@
from sys import stderr, argv
from ZODB.FileStorage import FileStorage
from ZODB.DB import DB
-from ZODB.serialize import referencesf
-from ZODB.ExportImport import *
-from ZODB.FileStorage.format import *
-from ZODB.Connection import *
-from OFS.ZDOM import *
-import OFS
-from OFS.XMLExportImport import *
-from Products.ZODBMountPoint import MountedObject
-
-
-
+import xml
+import xml.dom
+from xml.dom import minidom
+import types
LUCI_USER='zope'
@@ -39,6 +32,34 @@
print "TODO: implement me"
return 1
+# This function's ability to work is dependent
+# upon the structure of @dict
+def dataToXML(doc, dict, tltag):
+ node = doc.createElement(tltag)
+ for i in dict:
+ if isinstance(dict[i], types.DictType):
+ if i[-4:] == 'List':
+ tagname = i
+ else:
+ tagname = tltag[:-4]
+ temp = dataToXML(doc, dict[i], tagname)
+ node.appendChild(temp)
+ elif isinstance(dict[i], types.StringType) or isinstance(dict[i], types.IntType):
+ temp = doc.createElement('item')
+ temp.setAttribute('key', i)
+ temp.setAttribute('value', str(dict[i]))
+ node.appendChild(temp.cloneNode(True))
+ elif isinstance(dict[i], types.ListType):
+ if len(dict[i]) < 1:
+ continue
+ temp = doc.createElement(i)
+ for x in dict[i]:
+ t = doc.createElement('ref')
+ t.setAttribute('name', x)
+ temp.appendChild(t.cloneNode(True))
+ node.appendChild(temp.cloneNode(True))
+ return node.cloneNode(True)
+
def luci_backup(argv):
if len(argv) > 0:
dbfn = argv[0]
@@ -54,6 +75,10 @@
stderr.write('Unable to open the luci database \"' + dbfn + '\"\n')
sys.exit(1)
+ systems = {}
+ clusters = {}
+ users = {}
+
examine_classes = [ 'OFS.Folder.Folder',
'AccessControl.User.User',
'Products.CMFCore.MemberDataTool.MemberData' ]
@@ -78,7 +103,6 @@
sys.stderr = null
f.write('<?xml version="1.0"?>\n')
- f.write('<ZopeData>\n')
next_oid = None
while True:
@@ -87,81 +111,137 @@
try:
obj = conn.get(oid)
obj_class = str(type(obj)).split('\'')[1]
+ except:
+ continue
- if obj_class in examine_classes:
- conn.setstate(obj)
- if obj_class == 'OFS.Folder.Folder':
- if obj.__dict__['title'].split(':')[0] != '__luci__':
- raise
- elif obj_class == 'AccessControl.User.User':
- if not 'name' in obj.__dict__ or not '__' in obj.__dict__ or obj.__dict__['__'][0] != '{':
- raise
- elif obj_class == 'Products.CMFCore.MemberDataTool.MemberData':
- if not 'id' in obj.__dict__:
- raise
-
- # This better not fail.
- try:
- pickle, serial = conn._storage.load(oid, conn._version)
- referencesf(pickle, [oid])
- f.write(OFS.XMLExportImport.XMLrecord(oid, len(pickle), pickle))
- except:
- sys.stderr = temp
- sys.stderr.write('An error occurred while backing up the luci database.')
- sys.exit(1)
-
- # Anything that is caught here will have been raised by something
- # we don't care about.
- except: pass
+ if not obj_class in examine_classes:
+ continue
+ try:
+ conn.setstate(obj)
+ dict = obj.__dict__
+ except:
+ continue
+
+ if obj_class == 'OFS.Folder.Folder':
+ if not 'title' in dict or dict['title'][0:9] != '__luci__:':
+ continue
+ title = dict['title'].split(':')
+ cur = None
+
+ if title[1] == 'cluster':
+ clusters[dict['id']] = {
+ 'id': dict['id'],
+ 'title': dict['title'],
+ 'permList': [],
+ 'systemsList:': []
+ }
+ cur = clusters[dict['id']]
+ elif title[1] == 'csystem':
+ if len(title) > 2:
+ clusterName = title[2]
+ else:
+ parent = obj.parentNode()
+ clusterName = parent.__dict__['id']
+ clusters[clusterName]['systemsList'].append(dict['id'])
+ elif title[1] == 'system':
+ systems[dict['id']] = {
+ 'id': dict['id'],
+ 'title': dict['title'],
+ 'permList': []
+ }
+ cur = systems[dict['id']]
+ else:
+ # we don't care
+ continue
+
+ if cur:
+ roles = dict['__ac_local_roles__']
+ for i in roles:
+ if not i in users:
+ users[i] = { 'id': i }
+ if 'View' in roles[i]:
+ cur['permList'].append(i)
+ elif obj_class == 'AccessControl.User.User':
+ if not dict['name'] in users:
+ users[dict['name']] = {}
+ cur_user = users[dict['name']]
+ cur_user['name'] = dict['name']
+ cur_user['passwd'] = dict['__']
+ elif obj_class == 'Products.CMFCore.MemberDataTool.MemberData':
+ if not 'id' in dict:
+ continue
+ if not dict['id'] in users:
+ users[dict['id']] = {}
+ cur_user = users[dict['id']]
+ for i in dict:
+ cur_user[i] = dict[i]
if next_oid is None:
break
-
sys.stderr = temp
- f.write('</ZopeData>\n\n')
- f.flush()
- f.write('<CertificateData>\n\t<list>\n')
+ backup = {'systemList': systems, 'cluterList': clusters, 'userList': users }
+ doc = xml.dom.minidom.Document()
+ dataNode = dataToXML(doc, backup, 'backupData')
+
try:
certfile = file(SSL_PRIVKEY_PATH, 'rb')
output = certfile.read()
+
# should be at least some length greater than one
# TODO: find out what the min length of a valid keyfile is.
if len(output) < 1:
raise
- except:
+
+ certNode = doc.createElement('Certificate')
+ certNode.setAttribute('name', SSL_PRIVKEY_PATH)
+ certNode.setAttribute('data', output)
+ dataNode.appendChild(certNode.cloneNode(True))
+ certfile.close()
+ except False:
sys.stderr.write('Unable to read ' + SSL_PRIVKEY_PATH + '\n')
sys.exit(1)
- f.write('\t\t<tuple>\n\t\t\t<name=\"' + SSL_PRIVKEY_PATH + '\" />\n\t\t\t<data=\"' + output + '\" />\n\t\t</tuple>\n')
try:
certfile = file(SSL_PUBKEY_PATH, 'rb')
output = certfile.read()
+
# should be at least some length greater than one
# TODO: find out what the min length of a valid keyfile is.
if len(output) < 1:
raise
+
+ certNode = doc.createElement('Certificate')
+ certNode.setAttribute('name', SSL_PUBKEY_PATH)
+ certNode.setAttribute('data', output)
+ dataNode.appendChild(certNode.cloneNode(True))
+ certfile.close()
except:
sys.stderr.write('Unable to read ' + SSL_PUBKEY_PATH + '\n')
sys.exit(1)
- f.write('\t\t<tuple>\n\t\t\t<name=\"' + SSL_PUBKEY_PATH + '\" />\n\t\t\t<data=\"' + output + '\" />\n\t\t</tuple>\n')
try:
certfile = file(SSL_KEYCONFIG_PATH, 'rb')
output = certfile.read()
+
# should be at least some length greater than one
# TODO: find out what the min length of a valid key conf is.
if len(output) < 1:
raise
+
+ certNode = document.createElement('CertificateConfig')
+ certNode.setAttribute('name', SSL_KEYCONFIG_PATH)
+ certNode.setAttribute('data', output)
+ dataNode.appendChild(certNode.cloneNode(TRUE))
+ certfile.close()
except:
sys.stderr.write('Unable to read ' + SSL_KEYCONFIG_PATH + '\n')
- f.write('\t\t<tuple>\n\t\t\t<name=\"' + SSL_KEYCONFIG_PATH + '\" />\n\t\t\t<data=\"' + output + '\" />\n\t\t</tuple>\n')
- f.write('\t</list>\n</CertificateData>\n')
+ f.write(dataNode.toprettyxml())
+ f.flush()
f.close()
-
def _execWithCaptureErrorStatus(command, argv, searchPath = 0, root = '/', stdin = 0, catchfd = 1, catcherrfd = 2, closefd = -1):
if not os.access (root + command, os.X_OK):
raise RuntimeError, command + " can not be run"
next reply other threads:[~2006-06-13 17:36 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-13 17:36 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-06-13 18:42 [Cluster-devel] conga/luci/utils luci_admin rmccabe
2006-06-16 5:35 rmccabe
2006-06-16 17:44 rmccabe
2006-06-16 18:17 rmccabe
2006-06-16 19:35 rmccabe
2006-06-16 23:19 rmccabe
2006-06-18 3:26 rmccabe
2006-06-18 12:50 rmccabe
2006-06-18 15:02 rmccabe
2006-06-21 17:06 rmccabe
2006-06-21 17:41 rmccabe
2006-06-21 23:06 rmccabe
2006-06-26 20:01 rmccabe
2006-06-26 22:30 rmccabe
2006-06-27 18:19 rmccabe
2006-06-27 19:40 rmccabe
2006-06-27 19:50 rmccabe
2006-06-29 17:51 rmccabe
2006-06-29 18:04 rmccabe
2006-07-11 14:51 rmccabe
2006-07-11 18:46 rmccabe
2006-07-25 22:36 rmccabe
2006-07-26 1:17 rmccabe
2006-08-02 20:45 rmccabe
2006-08-02 20:52 rmccabe
2006-08-02 23:29 rmccabe
2006-08-03 3:30 rmccabe
2006-08-03 3:58 rmccabe
2006-08-03 12:26 rmccabe
2006-08-03 15:55 rmccabe
2006-08-03 16:32 rmccabe
2006-08-03 21:11 rmccabe
2006-08-03 21:19 rmccabe
2006-08-03 22:58 kupcevic
2006-08-04 18:37 rmccabe
2006-08-04 19:19 rmccabe
2006-08-18 18:03 rmccabe
2006-10-13 6:56 kupcevic
2007-08-07 20:22 rmccabe
2007-08-10 18:32 rmccabe
2007-08-10 18:33 rmccabe
2007-08-10 18:36 rmccabe
2007-09-19 5:17 rmccabe
2011-03-25 20:14 rmccabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060613173620.6987.qmail@sourceware.org \
--to=rmccabe@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.