示例#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.CallNtpdate(logger)
示例#2
0
    def testCallNtpdateError(self, mock_call, mock_check_call):
        command_status = ['service', 'ntpd', 'status']
        command_ntpdate = 'ntpdate `awk \'$1=="server" {print $2}\' /etc/ntp.conf`'
        mock_logger = mock.Mock()
        mock_check_call.side_effect = subprocess.CalledProcessError(1, 'Test')

        helpers.CallNtpdate(mock_logger)
        mock_call.assert_called_once_with(command_status)
        mock_check_call.assert_called_once_with(command_ntpdate, shell=True)
        expected_calls = [mock.call.warning(mock.ANY)]
        self.assertEqual(mock_logger.mock_calls, expected_calls)
示例#3
0
    def testCallNtpdateInactive(self, mock_call, mock_check_call):
        command_status = ['service', 'ntpd', 'status']
        command_ntpdate = 'ntpdate `awk \'$1=="server" {print $2}\' /etc/ntp.conf`'
        mock_logger = mock.Mock()
        mock_call.return_value = 1

        helpers.CallNtpdate(mock_logger)
        mock_call.assert_called_once_with(command_status)
        mock_check_call.assert_called_once_with(command_ntpdate, shell=True)
        expected_calls = [mock.call.info(mock.ANY)]
        self.assertEqual(mock_logger.mock_calls, expected_calls)