Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@cachetools.cachedmethod(operator.attrgetter("_migration_cache"))
def get_migration(cls, name):
"""
Get migration instance
:param name: Migration name
:return:
"""
app, mname = name.split(".")
# @todo: Consider custom
m = __import__("noc.%s.migrations.%s" % (app, mname), {}, {}, "Migration")
assert m
return m.Migration()
@cachetools.cachedmethod(operator.attrgetter("_bi_id_cache"), lock=lambda _: id_lock)
def get_by_bi_id(cls, id):
ad = AdministrativeDomain.objects.filter(bi_id=id)[:1]
if ad:
return ad[0]
return None
@cachetools.cachedmethod(operator.attrgetter("_id_cache"), lock=lambda _: id_lock)
def get_by_id(cls, id):
return EventClass.objects.filter(id=id).first()
@cachetools.cachedmethod(operator.attrgetter("_id_cache"), lock=lambda _: id_lock)
def get_by_id(cls, id):
return Group.objects.filter(id=id).first()
@cachetools.cachedmethod(operator.attrgetter("_id_cache"), lock=lambda _: id_lock)
def get_by_id(cls, id):
try:
return Layer.objects.get(id=id)
except Layer.DoesNotExist:
return None
@cachetools.cachedmethod(operator.attrgetter("_name_cache"), lock=lambda _: id_lock)
def get_by_name(cls, name):
return AddressProfile.objects.filter(name=name).first()
@cachetools.cachedmethod(operator.attrgetter("_state_cache"), lock=lambda _: state_lock)
def get_builtins(cls, name):
"""
Returns set of UUIDs for collection
:param name:
:return:
"""
return set(Collection(name).get_state())
@cachetools.cachedmethod(operator.attrgetter("_id_cache"), lock=lambda _: id_lock)
def get_by_id(cls, id):
return ASProfile.objects.filter(id=id).first()
@cachetools.cachedmethod(operator.attrgetter("_ips_cache"), lock=lambda _: ips_lock)
def get_profiles(cls, x):
return list(InterfaceProfile.objects.filter(status_discovery=True))
@cachetools.cachedmethod(operator.attrgetter("_bi_id_cache"), lock=lambda _: id_lock)
def get_by_bi_id(cls, id):
return Platform.objects.filter(bi_id=id).first()