Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [root@noc noc]# ./noc fix apply fix_platform_full_name
- 2017-09-15 15:15:42,114 [noc.core.dcs.base] Resolve near service postgres
- 2017-09-15 15:15:42,119 [noc.core.dcs.base] Resolved near service postgres to ['10.0.4.111:5432']
- 2017-09-15 15:15:42,346 [noc.core.dcs.base] Running resolver for service mongo
- 2017-09-15 15:15:42,348 [noc.core.dcs.base] [mongo] Starting resolver
- 2017-09-15 15:15:42,351 [noc.core.dcs.base] [mongo] Set active services to: mongo: 10.0.4.111:27017
- 2017-09-15 15:15:42,352 [noc.lib.nosql] Connecting to MongoDB {'username': 'noc', 'authentication_source': 'noc', 'readPreference': 'secondaryPreferred', 'replicaSet': 'noc', 'db': 'noc', 'socketKeepAlive': True, 'host': 'mongodb://noc:noc@10.0.4.111:27017/noc', 'password': '********'}
- Apply fix_platform_full_name ...
- 2017-09-15 15:15:42,569 [noc.core.debug] UNHANDLED EXCEPTION (2017-09-15 15:15:42.413897)
- BRANCH: feature/microservices TIP: 8b63c103d656
- PROCESS: ./commands/fix.py
- ERROR FINGERPRINT: 1f089e0c-1de6-5ddc-a713-c2cd2f12d097
- WORKING DIRECTORY: /opt/noc
- EXCEPTION: <class 'pymongo.errors.DuplicateKeyError'> E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }
- START OF TRACEBACK
- ------------------------------------------------------------------------
- File: lib/python2.7/site-packages/pymongo/helpers.py (Line: 203)
- Function: _check_command_response
- 196 details.get("assertionCode"),
- 197 response)
- 198
- 199 # Other errors
- 200 code = details.get("code")
- 201 # findAndModify with upsert can raise duplicate key error
- 202 if code in (11000, 11001, 12582):
- 203 ==> raise DuplicateKeyError(errmsg, code, response)
- 204 elif code == 50:
- 205 raise ExecutionTimeout(errmsg, code, response)
- 206 elif code == 43:
- 207 raise CursorNotFound(errmsg, code, response)
- 208
- 209 msg = msg or "%s"
- Variables:
- parse_write_concern_error = True
- code = 11000
- allowable_errors = None
- details =
- {u'code': 11000,
- u'errmsg': u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',
- u'ok': 0.0}
- msg = None
- response =
- {u'code': 11000,
- u'errmsg': u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',
- u'ok': 0.0}
- errmsg =
- u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }'
- ------------------------------------------------------------------------
- File: lib/python2.7/site-packages/pymongo/network.py (Line: 116)
- Function: command
- 109 unpacked = helpers._unpack_response(
- 110 response, codec_options=codec_options)
- 111
- 112 response_doc = unpacked['data'][0]
- 113 if check:
- 114 helpers._check_command_response(
- 115 response_doc, None, allowable_errors,
- 116 ==> parse_write_concern_error=parse_write_concern_error)
- 117 except Exception as exc:
- 118 if publish:
- 119 duration = (datetime.datetime.now() - start) + encoding_duration
- 120 if isinstance(exc, (NotMasterError, OperationFailure)):
- 121 failure = exc.details
- 122 else:
- Variables:
- size = 138
- max_bson_size = 16777216
- codec_options =
- CodecOptions(document_class=dict, tz_aware=False, uuid_representation=PYTHON_LEGACY, unicode_decode_error_handler='replace', tzinfo=None)
- check = True
- orig =
- SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
- parse_write_concern_error = True
- allowable_errors = None
- sock = <socket._socketobject object at 0x2f7ede0>
- publish = False
- name = 'createIndexes'
- read_concern = ReadConcern()
- read_preference = Primary()
- msg =
- '\xaf\x00\x00\x00\xecXUb\x00\x00\x00\x00\xd4\x07\x00\x00\x00\x00\x00\x00noc.$cmd\x00\x00\x00\x00\x00\xff\xff\xff\xff\x8a\x00\x00\x00\x02createIndexes\x00\x0e\x00\x00\x00noc.platforms\x00\x04indexes\x00[\x00\x00\x00\x030\x00S\x00\x00\x00\x08unique\x00\x01\x08background\x00\x00\x08sparse\x00\x00\x03key\x00\x14\x00\x00\x00\x10full_name\x00\x01\x00\x00\x00\x00\x02name\x00\x0c\x00\x00\x00full_name_1\x00\x00\x00\x00'
- ns = u'noc.$cmd'
- is_mongos = False
- dbname = u'noc'
- response_doc =
- {u'code': 11000,
- u'errmsg': u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',
- u'ok': 0.0}
- slave_ok = False
- address = (u'noc', 27017)
- collation = None
- response =
- '\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x87\x00\x00\x00\x01ok\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02errmsg\x00`\x00\x00\x00E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }\x00\x10code\x00\xf8*\x00\x00\x00'
- check_keys = False
- exc =
- DuplicateKeyError(u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',)
- unpacked =
- {'cursor_id': 0,
- 'data': [{u'code': 11000,
- u'errmsg': u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',
- u'ok': 0.0}],
- 'number_returned': 1,
- 'starting_from': 0}
- spec =
- SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
- listeners = <pymongo.monitoring._EventListeners object at 0x2fd5110>
- flags = 0
- request_id = 1649760492
- ------------------------------------------------------------------------
- File: lib/python2.7/site-packages/pymongo/pool.py (Line: 477)
- Function: command
- 470 try:
- 471 return command(self.sock, dbname, spec, slave_ok,
- 472 self.is_mongos, read_preference, codec_options,
- 473 check, allowable_errors, self.address,
- 474 check_keys, self.listeners, self.max_bson_size,
- 475 read_concern,
- 476 parse_write_concern_error=parse_write_concern_error,
- 477 ==> collation=collation)
- 478 except OperationFailure:
- 479 raise
- 480 # Catch socket.error, KeyboardInterrupt, etc. and close ourselves.
- 481 except BaseException as error:
- 482 self._raise_connection_failure(error)
- 483
- Variables:
- parse_write_concern_error = True
- check_keys = False
- allowable_errors = None
- self = SocketInfo(<socket._socketobject object at 0x2f7ede0>) at 50308752
- codec_options =
- CodecOptions(document_class=dict, tz_aware=False, uuid_representation=PYTHON_LEGACY, unicode_decode_error_handler='replace', tzinfo=None)
- dbname = u'noc'
- spec =
- SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
- read_concern = ReadConcern()
- slave_ok = False
- write_concern = WriteConcern()
- read_preference = Primary()
- collation = None
- check = True
- ------------------------------------------------------------------------
- File: lib/python2.7/site-packages/pymongo/collection.py (Line: 232)
- Function: _command
- 225 read_preference or self.read_preference,
- 226 codec_options or self.codec_options,
- 227 check,
- 228 allowable_errors,
- 229 read_concern=read_concern,
- 230 write_concern=write_concern,
- 231 parse_write_concern_error=parse_write_concern_error,
- 232 ==> collation=collation)
- 233
- 234 def __create(self, options, collation):
- 235 """Sends a create command with the given options.
- 236 """
- 237 cmd = SON([("create", self.__name)])
- 238 if options:
- Variables:
- parse_write_concern_error = True
- allowable_errors = None
- self =
- Collection(Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc'), u'noc.platforms')
- codec_options =
- CodecOptions(document_class=dict, tz_aware=False, uuid_representation=PYTHON_LEGACY, unicode_decode_error_handler='replace', tzinfo=None)
- read_concern = ReadConcern()
- slave_ok = False
- command =
- SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
- write_concern = WriteConcern()
- read_preference = Primary()
- collation = None
- check = True
- sock_info = SocketInfo(<socket._socketobject object at 0x2f7ede0>) at 50308752
- ------------------------------------------------------------------------
- File: lib/python2.7/site-packages/pymongo/collection.py (Line: 1472)
- Function: __create_index
- 1465 index['collation'] = collation
- 1466 cmd = SON([('createIndexes', self.name), ('indexes', [index])])
- 1467 try:
- 1468 self._command(
- 1469 sock_info, cmd, read_preference=ReadPreference.PRIMARY,
- 1470 codec_options=_UNICODE_REPLACE_CODEC_OPTIONS,
- 1471 write_concern=self.write_concern,
- 1472 ==> parse_write_concern_error=True)
- 1473 except OperationFailure as exc:
- 1474 if exc.code in common.COMMAND_NOT_FOUND_CODES:
- 1475 index["ns"] = self.__full_name
- 1476 wcn = (self.write_concern if
- 1477 self.write_concern.acknowledged else WriteConcern())
- 1478 self.__database.system.indexes._insert(
- Variables:
- index =
- {'background': False,
- 'key': SON([('full_name', 1)]),
- 'name': u'full_name_1',
- 'sparse': False,
- 'unique': True}
- index_doc = SON([('full_name', 1)])
- exc =
- DuplicateKeyError(u'E11000 duplicate key error collection: noc.noc.platforms index: full_name_1 dup key: { : null }',)
- index_options =
- {'background': False, 'name': u'full_name_1', 'sparse': False, 'unique': True}
- keys = [('full_name', 1)]
- self =
- Collection(Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc'), u'noc.platforms')
- cmd =
- SON([('createIndexes', u'noc.platforms'), ('indexes', [{'unique': True, 'background': False, 'sparse': False, 'key': SON([('full_name', 1)]), 'name': u'full_name_1'}])])
- collation = None
- sock_info = SocketInfo(<socket._socketobject object at 0x2f7ede0>) at 50308752
- ------------------------------------------------------------------------
- File: lib/python2.7/site-packages/pymongo/collection.py (Line: 1571)
- Function: create_index
- 1564 :meth:`create_index` no longer caches index names. Removed support
- 1565 for the drop_dups and bucket_size aliases.
- 1566
- 1567 .. mongodoc:: indexes
- 1568 """
- 1569 keys = helpers._index_list(keys)
- 1570 name = kwargs.setdefault("name", helpers._gen_index_name(keys))
- 1571 ==> self.__create_index(keys, kwargs)
- 1572 return name
- 1573
- 1574 def ensure_index(self, key_or_list, cache_for=300, **kwargs):
- 1575 """**DEPRECATED** - Ensures that an index exists on this collection.
- 1576
- 1577 .. versionchanged:: 3.0
- Variables:
- keys = [('full_name', 1)]
- self =
- Collection(Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc'), u'noc.platforms')
- name = u'full_name_1'
- kwargs =
- {'background': False, 'name': u'full_name_1', 'sparse': False, 'unique': True}
- ------------------------------------------------------------------------
- File: lib/python2.7/site-packages/mongoengine/document.py (Line: 836)
- Function: ensure_indexes
- 829
- 830 # we shouldn't pass 'cls' to the collection.ensureIndex options
- 831 # because of https://jira.mongodb.org/browse/SERVER-769
- 832 if 'cls' in opts:
- 833 del opts['cls']
- 834
- 835 if IS_PYMONGO_3:
- 836 ==> collection.create_index(fields, background=background, **opts)
- 837 else:
- 838 collection.ensure_index(fields, background=background,
- 839 drop_dups=drop_dups, **opts)
- 840
- 841 # If _cls is being used (for polymorphism), it needs an index,
- 842 # only if another index doesn't begin with _cls
- Variables:
- index_spec =
- [{'fields': [('vendor', 1), ('name', 1)], 'unique': True},
- {'fields': [('full_name', 1)], 'sparse': False, 'unique': True}]
- fields = [('full_name', 1)]
- collection =
- Collection(Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc'), u'noc.platforms')
- drop_dups = False
- background = False
- cls_indexed = False
- cls = <class 'noc.inv.models.platform.Platform'>
- index_cls = True
- spec = {'unique': True, 'sparse': False}
- opts = {'unique': True, 'sparse': False}
- index_opts = {}
- ------------------------------------------------------------------------
- File: lib/python2.7/site-packages/mongoengine/document.py (Line: 206)
- Function: _get_collection
- 199 opts['max'] = max_documents
- 200 cls._collection = db.create_collection(
- 201 collection_name, **opts
- 202 )
- 203 else:
- 204 cls._collection = db[collection_name]
- 205 if cls._meta.get('auto_create_index', True):
- 206 ==> cls.ensure_indexes()
- 207 return cls._collection
- 208
- 209 def to_mongo(self, *args, **kwargs):
- 210 data = super(Document, self).to_mongo(*args, **kwargs)
- 211
- 212 # If '_id' is None, try and set it from self._data. If that
- Variables:
- collection_name = 'noc.platforms'
- db =
- Database(MongoClient(host=['10.0.4.111:27017'], document_class=dict, tz_aware=False, connect=True, socketkeepalive=True, readpreference='secondaryPreferred', replicaset='noc', read_preference=Primary()), u'noc')
- cls = <class 'noc.inv.models.platform.Platform'>
- ------------------------------------------------------------------------
- File: lib/python2.7/site-packages/mongoengine/queryset/manager.py (Line: 37)
- Function: __get__
- 30 """
- 31 if instance is not None:
- 32 # Document object being used rather than a document class
- 33 return self
- 34
- 35 # owner is the document that contains the QuerySetManager
- 36 queryset_class = owner._meta.get('queryset_class', self.default)
- 37 ==> queryset = queryset_class(owner, owner._get_collection())
- 38 if self.get_queryset:
- 39 arg_count = self.get_queryset.func_code.co_argcount
- 40 if arg_count == 1:
- 41 queryset = self.get_queryset(queryset)
- 42 elif arg_count == 2:
- 43 queryset = self.get_queryset(owner, queryset)
- Variables:
- owner = <class 'noc.inv.models.platform.Platform'>
- instance = None
- self = <mongoengine.queryset.manager.QuerySetManager object at 0x2ffa350>
- queryset_class = <class 'mongoengine.queryset.queryset.QuerySet'>
- ------------------------------------------------------------------------
- File: fixes/fix_platform_full_name.py (Line: 14)
- Function: fix
- 7 # ----------------------------------------------------------------------
- 8
- 9 # NOC modules
- 10 from noc.inv.models.platform import Platform
- 11
- 12
- 13 def fix():
- 14 ==> for p in Platform.objects.all():
- 15 p.save()
- Variables:
- ------------------------------------------------------------------------
- File: commands/fix.py (Line: 74)
- Function: handle_apply
- 67 return
- 68 import noc.lib.nosql # Connect to mongo
- 69 for f in fixes:
- 70 fix = self.get_fix(f)
- 71 if not fix:
- 72 self.die("Invalid fix '%s'" % f)
- 73 print("Apply %s ..." % f, file=self.stdout)
- 74 ==> fix()
- 75 print("... done", file=self.stdout)
- 76
- 77
- 78 if __name__ == "__main__":
- 79 Command().run()
- Variables:
- f = 'fix_platform_full_name'
- fix = <function fix at 0x2ff9758>
- args = ()
- fixes = ['fix_platform_full_name']
- noc = <module 'noc' from '/opt/noc/__init__.pyc'>
- self = <__main__.Command object at 0x7f5cd95c7ed0>
- options = {}
- ------------------------------------------------------------------------
- File: commands/fix.py (Line: 34)
- Function: handle
- 27 apply_parser.add_argument(
- 28 "fixes",
- 29 nargs=argparse.REMAINDER,
- 30 help="Apply named fixes"
- 31 )
- 32
- 33 def handle(self, cmd, *args, **options):
- 34 ==> return getattr(self, "handle_%s" % cmd)(*args, **options)
- 35
- 36 def handle_list(self, *args, **options):
- 37 fixes = set()
- 38 for d in self.FIX_DIRS:
- 39 if not os.path.isdir(d):
- 40 continue
- Variables:
- cmd = 'apply'
- self = <__main__.Command object at 0x7f5cd95c7ed0>
- args = ()
- options = {'fixes': ['fix_platform_full_name']}
- ------------------------------------------------------------------------
- File: core/management/base.py (Line: 75)
- Function: run_from_argv
- 68 enable_profiling = cmd_options.pop("enable_profiling", False)
- 69 show_metrics = cmd_options.pop("show_metrics", False)
- 70 if enable_profiling:
- 71 # Start profiler
- 72 import yappi
- 73 yappi.start()
- 74 try:
- 75 ==> return self.handle(*args, **cmd_options) or 0
- 76 except CommandError as e:
- 77 self.print(str(e))
- 78 return 1
- 79 except KeyboardInterrupt:
- 80 self.print("Ctrl+C")
- 81 return 3
- Variables:
- parser =
- ArgumentParser(prog='fix.py', usage=None, description=None, version=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
- loglevel = 'info'
- enable_profiling = False
- args = ()
- cmd_options = {'cmd': 'apply', 'fixes': ['fix_platform_full_name']}
- argv = ['apply', 'fix_platform_full_name']
- self = <__main__.Command object at 0x7f5cd95c7ed0>
- show_metrics = False
- options = Namespace(cmd='apply', fixes=['fix_platform_full_name'])
- ------------------------------------------------------------------------
- END OF TRACEBACK
Add Comment
Please, Sign In to add comment