Example #1
0
    def HandleClockSync(self, logger):
        """Sync the software clock with the hypervisor clock.

    Args:
      logger: logger object, used to write to SysLog and serial port.
    """
        helpers.CallHwclock(logger)
Example #2
0
    def testCallHwclock(self, mock_call):
        command = ['/sbin/hwclock', '--hctosys']
        mock_logger = mock.Mock()

        helpers.CallHwclock(mock_logger)
        mock_call.assert_called_once_with(command)
        expected_calls = [mock.call.info(mock.ANY)]
        self.assertEqual(mock_logger.mock_calls, expected_calls)
Example #3
0
    def testCallHwclockError(self, mock_call):
        command = ['/sbin/hwclock', '--hctosys']
        mock_logger = mock.Mock()
        mock_call.side_effect = subprocess.CalledProcessError(1, 'Test')

        helpers.CallHwclock(mock_logger)
        mock_call.assert_called_once_with(command)
        expected_calls = [mock.call.warning(mock.ANY)]
        self.assertEqual(mock_logger.mock_calls, expected_calls)