예제 #1
0
    def update_all_sites_to_local_machine_sites(self, testcase=None):
        """ Update all sites to a local machine site (pointing to local IP address)
        NOTE: For use with Tantalus DVR simulation.
        INPUT
            testcase: a testcase object supplied when executing function as part of a testcase step.
        OUPUT
            successful: whether the function executed successfully or not.
            verified: whether the operation was verified or not.
        """

        self.log.debug("Updating all sites to local machine sites ...")
        result = {'successful': False, 'verified': False}

        try:
            # determine local machine ip
            local_machine_ip = return_machine_ip_address(self.log)['ip address']

            # update site in database
            handle = self.db.db_handle
            sql = "UPDATE %s SET %s = '%s'" % (DB_SITES_TABLE, DB_SITES_FIELDS['ip address'],
                                                local_machine_ip)

            self.db.execute_SQL(handle, sql)

            self.log.trace("Updated all sites %s to local machine sites.")
            result['successful'] = True
        except BaseException, e:
            self.handle_exception(e, operation="update all sites to local machine sites.")
예제 #2
0
    def configure_local_machine_site(self, testcase=None):
        """ Configure a site with the local machine's IP address.
        INPUT
            testcase: a testcase object supplied when executing function as part of a testcase step.
        OUPUT
            successful: whether the function executed successfully or not.
            verified: whether the operation was verified or not.
        """

        self.log.debug("Configuring local machine site ...")
        result = {'successful': False, 'verified': False}

        try:
            # determine local machine IP address
            ip_address = return_machine_ip_address(self.log)['ip address']

            # define custom site settings
            settings = [
                ['site name', 'Local Depot'],
                ['ip address', ip_address],
                ['dvr username', 'admin'],
            ]

            # configure site
            self.configure_remote_site(settings)

            if result['verified']:
                self.log.trace("Configured local machine site.")
            result['successful'] = True
        except BaseException, e:
            self.handle_exception(e, operation="")
예제 #3
0
    def __init__(self, logger, exception_handler, sisyphus):
        """
        @param logger: an initialized Logger() to inherit.
        @param exception_handler: an un-initialized ExceptionHandler() to inherit.
        @param sisyphus:
        """

        # instance logger (initialized instance)
        self.log = logger

        # instance exception handler
        self.handle_exception = exception_handler

        # instantialize sisyphus
        self.Sisyphus = sisyphus
        self.sisyphus = self.Sisyphus(self.log)

        # stacktrace
        self.inspect = inspect

        # load configuration
        self.load_config()

        # build client socket
        self.local_ip = return_machine_ip_address(self.log)['ip address']
        self.local_port = 333
        self.local_addr = (self.local_ip, self.local_port)
        self.packet_size = 16284
        self.client = socket.socket()
        self.client.bind(self.local_addr)