def exportDatabase(self, password = None):
    """
    Export the hub database.
    """
    if password is not None:
       if type(password) not in [str, unicode]:
          raise Exception(URI_ERROR + "illegal-argument", "Expected type str/unicode for argument password, but got %s" % str(type(password)))
       try:
          password = str(password)
       except:
          raise Exception(URI_ERROR + "illegal-argument", "Password contains non-ASCII characters (%s)" % password)
       else:
          if password.strip() == "":
             password = None
          else:
             pat = re.compile(ServiceControl.DBEXPORT_PASSWORD_PATTERN)
             if not pat.match(password):
                raise Exception(URI_ERROR + "illegal-argument", "Password %s does not match pattern %s" % (password, AdminWebSocketProtocol.DBEXPORT_PASSWORD_PATTERN))
    d = defer.Deferred()
    cfg = self.proto.factory.services["config"]
    dbfile = self.proto.factory.services["database"].dbfile
    log.msg("Exporting service database from %s ..", dbfile)
    p = DbExportProtocol(d,
                         self.proto.factory.services,
                         str(dbfile),
                         str(cfg.get("database-version")),
                         str(cfg.get("export-dir")),
                         str(cfg.get("export-url")),
                         password = password)
    p.run()
    return d
 def createDiagnosticsFiles(self):
    """
    Create a diagnostics file which contains non-sensitive database information export
    and log files as ZIP file.
    """
    d = defer.Deferred()
    cfg = self.proto.factory.services["config"]
    dbfile = self.proto.factory.services["database"].dbfile
    p = DbExportProtocol(d,
                         self.proto.factory.services,
                         str(dbfile),
                         str(cfg.get("database-version")),
                         str(cfg.get("export-dir")),
                         str(cfg.get("export-url")),
                         mode = DbExportProtocol.MODE_DIAGNOSTICS,
                         logsdir = str(cfg.get("log-dir")))
    p.run()
    return d
Beispiel #3
0
 def createDiagnosticsFiles(self):
     """
   Create a diagnostics file which contains non-sensitive database information export
   and log files as ZIP file.
   """
     d = defer.Deferred()
     cfg = self.proto.factory.services["config"]
     dbfile = self.proto.factory.services["database"].dbfile
     p = DbExportProtocol(d,
                          self.proto.factory.services,
                          str(dbfile),
                          str(cfg.get("database-version")),
                          str(cfg.get("export-dir")),
                          str(cfg.get("export-url")),
                          mode=DbExportProtocol.MODE_DIAGNOSTICS,
                          logsdir=str(cfg.get("log-dir")))
     p.run()
     return d
Beispiel #4
0
 def exportDatabase(self, password=None):
     """
   Export the hub database.
   """
     if password is not None:
         if type(password) not in [str, unicode]:
             raise Exception(
                 URI_ERROR + "illegal-argument",
                 "Expected type str/unicode for argument password, but got %s"
                 % str(type(password)))
         try:
             password = str(password)
         except:
             raise Exception(
                 URI_ERROR + "illegal-argument",
                 "Password contains non-ASCII characters (%s)" % password)
         else:
             if password.strip() == "":
                 password = None
             else:
                 pat = re.compile(ServiceControl.DBEXPORT_PASSWORD_PATTERN)
                 if not pat.match(password):
                     raise Exception(
                         URI_ERROR + "illegal-argument",
                         "Password %s does not match pattern %s" %
                         (password,
                          AdminWebSocketProtocol.DBEXPORT_PASSWORD_PATTERN))
     d = defer.Deferred()
     cfg = self.proto.factory.services["config"]
     dbfile = self.proto.factory.services["database"].dbfile
     log.msg("Exporting service database from %s ..", dbfile)
     p = DbExportProtocol(d,
                          self.proto.factory.services,
                          str(dbfile),
                          str(cfg.get("database-version")),
                          str(cfg.get("export-dir")),
                          str(cfg.get("export-url")),
                          password=password)
     p.run()
     return d