class ShowExports(): def __init__(self, parent=None): self.exportmgr = ExportMgr(SERVICE, '/org/ganesha/nfsd/ExportMgr', 'org.ganesha.nfsd.exportmgr') def showexports(self): print "Show exports" status, msg, reply = self.exportmgr.ShowExports() if status == True: ts = reply[0] exports = reply[1] self.proc_exports(ts, exports) else: self.status_message(status, msg) def addexport(self, conf_path, exp_expr): print "Add Export in %s" % conf_path status, msg = self.exportmgr.AddExport(conf_path, exp_expr) self.status_message(status, msg) def removeexport(self, exp_id): print "Remove Export with id %d" % int(exp_id) self.exportmgr.RemoveExport(exp_id) def displayexport(self, exp_id): print "Display export with id %d" % int(exp_id) status, msg, reply = self.exportmgr.DisplayExport(exp_id) if status == True: id = reply[0] path = reply[1] pseudo = reply[2] tag = reply[3] self.proc_export(id, path, pseudo, tag) else: self.status_message(status, msg) def proc_export(self, id, path, pseudo, tag): print "export %d: path = %s, pseudo = %s, tag = %s" % (id, path, pseudo, tag) def proc_exports(self, ts, exports): print "Timestamp: ", time.ctime(ts[0]), ts[1], " nsecs" if len(exports) == 0: print "No exports" else: print "Exports:" print " Id, path, nfsv3, mnt, nlm4, rquota,nfsv40, nfsv41, nfsv42, 9p, last" for export in exports: print( " %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d nsecs" % (export.ExportID, export.ExportPath, export.HasNFSv3, export.HasMNT, export.HasNLM4, export.HasRQUOTA, export.HasNFSv40, export.HasNFSv41, export.HasNFSv42, export.Has9P, time.ctime( export.LastTime[0]), export.LastTime[1])) def status_message(self, status, errormsg): print "Returns: status = %s, %s" % (str(status), errormsg)
class ShowExports(): def __init__(self, parent=None): self.exportmgr = ExportMgr(SERVICE, '/org/ganesha/nfsd/ExportMgr', 'org.ganesha.nfsd.exportmgr') def showexports(self): print("Show exports") status, msg, reply = self.exportmgr.ShowExports() if status == True: _ts = reply[0] exports = reply[1] self.proc_exports(_ts, exports) else: self.status_message(status, msg) def addexport(self, conf_path, exp_expr): print("Add Export in %s" % conf_path) status, msg = self.exportmgr.AddExport(conf_path, exp_expr) self.status_message(status, msg) def removeexport(self, exp_id): print("Remove Export with id %d" % int(exp_id)) self.exportmgr.RemoveExport(exp_id) def updateexport(self, conf_path, exp_expr): print("Update Export in %s" % conf_path) status, msg = self.exportmgr.UpdateExport(conf_path, exp_expr) self.status_message(status, msg) def displayexport(self, exp_id): print("Display export with id %d" % int(exp_id)) status, msg, reply = self.exportmgr.DisplayExport(exp_id) if status == True: _id = reply[0] path = reply[1] pseudo = reply[2] tag = reply[3] clients = reply[4] self.proc_export(_id, path, pseudo, tag, clients) else: self.status_message(status, msg) def proc_export(self, _id, path, pseudo, tag, clients): print("export %d: path = %s, pseudo = %s, tag = %s" %\ (_id, path, pseudo, tag)) print(" Client type, CIDR version, CIDR address, CIDR mask, " +\ "CIDR proto, Anonymous UID, Anonymous GID, " +\ "Attribute timeout, Options, Set") for client in clients: print(" %s, %d, %d, %d, %d, %d, %d, %d, %d, %d" % (client.Client_type, client.CIDR_version, client.CIDR_address, client.CIDR_mask, client.CIDR_proto, client.Anonymous_uid, client.Anonymous_gid, client.Expire_time_attr, client.Options, client.Set)) def proc_exports(self, _ts, exports): print("Timestamp: ", time.ctime(_ts[0]), _ts[1], " nsecs") if len(exports) == 0: print("No exports") else: print("Exports:") print( " Id, path, nfsv3, mnt, nlm4, rquota,nfsv40, nfsv41, nfsv42, 9p, last" ) for export in exports: print( " %d, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %d nsecs" % (export.ExportID, export.ExportPath, export.HasNFSv3, export.HasMNT, export.HasNLM4, export.HasRQUOTA, export.HasNFSv40, export.HasNFSv41, export.HasNFSv42, export.Has9P, time.ctime( export.LastTime[0]), export.LastTime[1])) def status_message(self, status, errormsg): print("Returns: status = %s, %s" % (str(status), errormsg))