[CalendarServer-changes] [14700] CalendarServer/branches/release/CalendarServer-6.1-dev/ calendarserver
source_changes at macosforge.org
source_changes at macosforge.org
Thu Apr 23 11:55:38 PDT 2015
Revision: 14700
http://trac.calendarserver.org//changeset/14700
Author: sagen at apple.com
Date: 2015-04-23 11:55:38 -0700 (Thu, 23 Apr 2015)
Log Message:
-----------
Backport phantom volume detection
Modified Paths:
--------------
CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tap/util.py
CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tools/diagnose.py
Modified: CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tap/util.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tap/util.py 2015-04-23 17:51:44 UTC (rev 14699)
+++ CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tap/util.py 2015-04-23 18:55:38 UTC (rev 14700)
@@ -32,6 +32,7 @@
from calendarserver.provision.root import RootResource
from calendarserver.push.applepush import APNSubscriptionResource
from calendarserver.push.notifier import NotifierFactory
+from calendarserver.tools import diagnose
from calendarserver.tools.util import checkDirectory
from calendarserver.webadmin.landing import WebAdminLandingResource
from calendarserver.webcal.resource import WebCalendarResource
@@ -1223,6 +1224,9 @@
success, reason = verifyConfig(config)
if success:
+ success, reason = verifyServerRoot(config)
+
+ if success:
success, reason = verifyTLSCertificate(config)
if success:
@@ -1244,6 +1248,7 @@
return False
else:
+ print(reason)
sys.exit(1)
return True
@@ -1261,7 +1266,20 @@
return False, "Neither CalDAV nor CardDAV are enabled"
+def verifyServerRoot(config):
+ """
+ Ensure server root is not on a phantom volume
+ """
+ result = diagnose.detectPhantomVolume(config.ServerRoot)
+ if result == diagnose.EXIT_CODE_SERVER_ROOT_MISSING:
+ return False, "ServerRoot is missing"
+
+ if result == diagnose.EXIT_CODE_PHANTOM_DATA_VOLUME:
+ return False, "ServerRoot is supposed to be on a non-boot-volume but it's not"
+
+ return True, "ServerRoot is ok"
+
def verifyTLSCertificate(config):
"""
If a TLS certificate is configured, make sure it exists, is non empty,
Modified: CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tools/diagnose.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tools/diagnose.py 2015-04-23 17:51:44 UTC (rev 14699)
+++ CalendarServer/branches/release/CalendarServer-6.1-dev/calendarserver/tools/diagnose.py 2015-04-23 18:55:38 UTC (rev 14700)
@@ -71,6 +71,7 @@
optargs, _ignore_args = getopt(
sys.argv[1:], "h", [
"help",
+ "phantom",
],
)
except GetoptError, e:
@@ -84,7 +85,11 @@
if opt in ("-h", "--help"):
usage()
+ elif opt == "--phantom":
+ result = detectPhantomVolume()
+ sys.exit(result)
+
osBuild = getOSBuild()
print("OS Build: {}".format(osBuild))
@@ -105,6 +110,14 @@
serverRoot = getServerRoot()
print("Prefs plist says ServerRoot directory is: {}".format(serverRoot.encode("utf-8")))
+ result = detectPhantomVolume(serverRoot)
+ if result == EXIT_CODE_OK:
+ print("ServerRoot volume ok")
+ elif result == EXIT_CODE_SERVER_ROOT_MISSING:
+ print("ServerRoot directory missing")
+ elif result == EXIT_CODE_PHANTOM_DATA_VOLUME:
+ print("Phantom ServerRoot volume detected")
+
systemPlist = os.path.join(serverRoot, "Config", "caldavd-system.plist")
try:
if checkPlist(systemPlist):
@@ -156,7 +169,32 @@
showWebApps()
+EXIT_CODE_OK = 0
+EXIT_CODE_SERVER_ROOT_MISSING = 1
+EXIT_CODE_PHANTOM_DATA_VOLUME = 2
+def detectPhantomVolume(serverRoot=None):
+ """
+ Check to see if serverRoot directory exists in a "phantom" volume, meaning
+ it's simply a directory under /Volumes residing on the boot volume, rather
+ that a real separate volume.
+ """
+
+ if not serverRoot:
+ serverRoot = getServerRoot()
+
+ if not os.path.exists(serverRoot):
+ return EXIT_CODE_SERVER_ROOT_MISSING
+
+ if serverRoot.startswith("/Volumes/"):
+ bootDevice = os.stat("/").st_dev
+ dataDevice = os.stat(serverRoot).st_dev
+ if bootDevice == dataDevice:
+ return EXIT_CODE_PHANTOM_DATA_VOLUME
+
+ return EXIT_CODE_OK
+
+
def showProcesses():
print()
@@ -303,7 +341,10 @@
"--command={}".format(query),
)
lines = stdout.split("\n")
- count = int(lines[2])
+ try:
+ count = int(lines[2])
+ except IndexError:
+ count = 0
return count
@@ -358,6 +399,7 @@
runSQLQuery("select * from job;")
+
def showConfigKeys():
print()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150423/8fbd50f0/attachment-0001.html>
More information about the calendarserver-changes
mailing list