Hi,
The attached patch switches the new account provisioning to use fsocpf by
default, with an option to use sqlite.
I'm aware that fsocpf isn't so advanced at the moment, but I think its likely
to be a better option for our immediate work.
Comments on the patch (here, or on reviewboard at
http://colo1.frogmouth.net/r/9/) would be appreciated.
Brad
Index: python/openchange/provision.py
===================================================================
--- python/openchange/provision.py (revision 1816)
+++ python/openchange/provision.py (working copy)
@@ -37,9 +37,25 @@
def openchangedb_url(lp):
return os.path.join(lp.get("private dir"), "openchange.ldb")
-def openchangedb_mapistore_url(lp):
- return os.path.join(lp.get("private dir"), "mapistore");
+def openchangedb_mapistore_dir(lp):
+ return os.path.join(lp.get("private dir"), "mapistore")
+def openchangedb_mapistore_url(lp, backend):
+ if backend == "fsocpf":
+ return "fsocpf://" + openchangedb_mapistore_dir(lp)
+ if backend == "sqlite":
+ return "sqlite://" + openchangedb_mapistore_dir(lp)
+ print "#### unsupported mapistore backend type:" + backend
+ print "#### using fsocpf instead"
+ return "fsocpf://" + openchangedb_mapistore_dir(lp)
+
+def suffix_for_mapistore_url(url):
+ if (url.startswith("fsocpf://")):
+ return ""
+ if (url.startswith("sqlite://")):
+ return ".db"
+ return ""
+
# This is a hack. Kind-of cute, but still a hack
def abstract():
import inspect
@@ -256,7 +272,7 @@
provision_schema(setup_path, names, lp, creds, reporter, "AD/oc_provision_configuration.ldif", "Exchange Samba with Exchange configuration objects")
print "[SUCCESS] Done!"
-def newmailbox(lp, username, firstorg, firstou):
+def newmailbox(lp, username, firstorg, firstou, backend):
names = guess_names_from_smbconf(lp, firstorg, firstou)
db = mailbox.OpenChangeDB(openchangedb_url(lp))
@@ -273,8 +289,8 @@
assert not db.user_exists(names.netbiosname, username)
# Step 3. Create a default mapistore content repository for this user
- db.add_storage_dir(mapistoreURL=openchangedb_mapistore_url(lp), username=username)
- print "* Mapistore content repository created: %s" % os.path.join(openchangedb_mapistore_url(lp), username)
+ db.add_storage_dir(mapistoreURL=openchangedb_mapistore_dir(lp), username=username)
+ print "* Mapistore content repository created: %s" % os.path.join(openchangedb_mapistore_dir(lp), username)
# Step 4. Create the user object
retdn = db.add_mailbox_user(names.ocfirstorgdn, username=username)
@@ -306,12 +322,14 @@
GlobalCount = db.get_message_GlobalCount(names.netbiosname)
ReplicaID = db.get_message_ReplicaID(names.netbiosname)
+ url = openchangedb_mapistore_url(lp, backend)
fid = db.add_mailbox_root_folder(names.ocfirstorgdn,
username=username, foldername=name,
parentfolder=parent_fid, GlobalCount=GlobalCount,
ReplicaID=ReplicaID, SystemIdx=SystemIdx,
- mapistoreURL=openchangedb_mapistore_url(lp))
+ mapistoreURL=url,
+ mapistoreSuffix=suffix_for_mapistore_url(url))
GlobalCount += 1
db.set_message_GlobalCount(names.netbiosname, GlobalCount=GlobalCount)
@@ -332,7 +350,7 @@
(("Mailbox Root", "IPM Subtree"), "Journal", "IPF.Journal", "PidTagIpmJournalEntryId"),
(("Mailbox Root", "IPM Subtree"), "Notes", "IPF.StickyNote", "PidTagIpmNoteEntryId"),
(("Mailbox Root", "IPM Subtree"), "Tasks", "IPF.Task", "PidTagIpmTaskEntryId"),
- (("Mailbox Root", "IPM Subtree"), "Drafts", "IPF.Note", "PidTagIpmDraftsEntryId")
+ (("Mailbox Root", "IPM Subtree"), "Drafts", "IPF.Note", "PidTagIpmDraftsEntryId")
]
fid_inbox = fids[("Mailbox Root", "IPM Subtree", "Inbox")]
@@ -341,9 +359,10 @@
for path, foldername, containerclass, pidtag in special_folders:
GlobalCount = db.get_message_GlobalCount(names.netbiosname)
ReplicaID = db.get_message_ReplicaID(names.netbiosname)
+ url = openchangedb_mapistore_url(lp, backend)
fid = db.add_mailbox_special_folder(username, fids[path], fid_inbox, foldername,
containerclass, GlobalCount, ReplicaID,
- openchangedb_mapistore_url(lp))
+ url, suffix_for_mapistore_url(url))
db.add_folder_property(fid_inbox, pidtag, fid)
db.add_folder_property(fid_mailbox, pidtag, fid)
GlobalCount += 1
Index: python/openchange/mailbox.py
===================================================================
--- python/openchange/mailbox.py (revision 1816)
+++ python/openchange/mailbox.py (working copy)
@@ -204,7 +204,8 @@
def add_mailbox_root_folder(self, ocfirstorgdn, username,
foldername, parentfolder,
GlobalCount, ReplicaID,
- SystemIdx, mapistoreURL):
+ SystemIdx, mapistoreURL,
+ mapistoreSuffix):
"""Add a root folder to the user mailbox
:param username: Username object
@@ -212,6 +213,8 @@
:param GlobalCount: current global counter for message database
:param ReplicaID: replica identifier for message database
:param SystemIdx: System Index for root folders
+ :param mapistoreURL: storage URL prefix (including type)
+ :param mapistoreSuffix: file type suffix to use with mapistore
"""
ocuserdn = "CN=%s,%s" % (username, ocfirstorgdn)
@@ -223,7 +226,7 @@
m.dn = ldb.Dn(self.ldb, ocuserdn)
m["PidTagFolderId"] = ldb.MessageElement([FID], ldb.CHANGETYPE_ADD, "PidTagFolderId")
m["SystemIdx"] = ldb.MessageElement([str(SystemIdx)], ldb.CHANGETYPE_ADD, "SystemIdx")
- m["mapistore_uri"] = ldb.MessageElement(["sqlite://%s/%s/%s.db" % (mapistoreURL, username, FID)], ldb.CHANGETYPE_ADD, "mapistore_uri")
+ m["mapistore_uri"] = ldb.MessageElement(["%s/%s/%s%s" % (mapistoreURL, username, FID, mapistoreSuffix)], ldb.CHANGETYPE_ADD, "mapistore_uri")
self.ldb.modify(m)
return FID
@@ -240,8 +243,8 @@
"PidTagFolderId": FID,
"PidTagDisplayName": foldername,
"PidTagAttrHidden": str(0),
- "PidTagContainerClass": "IPF.Note",
- "mapistore_uri": "sqlite://%s/%s/%s.db" % (mapistoreURL, username, FID),
+ "PidTagContainerClass": "IPF.Note",
+ "mapistore_uri": "%s/%s/%s%s" % (mapistoreURL, username, FID, mapistoreSuffix),
"FolderType": str(1),
"SystemIdx": str(SystemIdx)})
@@ -249,7 +252,7 @@
def add_mailbox_special_folder(self, username, parentfolder, ref_fid,
foldername, containerclass, GlobalCount, ReplicaID,
- mapistoreURL):
+ mapistoreURL, mapistoreSuffix):
"""Add a special folder to the user mailbox
:param username: Username object
@@ -260,6 +263,7 @@
:param GlobalCount: current global counter for message database
:param ReplicaID: replica identifier for message database
:param mapistoreURL: mapistore default content repository URI
+ :param mapistoreSuffix: file type suffix to use with mapistore
"""
FID = gen_mailbox_folder_fid(GlobalCount, ReplicaID)
@@ -277,7 +281,7 @@
"PidTagFolderId": FID,
"PidTagDisplayName": foldername,
"PidTagContainerClass": containerclass,
- "mapistore_uri": "sqlite://%s/%s/%s.db" % (mapistoreURL, username, FID),
+ "mapistore_uri": "%s/%s/%s%s" % (mapistoreURL, username, FID, mapistoreSuffix),
"PidTagContentCount": str(0),
"PidTagAttrHidden": str(0),
"PidTagContentUnreadCount": str(0),
Index: setup/openchange_newuser
===================================================================
--- setup/openchange_newuser (revision 1816)
+++ setup/openchange_newuser (working copy)
@@ -48,7 +48,8 @@
help="Create the OpenChange user account")
parser.add_option("--mailbox", action="store_true", metavar="MAILBOX",
help="Create the OpenChange user mailbox")
-
+parser.add_option("--mapistore", type="string", metavar="STORE",
+ help="The backend storage type to use (only for --mailbox)")
opts, args = parser.parse_args()
if len(args) == 0:
@@ -70,5 +71,9 @@
if opts.create == True:
openchange.newuser(lp, creds, username=args[0])
+backend = "fsocpf" #default
+if opts.mapistore is not None:
+ backend = opts.mapistore
+
if opts.mailbox == True:
- openchange.newmailbox(lp, username=args[0], firstorg=None, firstou=None)
+ openchange.newmailbox(lp, username=args[0], firstorg=None, firstou=None, backend=backend)
_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel