Skip to content

Commit

Permalink
Merge pull request #77 from x-7/x-7-patch-1
Browse files Browse the repository at this point in the history
cmdb-api:add attr check in ci_manager update method
  • Loading branch information
pycook authored Apr 22, 2021
2 parents 5256f79 + 7936b9c commit 9c76b38
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmdb-api/api/lib/cmdb/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,13 @@ def add(cls, ci_type_name, exist_policy=ExistPolicy.REPLACE, _no_attribute_polic

def update(self, ci_id, **ci_dict):
ci = self.confirm_ci_existed(ci_id)


ci_type_attrs_name = [attr["name"] for attr in CITypeAttributeManager().get_attributes_by_type_id(ci.type_id)]
value_manager = AttributeValueManager()
for p, v in ci_dict.items():
if p not in ci_type_attrs_name:
current_app.logger.warning('ci_type: {0} not has attribute {1}, please check!'.format(ci.type_id, p))
continue
try:
value_manager.create_or_update_attr_value(p, v, ci)
except BadRequest as e:
Expand Down

0 comments on commit 9c76b38

Please sign in to comment.