[CalendarServer-changes] [9955] CalendarServer/branches/release/CalendarServer-4.2-dev/contrib/ migration

source_changes at macosforge.org source_changes at macosforge.org
Fri Oct 19 13:51:41 PDT 2012


Revision: 9955
          http://trac.calendarserver.org//changeset/9955
Author:   sagen at apple.com
Date:     2012-10-19 13:51:41 -0700 (Fri, 19 Oct 2012)
Log Message:
-----------
Promotion extra now fixes DSN to use server-specific postgres

Modified Paths:
--------------
    CalendarServer/branches/release/CalendarServer-4.2-dev/contrib/migration/calendarpromotion.py

Added Paths:
-----------
    CalendarServer/branches/release/CalendarServer-4.2-dev/contrib/migration/test/test_promotion.py

Modified: CalendarServer/branches/release/CalendarServer-4.2-dev/contrib/migration/calendarpromotion.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-4.2-dev/contrib/migration/calendarpromotion.py	2012-10-18 16:26:35 UTC (rev 9954)
+++ CalendarServer/branches/release/CalendarServer-4.2-dev/contrib/migration/calendarpromotion.py	2012-10-19 20:51:41 UTC (rev 9955)
@@ -24,6 +24,23 @@
 GROUP_NAME = "calendar"
 LOG_DIR = "/var/log/caldavd"
 
+
+def updatePlist(plistData):
+    """
+    Update the passed-in plist data with new values for disabling the XMPPNotifier, and
+    to set the DSN to use the server-specific Postgres.
+
+    @param plistData: the plist data to update in place
+    @type plistData: C{dict}
+    """
+    try:
+        if plistData["Notifications"]["Services"]["XMPPNotifier"]["Enabled"]:
+            plistData["Notifications"]["Services"]["XMPPNotifier"]["Enabled"] = False
+    except KeyError:
+        pass
+    plistData["DSN"] = "/Library/Server/PostgreSQL For Server Services/Socket:caldav:caldav:::"
+
+
 def main():
 
     try:
@@ -45,17 +62,11 @@
     if os.path.exists(plistPath):
         try:
             plistData = readPlist(plistPath)
+            updatePlist(plistData)
+            writePlist(plistData, plistPath)
 
-            # Disable XMPPNotifier now that we're directly talking to APNS
-            try:
-                if plistData["Notifications"]["Services"]["XMPPNotifier"]["Enabled"]:
-                    plistData["Notifications"]["Services"]["XMPPNotifier"]["Enabled"] = False
-                writePlist(plistData, plistPath)
-            except KeyError:
-                pass
-
         except Exception, e:
-            print "Unable to disable XMPP in %s: %s" % (plistPath, e)
+            print "Unable to disable update values in %s: %s" % (plistPath, e)
 
     else:
         # Copy configuration

Added: CalendarServer/branches/release/CalendarServer-4.2-dev/contrib/migration/test/test_promotion.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-4.2-dev/contrib/migration/test/test_promotion.py	                        (rev 0)
+++ CalendarServer/branches/release/CalendarServer-4.2-dev/contrib/migration/test/test_promotion.py	2012-10-19 20:51:41 UTC (rev 9955)
@@ -0,0 +1,60 @@
+##
+# Copyright (c) 2012 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+import twistedcaldav.test.util
+from contrib.migration.calendarpromotion import updatePlist
+
+class PromotionTests(twistedcaldav.test.util.TestCase):
+    """
+    Calendar Server Promotion Tests
+    """
+
+    def test_updatePlist(self):
+        """
+        Verify XMPPNotifier is disabled and DSN is updated
+        """
+
+        orig = {
+            "ignored" : "ignored",
+        }
+        expected = {
+            "ignored" : "ignored",
+            "DSN" : "/Library/Server/PostgreSQL For Server Services/Socket:caldav:caldav:::",
+        }
+        updatePlist(orig)
+        self.assertEquals(orig, expected)
+
+        orig = {
+            "Notifications" : {
+                "Services" : {
+                    "XMPPNotifier" : {
+                        "Enabled" : True
+                    }
+                }
+            }
+        }
+        expected = {
+            "Notifications" : {
+                "Services" : {
+                    "XMPPNotifier" : {
+                        "Enabled" : False
+                    }
+                }
+            },
+            "DSN" : "/Library/Server/PostgreSQL For Server Services/Socket:caldav:caldav:::",
+        }
+        updatePlist(orig)
+        self.assertEquals(orig, expected)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121019/5072c36a/attachment.html>


More information about the calendarserver-changes mailing list