Size: a a a

2020 October 31

ID

Iacopo Dalla Verità in NOC Project
Ok, but i think the only way for create a object with custom ID, is from MongoDB
источник

DK

Dmitry K. in NOC Project
Iacopo Dalla Verità
Ok, but i think the only way for create a object with custom ID, is from MongoDB
no, be patient , i create script to clone MO with right id for you
источник

ID

Iacopo Dalla Verità in NOC Project
Dmitry K.
no, be patient , i create script to clone MO with right id for you
Thank you, awesome!
источник

DK

Dmitry K. in NOC Project
./noc shell

from noc.sa.models.managedobject import ManagedObject
from noc.core.mongo.connection import connect
connect()

mo = ManagedObject.objects.filter().first()

mo.id = 10
mo.name = "NEW_OBJECT_WITH_ID_10"
mo.save()


@Pinno93
источник

ID

Iacopo Dalla Verità in NOC Project
>>> mo = ManagedObject.objects.filter().first()
>>>
>>> mo.id = 10
>>> mo.name = "NEW_OBJECT_WITH_ID_10"
>>> mo.save()
Traceback (most recent call last):
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
   return self.cursor.execute(sql, params)
 File "/opt/noc/core/model/db/monitor.py", line 26, in execute
   super().execute(query, vars)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "sa_managedobject_bi_id"
