Exemple #1
0
 def testFullLogs(self):
     logger = cwmplog.Logger(full_logs=2)
     self.assertEqual(logger.LogSoapXML(GetParameterValuesResponseLongXML),
                      GetParameterValuesResponseLongXML)
     self.assertEqual(logger.LogSoapXML(GetParameterValuesResponseLongXML),
                      GetParameterValuesResponseLongXML)
     self.assertEqual(logger.LogSoapXML(GetParameterValuesResponseLongXML),
                      GetParameterValuesResponseLongLog)
Exemple #2
0
  def __init__(self, ip, cpe, listenport, acs_config,
               ping_path, acs_url=None, fetch_args=None,
               ioloop=None, restrict_acs_hosts=None):
    tornado.httpclient.AsyncHTTPClient.configure(
        'tornado.curl_httpclient.CurlAsyncHTTPClient')
    # pylint:disable=protected-access
    oldcreate = tornado.curl_httpclient._curl_create
    tornado.curl_httpclient._curl_create = (
        lambda *args, **kwargs: CurlCreator(oldcreate, *args, **kwargs))
    # pylint:enable=protected-access
    self.cpe = cpe
    self.cpe_soap = api_soap.CPE(self.cpe)
    self.encode = api_soap.Encode()
    self.cwmplogger = cwmplog.Logger(full_logs=10)
    self.outstanding = None
    self.response_queue = []
    self.request_queue = []
    self.event_queue = LimitDeque(MAX_EVENT_QUEUE_SIZE, self.EventQueueHandler)
    self.ioloop = ioloop or tornado.ioloop.IOLoop.instance()
    self.retry_count = 0  # for Inform.RetryCount
    self.start_session_timeout = None  # timer for CWMPRetryInterval
    self.session = None
    self.my_configured_ip = ip
    self.fetch_args = fetch_args or dict()
    self.ping_rate_limit_seconds = 2
    self.previous_ping_time = 0
    self.ping_timeout_pending = None
    self._changed_parameters = set()
    self._changed_parameters_sent = set()
    self._acs_config = acs_config
    self.cpe_management_server = cpe_management_server.CpeManagementServer(
        acs_url=acs_url, acs_config=acs_config, port=listenport,
        ping_path=ping_path, get_parameter_key=cpe.getParameterKey,
        start_periodic_session=self.NewPeriodicSession, ioloop=self.ioloop,
        restrict_acs_hosts=restrict_acs_hosts)
    self.last_success_response = 0  # used by DiagUI
    self.num_599_responses = 0
    self._acs_disabled_until = None

    try:
      notifier = filenotifier.FileNotifier(mainloop.MainLoop())
      self.watch_acs_disabled = notifier.WatchObj(self._AcsDisabledFilename(),
                                                  self._UpdateAcsDisabled)
      self._UpdateAcsDisabled()
    except pyinotify.WatchManagerError:
      print 'cwmp temp dir (%s) does not exist' % CWMP_TMPDIR
Exemple #3
0
 def testEmpty(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML('')
     self.assertEqual(log, '')
Exemple #4
0
 def testBadXML(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML('this is <not> XML')
     self.assertEqual(log, 'this is <not> XML')
Exemple #5
0
 def testGetParameterValuesResponse(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML(GetParameterValuesResponseXML)
     self.assertEqual(log, GetParameterValuesResponseLog)
Exemple #6
0
 def testCwmpFault(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML(CwmpFaultXML)
     self.assertEqual(log, CwmpFaultLog)
Exemple #7
0
 def testAddObjectResponse(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML(AddObjectResponseXML)
     self.assertEqual(log, AddObjectResponseLog)
Exemple #8
0
 def testGetParameterNames(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML(GetParameterNamesXML)
     self.assertEqual(log, GetParameterNamesLog)
Exemple #9
0
 def testSetParameterValuesResponseSuccess(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML(SetParameterValuesResponseSuccessXML)
     self.assertEqual(log, SetParameterValuesResponseSuccessLog)
Exemple #10
0
 def testInformResponse(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML(InformResponseXML)
     self.assertEqual(log, InformResponseLog)
Exemple #11
0
 def testTruncate(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML(GPVResponseManyLinesXML)
     self.assertLessThan(len(log.splitlines()), 10)
Exemple #12
0
 def testKeyPassphrase(self):
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML(KeyPassphraseXML)
     self.assertFalse('password' in log)
     self.assertTrue('ThisIsTheOtherValue' in log)
Exemple #13
0
 def testDontShorten(self):
     os.environ['DONT_SHORTEN'] = '1'
     logger = cwmplog.Logger(full_logs=0)
     log = logger.LogSoapXML(GetParameterValuesResponseLongXML)
     self.assertEqual(log, GetParameterValuesResponseLongXML)