forked from veops/cmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'veops:master' into master
- Loading branch information
Showing
110 changed files
with
3,273 additions
and
2,095 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,4 +78,3 @@ cmdb-ui/npm-debug.log* | |
cmdb-ui/yarn-debug.log* | ||
cmdb-ui/yarn-error.log* | ||
cmdb-ui/package-lock.json | ||
start.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
line-length = 120 | ||
cache-dir = ".ruff_cache" | ||
target-version = "py310" | ||
unsafe-fixes = true | ||
show-fixes = true | ||
|
||
[lint] | ||
select = [ | ||
"E", | ||
"F", | ||
"I", | ||
"TCH", | ||
# W | ||
"W505", | ||
# PT | ||
"PT018", | ||
# SIM | ||
"SIM101", | ||
"SIM114", | ||
# PGH | ||
"PGH004", | ||
# PL | ||
"PLE1142", | ||
# RUF | ||
"RUF100", | ||
# UP | ||
"UP007" | ||
] | ||
preview = true | ||
ignore = ["FURB101"] | ||
|
||
[lint.flake8-pytest-style] | ||
mark-parentheses = false | ||
parametrize-names-type = "list" | ||
parametrize-values-row-type = "list" | ||
parametrize-values-type = "tuple" | ||
|
||
[lint.flake8-unused-arguments] | ||
ignore-variadic-names = true | ||
|
||
[lint.isort] | ||
lines-between-types = 1 | ||
order-by-type = true | ||
|
||
[lint.per-file-ignores] | ||
"**/api/v1/*.py" = ["TCH"] | ||
"**/model/*.py" = ["TCH003"] | ||
"**/models/__init__.py" = ["F401", "F403"] | ||
"**/tests/*.py" = ["E402"] | ||
"celery_worker.py" = ["F401"] | ||
"api/views/entry.py" = ["I001"] | ||
"migrations/*.py" = ["I001", "E402"] | ||
"*.py" = ["I001"] | ||
"api/views/common_setting/department.py" = ["F841"] | ||
"api/lib/common_setting/upload_file.py" = ["F841"] | ||
"api/lib/common_setting/acl.py" = ["F841"] | ||
"**/__init__.py" = ["F822"] | ||
"api/tasks/*.py" = ["E722"] | ||
"api/views/cmdb/*.py" = ["E722"] | ||
"api/views/acl/*.py" = ["E722"] | ||
"api/lib/secrets/*.py" = ["E722", "F841"] | ||
"api/lib/utils.py" = ["E722", "E731"] | ||
"api/lib/perm/authentication/cas/*" = ["E113", "F841"] | ||
"api/lib/perm/acl/*" = ["E722"] | ||
"api/lib/*" = ["E721", "F722"] | ||
"api/lib/cmdb/*" = ["F722", "E722"] | ||
"api/lib/cmdb/search/ci/es/search.py" = ["F841", "SIM114"] | ||
"api/lib/cmdb/search/ci/db/search.py" = ["F841"] | ||
"api/lib/cmdb/value.py" = ["F841"] | ||
"api/lib/cmdb/history.py" = ["E501"] | ||
"api/commands/common.py" = ["E722"] | ||
"api/commands/click_cmdb.py" = ["E722"] | ||
"api/lib/perm/auth.py" = ["SIM114"] | ||
|
||
[format] | ||
preview = true | ||
quote-style = "single" | ||
docstring-code-format = true | ||
skip-magic-trailing-comma = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,12 @@ def cmdb_trigger(): | |
""" | ||
from api.lib.cmdb.ci import CITriggerManager | ||
|
||
current_app.test_request_context().push() | ||
if not UserCache.get('worker'): | ||
from api.lib.perm.acl.user import UserCRUD | ||
UserCRUD.add(username='worker', password=uuid.uuid4().hex, email='[email protected]') | ||
login_user(UserCache.get('worker')) | ||
|
||
current_day = datetime.datetime.today().strftime("%Y-%m-%d") | ||
trigger2cis = dict() | ||
trigger2completed = dict() | ||
|
@@ -256,10 +262,10 @@ def cmdb_trigger(): | |
trigger2cis[trigger.id] = (trigger, ready_cis) | ||
else: | ||
cur = trigger2cis[trigger.id] | ||
cur_ci_ids = {i.ci_id for i in cur[1]} | ||
cur_ci_ids = {_ci.ci_id for _ci in cur[1]} | ||
trigger2cis[trigger.id] = ( | ||
trigger, cur[1] + [i for i in ready_cis if i.ci_id not in cur_ci_ids | ||
and i.ci_id not in trigger2completed.get(trigger.id, {})]) | ||
trigger, cur[1] + [_ci for _ci in ready_cis if _ci.ci_id not in cur_ci_ids | ||
and _ci.ci_id not in trigger2completed.get(trigger.id, {})]) | ||
|
||
for tid in trigger2cis: | ||
trigger, cis = trigger2cis[tid] | ||
|
@@ -346,7 +352,7 @@ def cmdb_inner_secrets_init(address): | |
if valid_address(address): | ||
token = current_app.config.get("INNER_TRIGGER_TOKEN", "") if not token else token | ||
if not token: | ||
token = click.prompt(f'Enter root token', hide_input=True, confirmation_prompt=False) | ||
token = click.prompt('Enter root token', hide_input=True, confirmation_prompt=False) | ||
assert token is not None | ||
resp = requests.post("{}/api/v0.1/secrets/auto_seal".format(address.strip("/")), | ||
headers={"Inner-Token": token}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.