DETAIL:  Key (bi_id)=(5936744569129038149) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 745, in save
   self.save_base(using=using, force_insert=force_insert,
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 782, in save_base
   updated = self._save_table(
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 887, in _save_table
   results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 924, in _do_insert
   return manager._insert(
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
   return getattr(self.get_queryset(), name)(*args, **kwargs)
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/query.py", line 1204, in _insert
   return query.get_compiler(using=using).execute_sql(returning_fields)
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1391, in execute_sql
   cursor.execute(sql, params)
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 68, in execute
   return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
   return executor(sql, params, many, context)
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
   return self.cursor.execute(sql, params)
 File "/opt/noc/lib/python3.8/site-packages/django/db/utils.py", line 90, in exit
   raise dj_exc_value.with_traceback(traceback) from exc_value
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
   return self.cursor.execute(sql, params)
 File "/opt/noc/core/model/db/monitor.py", line 26, in execute
   super().execute(query, vars)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "sa_managedobject_bi_id"
DETAIL:  Key (bi_id)=(5936744569129038149) already exists.
источник

ID

Iacopo Dalla Verità in NOC Project
today everything is bad 😂
источник

G

Gitlab in NOC Project
источник

DK

Dmitry K. in NOC Project
Iacopo Dalla Verità
>>> mo = ManagedObject.objects.filter().first()
>>>
>>> mo.id = 10
>>> mo.name = "NEW_OBJECT_WITH_ID_10"
>>> mo.save()
Traceback (most recent call last):
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
   return self.cursor.execute(sql, params)
 File "/opt/noc/core/model/db/monitor.py", line 26, in execute
   super().execute(query, vars)
psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "sa_managedobject_bi_id"
DETAIL:  Key (bi_id)=(5936744569129038149) already exists.


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 745, in save
   self.save_base(using=using, force_insert=force_insert,
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 782, in save_base
   updated = self._save_table(
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 887, in _save_table
   results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 924, in _do_insert
   return manager._insert(
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/manager.py", line 82, in manager_method
   return getattr(self.get_queryset(), name)(*args, **kwargs)
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/query.py", line 1204, in _insert
   return query.get_compiler(using=using).execute_sql(returning_fields)
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1391, in execute_sql
   cursor.execute(sql, params)
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 68, in execute
   return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
   return executor(sql, params, many, context)
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
   return self.cursor.execute(sql, params)
 File "/opt/noc/lib/python3.8/site-packages/django/db/utils.py", line 90, in exit
   raise dj_exc_value.with_traceback(traceback) from exc_value
 File "/opt/noc/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
   return self.cursor.execute(sql, params)
 File "/opt/noc/core/model/db/monitor.py", line 26, in execute
   super().execute(query, vars)
django.db.utils.IntegrityError: duplicate key value violates unique constraint "sa_managedobject_bi_id"
DETAIL:  Key (bi_id)=(5936744569129038149) already exists.
./noc shell

from noc.sa.models.managedobject import ManagedObject
from noc.core.mongo.connection import connect
connect()

mo = ManagedObject.objects.filter().first()

mo.id = 10
mo.name = "NEW_OBJECT_WITH_ID_10"
del mo.bi_id
mo.save()
источник

ID

Iacopo Dalla Verità in NOC Project
>>> delete mo.bi_id
 File "<stdin>", line 1
   delete mo.bi_id
          ^
SyntaxError: invalid syntax
источник

DK

Dmitry K. in NOC Project
sorry del
источник

ID

Iacopo Dalla Verità in NOC Project
>>> from noc.sa.models.managedobject import ManagedObject
>>> from noc.core.mongo.connection import connect
>>> connect()
>>>
>>> mo = ManagedObject.objects.filter().first()

>>>
>>> mo.id = 10
>>> mo.name = "NEW_OBJECT_WITH_ID_10"
>>> del mo.bi_id
>>> mo.save()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 745, in save
   self.save_base(using=using, force_insert=force_insert,
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 782, in save_base
   updated = self._save_table(
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 869, in _save_table
   raise DatabaseError("Save with update_fields did not affect any rows.")
django.db.utils.DatabaseError: Save with update_fields did not affect any rows.
источник

DK

Dmitry K. in NOC Project
Iacopo Dalla Verità
>>> from noc.sa.models.managedobject import ManagedObject
>>> from noc.core.mongo.connection import connect
>>> connect()
>>>
>>> mo = ManagedObject.objects.filter().first()

>>>
>>> mo.id = 10
>>> mo.name = "NEW_OBJECT_WITH_ID_10"
>>> del mo.bi_id
>>> mo.save()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 745, in save
   self.save_base(using=using, force_insert=force_insert,
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 782, in save_base
   updated = self._save_table(
 File "/opt/noc/lib/python3.8/site-packages/django/db/models/base.py", line 869, in _save_table
   raise DatabaseError("Save with update_fields did not affect any rows.")
django.db.utils.DatabaseError: Save with update_fields did not affect any rows.
ok, will try another way, please wait
источник

ID

Iacopo Dalla Verità in NOC Project
no problem, i have hope
источник

RM

Roman Melnyk in NOC Project
Roman Melnyk
Всем привет.
Вопрос по поводу линковки ifDesc.
В профайле интерфейса обязательно указывать помимо IfDesc pattern ещё и Handler?
Почему то если не указать handler в профиле порта и сохранить то ifdesc_pattern не сохраняется и тупо пустое поле показывает если повторно зайти в профиль порта.
Хотя в доке пишет типа "Если для профиля интерфейса заданы настройки ifdesc_patterns или ifdesc_handler".
Подскажет кто?
источник

DK

Dmitry K. in NOC Project
Iacopo Dalla Verità
no problem, i have hope
./noc shell

from noc.sa.models.managedobject import ManagedObject
from noc.core.bi.decorator import bi_hash



from noc.core.mongo.connection import connect
connect()

mo = ManagedObject.objects.filter().first()

mo.id = 10
mo.name = "NEW_OBJECT_WITH_ID_10"
mo.bi_id = bi_hash(mo.id)
mo.save()
источник

ID

Iacopo Dalla Verità in NOC Project
It's worked
источник

ID

Iacopo Dalla Verità in NOC Project
If i open the map, i don't have error or crashinfo
источник

ID

Iacopo Dalla Verità in NOC Project
thank you very much
источник

DK

Dmitry K. in NOC Project
Iacopo Dalla Verità
thank you very much
Dont forget that you cant delete User by web too. Use
./noc wipe user USERNAME
источник

DK

Dmitry K. in NOC Project
Or move users in inactive state - its better
источник