docker-compose is ok

This commit is contained in:
pycook
2023-07-11 18:12:22 +08:00
parent 77d89677ef
commit b93afc1790
11 changed files with 94 additions and 13741 deletions

View File

@@ -41,6 +41,15 @@ from api.models.cmdb import PreferenceRelationView
def cmdb_init_cache():
db.session.remove()
ci_relations = CIRelation.get_by(to_dict=False)
relations = dict()
for cr in ci_relations:
relations.setdefault(cr.first_ci_id, {}).update({cr.second_ci_id: cr.second_ci.type_id})
for i in relations:
relations[i] = json.dumps(relations[i])
if relations:
rd.create_or_update(relations, REDIS_PREFIX_CI_RELATION)
if current_app.config.get("USE_ES"):
from api.extensions import es
from api.models.cmdb import Attribute
@@ -83,15 +92,6 @@ def cmdb_init_cache():
else:
rd.create_or_update({ci.id: json.dumps(ci_dict)}, REDIS_PREFIX_CI)
ci_relations = CIRelation.get_by(to_dict=False)
relations = dict()
for cr in ci_relations:
relations.setdefault(cr.first_ci_id, {}).update({cr.second_ci_id: cr.second_ci.type_id})
for i in relations:
relations[i] = json.dumps(relations[i])
if relations:
rd.create_or_update(relations, REDIS_PREFIX_CI_RELATION)
db.session.remove()

View File

@@ -95,7 +95,7 @@ class Search(object):
for _v in new_v:
ci_type = CITypeCache.get(_v)
if len(new_v) == 1 and not self.sort and ci_type.default_order_attr:
if len(new_v) == 1 and not self.sort and ci_type and ci_type.default_order_attr:
self.sort = ci_type.default_order_attr
if ci_type is not None:

View File

@@ -41,7 +41,7 @@ class ACLManager(object):
def get_all_roles(self):
numfound, roles = RoleCRUD.search(
None, self.app_name, 1, 999999, True, True, False)
return roles
return [i.to_dict() for i in roles]
def remove_user_from_role(self, user_rid, payload):
app_id = self.app_name

View File

@@ -444,7 +444,7 @@ class AutoDiscoveryCIType(Model):
__tablename__ = "c_ad_ci_types"
type_id = db.Column(db.Integer, db.ForeignKey('c_ci_types.id'))
adr_id = db.Column(db.Integer, db.ForeignKey('c_ad_ci_types.id'))
adr_id = db.Column(db.Integer, db.ForeignKey('c_ad_rules.id'))
attributes = db.Column(db.JSON) # {ad_key: cmdb_key}

View File

@@ -1,3 +1,5 @@
# -*- coding:utf-8 -*-
from api.extensions import db
from api.lib.database import Model, TimestampMixin, SoftDeleteMixin, CRUDMixin