Advertisement
Guest User

version

a guest
Mar 24th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.43 KB | None | 0 0
  1. root@Node1:/opt/noc# ./noc script --debug --pretty get_version "apcFA0D7A"
  2. 2018-03-24 05:26:45,613 [noc.core.dcs.base] Resolve near service postgres
  3. 2018-03-24 05:26:45,613 [noc.core.http.client] HTTP GET http://consul:8500/v1/health/service/postgres?passing=1&near=_agent
  4. 2018-03-24 05:26:45,616 [noc.core.http.client] HTTP Response 200
  5. 2018-03-24 05:26:45,616 [noc.core.dcs.base] Resolved near service postgres to ['10.220.21.122:5432']
  6. 2018-03-24 05:26:46,482 [noc.core.dcs.base] Running resolver for service mongo
  7. 2018-03-24 05:26:46,482 [noc.core.dcs.base] [mongo] Starting resolver
  8. 2018-03-24 05:26:46,483 [noc.core.http.client] HTTP GET http://consul:8500/v1/health/service/mongo?passing=1
  9. 2018-03-24 05:26:46,484 [noc.core.http.client] HTTP Response 200
  10. 2018-03-24 05:26:46,484 [noc.core.dcs.base] [mongo] Set active services to: mongo: 10.220.21.122:27017
  11. 2018-03-24 05:26:46,484 [noc.core.http.client] HTTP GET http://consul:8500/v1/health/service/mongo?index=460194&passing=1
  12. 2018-03-24 05:26:46,485 [noc.lib.nosql] Connecting to MongoDB {'username': 'noc', 'authentication_source': 'noc', 'readPreference': 'secondaryPreferred', 'replicaSet': 'noc', 'db': 'noc', 'socketKeepAlive': True, 'host': 'mongodb://noc:********@10.220.21.122:27017/noc', 'password': '********'}
  13. 2018-03-24 05:26:46,547 [noc.core.cache.base] Using cache backend: noc.core.cache.mongo.MongoCache
  14. 2018-03-24 05:26:46,611 [noc.main.models.doccategory] Registering Capability
  15. 2018-03-24 05:26:46,612 [noc.main.models.doccategory] Registering MetricType
  16. 2018-03-24 05:26:46,648 [noc.main.models.doccategory] Registering ConnectionType
  17. 2018-03-24 05:26:46,652 [noc.main.models.doccategory] Registering ObjectModel
  18. 2018-03-24 05:26:46,661 [noc.main.models.textindex] Adding FTS index for sa.managedobject
  19. 2018-03-24 05:26:46,676 [noc.main.models.textindex] Adding FTS index for ip.vrf
  20. 2018-03-24 05:26:46,679 [noc.main.models.textindex] Adding FTS index for vc.vc
  21. 2018-03-24 05:26:46,682 [noc.main.models.textindex] Adding FTS index for ip.prefix
  22. 2018-03-24 05:26:46,687 [noc.main.models.textindex] Adding FTS index for ip.address
  23. 2018-03-24 05:26:46,734 [noc.core.script.loader] Loading script APC.AOS.get_version
  24. 2018-03-24 05:26:46,743 [noc.core.profile.loader] Loading profile APC.AOS
  25. 2018-03-24 05:26:46,743 [script] [APC.AOS.get_version|10.20.50.50] Running. Input arguments: {}, timeout 3600
  26. 2018-03-24 05:26:46,744 [script] [APC.AOS.get_version|10.20.50.50] [snmp] Creating IOLoop
  27. 2018-03-24 05:26:46,744 [script] [APC.AOS.get_version|10.20.50.50] [snmp] Create UDP socket
  28. 2018-03-24 05:26:46,744 [noc.core.ioloop.snmp] [10.20.50.50] SNMP GET ['1.3.6.1.2.1.33.1.1.2.0']
  29. 2018-03-24 05:26:46,790 [noc.core.ioloop.snmp] [10.20.50.50] GET result: 'Smart-UPS 2200'
  30. 2018-03-24 05:26:46,790 [noc.core.ioloop.snmp] [10.20.50.50] SNMP GET ['.1.3.6.1.2.1.33.1.1.3.0']
  31. 2018-03-24 05:26:46,792 [script] [APC.AOS.get_version|10.20.50.50] [snmp] Closing UDP socket
  32. 2018-03-24 05:26:46,792 [script] [APC.AOS.get_version|10.20.50.50] [snmp] Closing IOLoop
  33. 2018-03-24 05:26:46,957 [noc.core.debug] UNHANDLED EXCEPTION (2018-03-24 05:26:46.802693)
  34. PROCESS: ./commands/script.py
  35. VERSION: 15.05.1+microservices.9200.0aefb171
  36. BRANCH: microservices CHANGESET: 0aefb171
  37. ERROR FINGERPRINT: 79739c44-b304-528f-9c32-026df85335e9
  38. WORKING DIRECTORY: /opt/noc
  39. EXCEPTION: <type 'exceptions.ValueError'> invalid literal for int() with base 10: ''
  40. START OF TRACEBACK
  41. ------------------------------------------------------------------------
  42. File: core/snmp/ber.py (Line: 421)
  43. Function: encode_oid
  44. 414 """
  45. 415 >>> BEREncoder().encode_oid("1.3.6.1.2.1.1.5.0")
  46. 416 '\\x06\\x08+\\x06\\x01\\x02\\x01\\x01\\x05\\x00'
  47. 417
  48. 418 :param data:
  49. 419 :return:
  50. 420 """
  51. 421 ==> d = [int(x) for x in data.split(".")]
  52. 422 r = [chr(d[0] * 40 + d[1])]
  53. 423 for v in d[2:]:
  54. 424 if v < 0x7f:
  55. 425 r += [chr(v)]
  56. 426 else:
  57. 427 rr = []
  58. Variables:
  59. x = ''
  60. self = <noc.core.snmp.ber.BEREncoder object at 0x7f62b502f790>
  61. data = '.1.3.6.1.2.1.33.1.1.3.0'
  62. ------------------------------------------------------------------------
  63. File: core/snmp/get.py (Line: 38)
  64. Function: _build_pdu
  65. 31 if not request_id:
  66. 32 request_id = random.randint(0, 0x7FFFFFFF)
  67. 33 # Encode variable bindings
  68. 34 varbinds = e.encode_sequence([
  69. 35 e.encode_sequence([
  70. 36 e.encode_oid(str(oid)),
  71. 37 e.encode_null()
  72. 38 ==> ]) for oid in oids
  73. 39 ])
  74. 40 # Encode RFC-1905 SNMP GET PDU
  75. 41 pdu = e.encode_choice(pdu_type, [
  76. 42 e.encode_int(request_id),
  77. 43 e.encode_int(0), # Error status
  78. 44 e.encode_int(0), # Error index
  79. Variables:
  80. pdu_type = 0
  81. oid = '.1.3.6.1.2.1.33.1.1.3.0'
  82. community = 'kondaro'
  83. oids = ['.1.3.6.1.2.1.33.1.1.3.0']
  84. version = 1
  85. request_id = 1045452829
  86. e = <noc.core.snmp.ber.BEREncoder object at 0x7f62b502f790>
  87. ------------------------------------------------------------------------
  88. File: core/snmp/get.py (Line: 63)
  89. Function: get_pdu
  90. 56 """
  91. 57 Generate SNMP v2c GET PDU
  92. 58 :param version:
  93. 59 :param community:
  94. 60 :param oids:
  95. 61 :return:
  96. 62 """
  97. 63 ==> return _build_pdu(community, PDU_GET_REQUEST, oids, request_id, version)
  98. 64
  99. 65
  100. 66 def getnext_pdu(community, oid, request_id=None, version=SNMP_v2c):
  101. 67 """
  102. 68 Generate SNMP v2c GETNEXT PDU
  103. 69 :param version:
  104. Variables:
  105. oids = ['.1.3.6.1.2.1.33.1.1.3.0']
  106. version = 1
  107. community = 'kondaro'
  108. request_id = None
  109. ------------------------------------------------------------------------
  110. File: core/ioloop/snmp.py (Line: 52)
  111. Function: snmp_get
  112. 45 elif isinstance(oids, dict):
  113. 46 oid_map = dict((oids[k], k) for k in oids)
  114. 47 oids = oids.values()
  115. 48 else:
  116. 49 raise ValueError("oids must be either string or dict")
  117. 50 logger.debug("[%s] SNMP GET %s", address, oids)
  118. 51 # Send GET PDU
  119. 52 ==> pdu = get_pdu(community=community, oids=oids, version=version)
  120. 53 if udp_socket:
  121. 54 sock = udp_socket
  122. 55 prev_timeout = sock.get_timeout()
  123. 56 else:
  124. 57 sock = UDPSocket(ioloop=ioloop, tos=tos)
  125. 58 sock.settimeout(timeout)
  126. Variables:
  127. ioloop = <tornado.platform.epoll.EPollIOLoop object at 0x7f62b502f5d0>
  128. tos = 0
  129. oid_map = {}
  130. community = 'kondaro'
  131. port = 161
  132. version = 1
  133. timeout = 10
  134. address = u'10.20.50.50'
  135. oids = ['.1.3.6.1.2.1.33.1.1.3.0']
  136. udp_socket = <noc.core.ioloop.udp.UDPSocket object at 0x7f62b502f6d0>
  137. ------------------------------------------------------------------------
  138. File: local/lib/python2.7/site-packages/tornado/gen.py (Line: 307)
  139. Function: wrapper
  140. 300 # Inline the first iteration of Runner.run. This lets us
  141. 301 # avoid the cost of creating a Runner when the coroutine
  142. 302 # never actually yields, which in turn allows us to
  143. 303 # use "optional" coroutines in critical path code without
  144. 304 # performance penalty for the synchronous case.
  145. 305 try:
  146. 306 orig_stack_contexts = stack_context._state.contexts
  147. 307 ==> yielded = next(result)
  148. 308 if stack_context._state.contexts is not orig_stack_contexts:
  149. 309 yielded = TracebackFuture()
  150. 310 yielded.set_exception(
  151. 311 stack_context.StackContextInconsistentError(
  152. 312 'stack_context inconsistency (probably caused '
  153. 313 'by yield within a "with StackContext" block)'))
  154. Variables:
  155. func = <function snmp_get at 0x7f62c09fe8c0>
  156. args = ()
  157. yielded = None
  158. replace_callback = True
  159. future = None
  160. result = <generator object snmp_get at 0x7f62b50289b0>
  161. orig_stack_contexts = ((), None)
  162. kwargs =
  163. {'address': u'10.20.50.50',
  164. 'community': 'kondaro',
  165. 'ioloop': <tornado.platform.epoll.EPollIOLoop object at 0x7f62b502f5d0>,
  166. 'oids': '.1.3.6.1.2.1.33.1.1.3.0',
  167. 'tos': 0,
  168. 'udp_socket': <noc.core.ioloop.udp.UDPSocket object at 0x7f62b502f6d0>,
  169. 'version': 1}
  170. ------------------------------------------------------------------------
  171. File: local/lib/python2.7/site-packages/tornado/concurrent.py (Line: 238)
  172. Function: result
  173. 231 before the `Future` is done, so the ``timeout`` is never used.
  174. 232 """
  175. 233 self._clear_tb_log()
  176. 234 if self._result is not None:
  177. 235 return self._result
  178. 236 if self._exc_info is not None:
  179. 237 try:
  180. 238 ==> raise_exc_info(self._exc_info)
  181. 239 finally:
  182. 240 self = None
  183. 241 self._check_done()
  184. 242 return self._result
  185. 243
  186. 244 def exception(self, timeout=None):
  187. Variables:
  188. self = None
  189. timeout = None
  190. ------------------------------------------------------------------------
  191. File: local/lib/python2.7/site-packages/tornado/gen.py (Line: 1055)
  192. Function: run
  193. 1048 return
  194. 1049 self.future = None
  195. 1050 try:
  196. 1051 orig_stack_contexts = stack_context._state.contexts
  197. 1052 exc_info = None
  198. 1053
  199. 1054 try:
  200. 1055 ==> value = future.result()
  201. 1056 except Exception:
  202. 1057 self.had_exception = True
  203. 1058 exc_info = sys.exc_info()
  204. 1059 future = None
  205. 1060
  206. 1061 if exc_info is not None:
  207. Variables:
  208. exc_info = None
  209. self = <tornado.gen.Runner object at 0x7f62b49c40d0>
  210. future = None
  211. orig_stack_contexts = ((), None)
  212. ------------------------------------------------------------------------
  213. File: core/script/snmp/base.py (Line: 105)
  214. Function: run
  215. 98 self.result = yield snmp_get(
  216. 99 address=self.script.credentials["address"],
  217. 100 oids=oids,
  218. 101 community=str(self.script.credentials["snmp_ro"]),
  219. 102 tos=self.script.tos,
  220. 103 ioloop=self.get_ioloop(),
  221. 104 udp_socket=self.get_socket(),
  222. 105 ==> version=version
  223. 106 )
  224. 107 self.timeouts = self.timeouts_limit
  225. 108 if self.beef:
  226. 109 # Restore from beef
  227. 110 self.beef.set_snmp_get(oids, self.result)
  228. 111 except SNMPError as e:
  229. Variables:
  230. self = <noc.core.script.snmp.base.SNMP object at 0x7f62b502f250>
  231. version = 1
  232. oids = '.1.3.6.1.2.1.33.1.1.3.0'
  233. ------------------------------------------------------------------------
  234. File: local/lib/python2.7/site-packages/tornado/gen.py (Line: 1063)
  235. Function: run
  236. 1056 except Exception:
  237. 1057 self.had_exception = True
  238. 1058 exc_info = sys.exc_info()
  239. 1059 future = None
  240. 1060
  241. 1061 if exc_info is not None:
  242. 1062 try:
  243. 1063 ==> yielded = self.gen.throw(*exc_info)
  244. 1064 finally:
  245. 1065 # Break up a reference to itself
  246. 1066 # for faster GC on CPython.
  247. 1067 exc_info = None
  248. 1068 else:
  249. 1069 yielded = self.gen.send(value)
  250. Variables:
  251. exc_info = None
  252. self = <tornado.gen.Runner object at 0x7f62b49c40d0>
  253. future = None
  254. orig_stack_contexts = ((), None)
  255. ------------------------------------------------------------------------
  256. File: local/lib/python2.7/site-packages/tornado/concurrent.py (Line: 238)
  257. Function: result
  258. 231 before the `Future` is done, so the ``timeout`` is never used.
  259. 232 """
  260. 233 self._clear_tb_log()
  261. 234 if self._result is not None:
  262. 235 return self._result
  263. 236 if self._exc_info is not None:
  264. 237 try:
  265. 238 ==> raise_exc_info(self._exc_info)
  266. 239 finally:
  267. 240 self = None
  268. 241 self._check_done()
  269. 242 return self._result
  270. 243
  271. 244 def exception(self, timeout=None):
  272. Variables:
  273. self = None
  274. timeout = None
  275. ------------------------------------------------------------------------
  276. File: local/lib/python2.7/site-packages/tornado/ioloop.py (Line: 458)
  277. Function: run_sync
  278. 451 if timeout is not None:
  279. 452 timeout_handle = self.add_timeout(self.time() + timeout, self.stop)
  280. 453 self.start()
  281. 454 if timeout is not None:
  282. 455 self.remove_timeout(timeout_handle)
  283. 456 if not future_cell[0].done():
  284. 457 raise TimeoutError('Operation timed out after %s seconds' % timeout)
  285. 458 ==> return future_cell[0].result()
  286. 459
  287. 460 def time(self):
  288. 461 """Returns the current time according to the `IOLoop`'s clock.
  289. 462
  290. 463 The return value is a floating-point number relative to an
  291. 464 unspecified time in the past.
  292. Variables:
  293. self = <tornado.platform.epoll.EPollIOLoop object at 0x7f62b502f5d0>
  294. run = <function run at 0x7f62b502a758>
  295. func = <function run at 0x7f62b502a488>
  296. timeout = None
  297. future_cell = [<tornado.concurrent.Future object at 0x7f62b502f810>]
  298. ------------------------------------------------------------------------
  299. File: core/script/snmp/base.py (Line: 122)
  300. Function: get
  301. 115 if not self.timeouts:
  302. 116 raise self.FatalTimeoutError()
  303. 117 raise self.TimeOutError()
  304. 118 else:
  305. 119 raise
  306. 120
  307. 121 version = self._get_snmp_version(version)
  308. 122 ==> self.get_ioloop().run_sync(run)
  309. 123 return self.result
  310. 124
  311. 125 def set(self, *args):
  312. 126 """
  313. 127 Perform SNMP GET request
  314. 128 :param oid: string or list of oids
  315. Variables:
  316. cached = False
  317. self = <noc.core.script.snmp.base.SNMP object at 0x7f62b502f250>
  318. version = 1
  319. run = <function run at 0x7f62b502a488>
  320. oids = '.1.3.6.1.2.1.33.1.1.3.0'
  321. ------------------------------------------------------------------------
  322. File: sa/profiles/APC/AOS/get_version.py (Line: 31)
  323. Function: execute_snmp
  324. 24 rx_platform = re.compile(r"^(?P<platform>.+?)\s+named\s+", re.MULTILINE)
  325. 25
  326. 26 rx_platform1 = re.compile(r"^Name\s+: (?P<platform>.+?)\s+Date",
  327. 27 re.MULTILINE)
  328. 28
  329. 29 def execute_snmp(self, **kwargs):
  330. 30 platform = self.snmp.get("1.3.6.1.2.1.33.1.1.2.0")
  331. 31 ==> firmware = self.snmp.get(".1.3.6.1.2.1.33.1.1.3.0")
  332. 32 return {
  333. 33 "vendor": "APC",
  334. 34 "platform": platform,
  335. 35 # "version": firmware
  336. 36 "version": firmware
  337. 37 }
  338. Variables:
  339. platform = 'Smart-UPS 2200'
  340. self = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
  341. kwargs = {}
  342. ------------------------------------------------------------------------
  343. File: core/script/base.py (Line: 422)
  344. Function: call_method
  345. 415 if isinstance(handler, six.string_types):
  346. 416 handler = getattr(self, handler, None)
  347. 417 if handler is None:
  348. 418 self.logger.debug("No '%s' handler. Passing to next method" % m)
  349. 419 continue
  350. 420 # Call handler
  351. 421 try:
  352. 422 ==> r = handler(**kwargs)
  353. 423 if isinstance(r, PartialResult):
  354. 424 if self.partial_result:
  355. 425 self.partial_result.update(r.result)
  356. 426 else:
  357. 427 self.partial_result = r.result
  358. 428 self.logger.debug("Partial result: %r. Passing to next method", self.partial_result)
  359. Variables:
  360. self = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
  361. m = u'S'
  362. fallback_handler = None
  363. cli_handler =
  364. <bound method Script.execute_cli of <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>>
  365. handler =
  366. <bound method Script.execute_snmp of <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>>
  367. kwargs = {}
  368. snmp_handler =
  369. <bound method Script.execute_snmp of <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>>
  370. access_preference = u'SC*'
  371. ------------------------------------------------------------------------
  372. File: core/script/base.py (Line: 385)
  373. Function: execute
  374. 378 # Raise error
  375. 379 raise self.NotSupportedError()
  376. 380 else:
  377. 381 # New SNMP/CLI API
  378. 382 return self.call_method(
  379. 383 cli_handler=self.execute_cli,
  380. 384 snmp_handler=self.execute_snmp,
  381. 385 ==> **kwargs
  382. 386 )
  383. 387
  384. 388 def call_method(self, cli_handler=None, snmp_handler=None,
  385. 389 fallback_handler=None, **kwargs):
  386. 390 """
  387. 391 Call function depending on access_preference
  388. Variables:
  389. self = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
  390. kwargs = {}
  391. ------------------------------------------------------------------------
  392. File: core/script/base.py (Line: 247)
  393. Function: run
  394. 240 self.logger.info("Using cached result")
  395. 241 cache_hit = True
  396. 242 except KeyError:
  397. 243 pass
  398. 244 # Execute script
  399. 245 if not cache_hit:
  400. 246 try:
  401. 247 ==> result = self.execute(**self.args)
  402. 248 if self.cache and self.parent and result:
  403. 249 self.logger.info("Caching result")
  404. 250 self.set_cache(self.name, self.args, result)
  405. 251 finally:
  406. 252 if not self.parent:
  407. 253 # Close SNMP socket when necessary
  408. Variables:
  409. cache_hit = False
  410. self = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
  411. ------------------------------------------------------------------------
  412. File: commands/script.py (Line: 118)
  413. Function: handle
  414. 111 capabilities=caps,
  415. 112 args=args,
  416. 113 version=version,
  417. 114 timeout=3600,
  418. 115 name=script,
  419. 116 collect_beef=bool(beef)
  420. 117 )
  421. 118 ==> result = scr.run()
  422. 119 if pretty:
  423. 120 pprint.pprint(result)
  424. 121 elif yaml:
  425. 122 import yaml
  426. 123 import sys
  427. 124 yaml.dump(result, sys.stdout)
  428. Variables:
  429. obj = <ManagedObject: apcFA0D7A>
  430. beef = None
  431. service = <__main__.ServiceStub object at 0x7f62b5017e50>
  432. script = u'APC.AOS.get_version'
  433. script_class = <class 'noc.sa.profiles.APC.AOS.get_version.Script'>
  434. self = <__main__.Command object at 0x7f62c19b1b10>
  435. args = {}
  436. use_snmp = True
  437. caps =
  438. {u'SNMP': True,
  439. u'SNMP | Bulk': True,
  440. u'SNMP | IF-MIB': True,
  441. u'SNMP | v1': True,
  442. u'SNMP | v2c': True,
  443. u'SNMP | v3': False}
  444. yaml = False
  445. object_name = ['apcFA0D7A']
  446. version = None
  447. arguments = []
  448. pretty = True
  449. credentials =
  450. {'access_preference': u'SC',
  451. 'address': u'10.20.50.50',
  452. 'cli_protocol': 'telnet',
  453. 'password': None,
  454. 'path': None,
  455. 'raise_privileges': True,
  456. 'snmp_ro': u'kondaro',
  457. 'snmp_version': 'v2c',
  458. 'super_password': None,
  459. 'user': None}
  460. access_preference = None
  461. options = {}
  462. scr = <noc.sa.profiles.APC.AOS.get_version.Script object at 0x7f62b502f150>
  463. ------------------------------------------------------------------------
  464. File: core/management/base.py (Line: 75)
  465. Function: run_from_argv
  466. 68 enable_profiling = cmd_options.pop("enable_profiling", False)
  467. 69 show_metrics = cmd_options.pop("show_metrics", False)
  468. 70 if enable_profiling:
  469. 71 # Start profiler
  470. 72 import yappi
  471. 73 yappi.start()
  472. 74 try:
  473. 75 ==> return self.handle(*args, **cmd_options) or 0
  474. 76 except CommandError as e:
  475. 77 self.print(str(e))
  476. 78 return 1
  477. 79 except KeyboardInterrupt:
  478. 80 self.print("Ctrl+C")
  479. 81 return 3
  480. Variables:
  481. parser =
  482. ArgumentParser(prog='script.py', usage=None, description=None, version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
  483. loglevel = 'debug'
  484. enable_profiling = False
  485. args = ()
  486. cmd_options =
  487. {'access_preference': None,
  488. 'arguments': [],
  489. 'beef': None,
  490. 'object_name': ['apcFA0D7A'],
  491. 'pretty': True,
  492. 'script': ['get_version'],
  493. 'use_snmp': True,
  494. 'yaml': False}
  495. argv = ['--debug', '--pretty', 'get_version', 'apcFA0D7A']
  496. self = <__main__.Command object at 0x7f62c19b1b10>
  497. show_metrics = False
  498. options =
  499. Namespace(access_preference=None, arguments=[], beef=None, object_name=['apcFA0D7A'], pretty=True, script=['get_version'], use_snmp=True, yaml=False)
  500. ------------------------------------------------------------------------
  501. END OF TRACEBACK
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement