noc-web noc]# ./noc shell
Python 3.8.3 (default, Jun 18 2020, 20:51:40)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from noc.core.mongo.connection import connect
>>> connect()
2021-03-19 08:09:33,872 [noc.core.ioloop.util] Setting up asyncio event loop policy
2021-03-19 08:09:33,872 [noc.core.ioloop.util] Setting up default event loop
2021-03-19 08:09:34,277 [noc.core.dcs.base] [mongo] Starting resolver (near=False)
2021-03-19 08:09:34,293 [noc.core.dcs.base] [mongo] Set active services to: mongo:
172.16.0.81:270172021-03-19 08:09:34,294 [noc.core.dcs.base] [mongo] Stopping resolver
2021-03-19 08:09:34,294 [noc.core.mongo.connection] Connecting to MongoDB {'db': 'noc', 'username': 'noc', 'password': '********', 'authentication_source': 'no}
>>> from noc.main.models.apitoken import APIToken
>>> from noc.aaa.models.user import User
2021-03-19 08:10:02,656 [noc.core.dcs.base] Resolve near service postgres
2021-03-19 08:10:02,665 [noc.core.dcs.base] Resolved near service postgres to ['
172.16.0.81:5432']
>>> user = User.objects.get(username="ruslan")
>>> token = APIToken.objects.filter(type="noc-gitlab-api", user=
user.id).first()
>>> token.token = "NEW_TOKEN"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'token'
>>>