コード例 #1
0
ファイル: sth.py プロジェクト: gitter-badger/IoT-STH
 def get_timestamp_remote(self):
     """
     return date-time in timestamp from sth server
     :return float
     """
     myfab = FabricSupport(host=self.sth_host, user=self.fabric_user, password=self.fabric_password, cert_file=self.fabric_cert_file, retry=self.fabric_error_retry, hide=True, sudo=self.fabric_sudo)
     return float(myfab.run("date +%s"))  # get timestamp
コード例 #2
0
ファイル: sth.py プロジェクト: gitter-badger/IoT-STH
 def drop_all_test_databases(self):
     """
     drop all te
     sts databases with prefix
     """
     myfab = FabricSupport(host=self.sth_host, user=self.fabric_user, password=self.fabric_password, cert_file=self.fabric_cert_file, retry=self.fabric_error_retry, hide=True, sudo=self.fabric_sudo)
     myfab.run("sh drop_database_mongo.sh sth_test", path="%s/%s" % (self.fabric_target_path, u'resources'), sudo=False)
コード例 #3
0
ファイル: sth.py プロジェクト: gitter-badger/IoT-STH
 def sth_service(self, operation):
     """
     cygnus service (status | stop | start | restart)
     :param operation:
     """
     myfab = FabricSupport(host=self.sth_host, user=self.fabric_user, password=self.fabric_password, cert_file=self.fabric_cert_file, retry=self.fabric_error_retry, hide=True, sudo=self.fabric_sudo)
     if self.sth_host != "localhost" and self.sth_host != "127.0.0.1":
         myfab.run("sudo service sth %s" % operation, path=self.fabric_target_path, sudo=False)
コード例 #4
0
ファイル: sth.py プロジェクト: gitter-badger/IoT-STH
 def get_timestamp_remote(self):
     """
     return date-time in timestamp from sth server
     :return float
     """
     myfab = FabricSupport(host=self.sth_host,
                           user=self.fabric_user,
                           password=self.fabric_password,
                           cert_file=self.fabric_cert_file,
                           retry=self.fabric_error_retry,
                           hide=True,
                           sudo=self.fabric_sudo)
     return float(myfab.run("date +%s"))  # get timestamp
コード例 #5
0
ファイル: sth.py プロジェクト: ficoreulpgc/IoT-STH
 def sth_service(self, operation):
     """
     cygnus service (status | stop | start | restart)
     :param operation:
     """
     myfab = FabricSupport(
         host=self.sth_host,
         user=self.fabric_user,
         password=self.fabric_password,
         cert_file=self.fabric_cert_file,
         retry=self.fabric_error_retry,
         hide=False,
         sudo=self.fabric_sudo,
     )
     myfab.run("HOST=0.0.0.0 npm start", path=self.fabric_target_path, sudo=False)
コード例 #6
0
ファイル: sth.py プロジェクト: gitter-badger/IoT-STH
 def drop_all_test_databases(self):
     """
     drop all te
     sts databases with prefix
     """
     myfab = FabricSupport(host=self.sth_host,
                           user=self.fabric_user,
                           password=self.fabric_password,
                           cert_file=self.fabric_cert_file,
                           retry=self.fabric_error_retry,
                           hide=True,
                           sudo=self.fabric_sudo)
     myfab.run("sh drop_database_mongo.sh sth_test",
               path="%s/%s" % (self.fabric_target_path, u'resources'),
               sudo=False)
コード例 #7
0
ファイル: sth.py プロジェクト: gitter-badger/IoT-STH
 def sth_service(self, operation):
     """
     cygnus service (status | stop | start | restart)
     :param operation:
     """
     myfab = FabricSupport(host=self.sth_host,
                           user=self.fabric_user,
                           password=self.fabric_password,
                           cert_file=self.fabric_cert_file,
                           retry=self.fabric_error_retry,
                           hide=True,
                           sudo=self.fabric_sudo)
     if self.sth_host != "localhost" and self.sth_host != "127.0.0.1":
         myfab.run("sudo service sth %s" % operation,
                   path=self.fabric_target_path,
                   sudo=False)
コード例 #8
0
ファイル: sth.py プロジェクト: gitter-badger/IoT-STH
 def init_log_file(self):
     """
     reinitialize log file
     delete and create a new log file (empty)
     """
     myfab = FabricSupport(host=self.sth_host,
                           user=self.fabric_user,
                           password=self.fabric_password,
                           cert_file=self.fabric_cert_file,
                           retry=self.fabric_error_retry,
                           hide=False,
                           sudo=self.fabric_sudo)
     log = Remote_Log(file=self.log_file, fabric=myfab)
     log.delete_log_file()
     log.create_log_file(owner=self.log_owner,
                         group=self.log_group,
                         mod=self.log_mod)
コード例 #9
0
ファイル: sth.py プロジェクト: gitter-badger/IoT-STH
    def verify_log(self, label, text):
        """
        Verify in log file if a label with a text exists
        :param label: label to find
        :param text: text to find (begin since the end)
        """
        myfab = FabricSupport(host=self.sth_host,
                              user=self.fabric_user,
                              password=self.fabric_password,
                              cert_file=self.fabric_cert_file,
                              retry=self.fabric_error_retry,
                              hide=True,
                              sudo=self.fabric_sudo)
        log = Remote_Log(fabric=myfab, file=self.log_file)
        line = log.find_line(label, text)

        #verify if a line with a level and a text exists in the log
        assert line != None, "ERROR  - label: \"%s\" and text: \"%s\" is not found.    \n       - %s" % (
            label, text, line)
        # verify if the new line in log has been wrote after the notification was sent
        assert self.date_time < log.get_line_time_in_log(
            line), "ERROR - the lines has not  been logged"