from afs.argparse import *
import afs.lib.partition as partition
+from afs.lib.time import *
import kafs
help = "Report a volume server's status"
print("--------------------------------------------")
for trans in results:
- print("transaction: {:d} created: {:s}".format(trans.tid, afs_time(trans.creationTime)))
- print("lastActiveTime:", afs_time(trans.time))
+ print("transaction: {:d} created: {:s}".format(trans.tid, time2str(trans.creationTime)))
+ print("lastActiveTime:", time2str(trans.time))
if iflag & kafs.ITOffline:
attach_mode = "offline"
elif iflag & kafs.ITBusy:
--- /dev/null
+#
+# AFS Volume management toolkit: Standard AFS date and time display format
+# -*- coding: utf-8 -*-
+#
+
+__copyright__ = """
+Copyright (C) 2014 Red Hat, Inc. All Rights Reserved.
+Written by David Howells (dhowells@redhat.com)
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public Licence version 2 as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public Licence for more details.
+
+You should have received a copy of the GNU General Public Licence
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""
+
+import datetime
+
+def time2str(time):
+ t = datetime.datetime.fromtimestamp(time)
+ return t.strftime("%a %b %d %H:%M:%S %Y")
+
+def time2str_or_never(time):
+ if time == 0:
+ return "Never"
+ t = datetime.datetime.fromtimestamp(time)
+ return t.strftime("%a %b %d %H:%M:%S %Y")
import afs.lib.addrcache as addrcache
import afs.lib.partition as partition
+from afs.lib.time import *
import kafs
-import datetime
statistics_time_ranges = [
"0-60 sec ",
return "BUSY"
return "UNATTACHABLE"
-def vol_date(d, never = False):
- if d == 0 and never:
- return "Never"
- t = datetime.datetime.fromtimestamp(d)
- return t.strftime("%a %b %d %H:%M:%S %Y")
-
def yes_or_no(n):
if (n):
return "Y"
vol.cloneID,
vol.backupID))
print(" ", "MaxQuota {:10d} K".format(vol.maxquota))
- print(" ", "Creation ", vol_date(vol.creationDate, True))
- print(" ", "Copy ", vol_date(vol.copyDate, True))
- print(" ", "Backup ", vol_date(vol.backupDate, True))
- print(" ", "Last Access", vol_date(vol.accessDate, True))
- print(" ", "Last Update", vol_date(vol.updateDate, True))
+ print(" ", "Creation ", time2str_or_never(vol.creationDate))
+ print(" ", "Copy ", time2str_or_never(vol.copyDate))
+ print(" ", "Backup ", time2str_or_never(vol.backupDate))
+ print(" ", "Last Access", time2str_or_never(vol.accessDate))
+ print(" ", "Last Update", time2str_or_never(vol.updateDate))
print(" ", vol.dayUse, "accesses in the past day (i.e., vnode references)")
print()
except AttributeError:
pass
print("type\t\t{:s}".format(vol_type(vol)))
- print("creationDate\t{:<10d}\t{:s}".format(vol.creationDate, vol_date(vol.creationDate)))
- print("accessDate\t{:<10d}\t{:s}".format(vol.accessDate, vol_date(vol.accessDate)))
- print("updateDate\t{:<10d}\t{:s}".format(vol.updateDate, vol_date(vol.updateDate)))
- print("backupData\t{:<10d}\t{:s}".format(vol.backupDate, vol_date(vol.backupDate)))
- print("copyDate\t{:<10d}\t{:s}".format(vol.copyDate, vol_date(vol.copyDate)))
+ print("creationDate\t{:<10d}\t{:s}".format(vol.creationDate, time2str(vol.creationDate)))
+ print("accessDate\t{:<10d}\t{:s}".format(vol.accessDate, time2str(vol.accessDate)))
+ print("updateDate\t{:<10d}\t{:s}".format(vol.updateDate, time2str(vol.updateDate)))
+ print("backupData\t{:<10d}\t{:s}".format(vol.backupDate, time2str(vol.backupDate)))
+ print("copyDate\t{:<10d}\t{:s}".format(vol.copyDate, time2str(vol.copyDate)))
try:
print("flags\t\t{:<7d}\t(Optional)".format(vol.flags))
except AttributeError: