Skip to content

Commit ddbad3c

Browse files
authoredMay 6, 2021
Merge pull request #9 from southbridgeio/xml-import-detection-8
Improve XML import file detecton (#8)
2 parents 5f2a39a + 6694cb6 commit ddbad3c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed
 

‎zabbix-import.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,10 @@ def import_template(zabbix, yml, group2groupid, template2templateid):
915915
macros = []
916916
for macro in new_template["macros"]["macro"]:
917917
macros.append(
918-
{"macro": macro["macro"], "value": macro["value"],}
918+
{
919+
"macro": macro["macro"],
920+
"value": macro["value"],
921+
}
919922
)
920923
else:
921924
macros = ""
@@ -970,7 +973,10 @@ def import_usergroup(zabbix, yml, group2groupid, usergroup2usergroupid):
970973
rights = []
971974
for r in yml["rights"]:
972975
rights.append(
973-
{"id": group2groupid[r["id"]], "permission": r["permission"],}
976+
{
977+
"id": group2groupid[r["id"]],
978+
"permission": r["permission"],
979+
}
974980
)
975981
else:
976982
rights = []
@@ -1486,6 +1492,9 @@ def main(
14861492
op_result = None
14871493

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

0 commit comments

Comments
 (0)
Please sign in to comment.