Skip to content

Commit

Permalink
Merge pull request #9 from southbridgeio/xml-import-detection-8
Browse files Browse the repository at this point in the history
Improve XML import file detecton (#8)
  • Loading branch information
evgkrsk authored May 6, 2021
2 parents 5f2a39a + 6694cb6 commit ddbad3c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions zabbix-import.py
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,10 @@ def import_template(zabbix, yml, group2groupid, template2templateid):
macros = []
for macro in new_template["macros"]["macro"]:
macros.append(
{"macro": macro["macro"], "value": macro["value"],}
{
"macro": macro["macro"],
"value": macro["value"],
}
)
else:
macros = ""
Expand Down Expand Up @@ -970,7 +973,10 @@ def import_usergroup(zabbix, yml, group2groupid, usergroup2usergroupid):
rights = []
for r in yml["rights"]:
rights.append(
{"id": group2groupid[r["id"]], "permission": r["permission"],}
{
"id": group2groupid[r["id"]],
"permission": r["permission"],
}
)
else:
rights = []
Expand Down Expand Up @@ -1486,6 +1492,9 @@ def main(
op_result = None

if "zabbix_export" in yml:
if "<?xml version=" in yml:
logging.error("There is not YAML file, but XML one: {}".format(yaml_file))
return None
logging.debug("Loading from XML-exported YAML")
xml_exported = True
yml = yml["zabbix_export"]
Expand Down

0 comments on commit ddbad3c

Please sign in to comment.