PR Commit for fmgr_device_provision_template. Contains bug fixes. (#58151)

pull/61170/head
Fortinet Core CSE NA 5 years ago committed by Nilashish Chakraborty
parent 55d1da08b1
commit 45cc29ba08

@ -66,7 +66,7 @@ options:
provision_targets: provision_targets:
description: description:
- The friendly names of devices in FortiManager to assign the provisioning template to. Comma separated list. - The friendly names of devices in FortiManager to assign the provisioning template to. CSV separated list.
required: True required: True
snmp_status: snmp_status:
@ -686,9 +686,9 @@ def set_devprof_scope(fmgr, paramgram):
} }
targets = [] targets = []
for target in paramgram["provision_targets"].strip().split(","): for target in paramgram["provision_targets"].split(","):
# split the host on the space to get the mask out # split the host on the space to get the mask out
new_target = {"name": target} new_target = {"name": target.strip()}
targets.append(new_target) targets.append(new_target)
datagram["scope member"] = targets datagram["scope member"] = targets
@ -1184,14 +1184,14 @@ def set_devprof_faz(fmgr, paramgram):
response = DEFAULT_RESULT_OBJ response = DEFAULT_RESULT_OBJ
datagram = { datagram = {
"target-ip": paramgram["admin_fortianalyzer_target"], "target-ip": paramgram["admin_fortianalyzer_target"],
"target": 4, "target": "others",
} }
url = "/pm/config/adom/{adom}" \ url = "/pm/config/adom/{adom}" \
"/devprof/{provisioning_template}" \ "/devprof/{provisioning_template}" \
"/device/profile/fortianalyzer".format(adom=adom, "/device/profile/fortianalyzer".format(adom=adom,
provisioning_template=paramgram["provisioning_template"]) provisioning_template=paramgram["provisioning_template"])
if paramgram["mode"] == "delete": if paramgram["mode"] == "delete":
datagram["hastarget"] = "True" datagram["hastarget"] = "False"
response = fmgr.process_request(url, datagram, paramgram["mode"]) response = fmgr.process_request(url, datagram, paramgram["mode"])
return response return response
@ -1457,7 +1457,6 @@ def main():
ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram)) ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram))
except Exception as err: except Exception as err:
raise FMGBaseException(err) raise FMGBaseException(err)
try: try:
# PROCESS THE ADMIN OPTIONS # PROCESS THE ADMIN OPTIONS
if any(v is not None for v in ( if any(v is not None for v in (
@ -1467,7 +1466,7 @@ def main():
paramgram["admin_gui_theme"])): paramgram["admin_gui_theme"])):
results = set_devprof_admin(fmgr, paramgram) results = set_devprof_admin(fmgr, paramgram)
fmgr.govern_response(module=module, results=results, good_codes=[0], fmgr.govern_response(module=module, results=results, good_codes=[0], stop_on_success=False,
ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram)) ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram))
except Exception as err: except Exception as err:
raise FMGBaseException(err) raise FMGBaseException(err)
@ -1494,7 +1493,7 @@ def main():
paramgram["smtp_source_ipv4"], paramgram["smtp_validate_cert"])): paramgram["smtp_source_ipv4"], paramgram["smtp_validate_cert"])):
results = set_devprof_smtp(fmgr, paramgram) results = set_devprof_smtp(fmgr, paramgram)
fmgr.govern_response(module=module, results=results, good_codes=[0], fmgr.govern_response(module=module, results=results, good_codes=[0], stop_on_success=False,
ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram)) ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram))
except Exception as err: except Exception as err:
raise FMGBaseException(err) raise FMGBaseException(err)
@ -1504,7 +1503,7 @@ def main():
if any(v is not None for v in if any(v is not None for v in
(paramgram["dns_suffix"], paramgram["dns_primary_ipv4"], paramgram["dns_secondary_ipv4"])): (paramgram["dns_suffix"], paramgram["dns_primary_ipv4"], paramgram["dns_secondary_ipv4"])):
results = set_devprof_dns(fmgr, paramgram) results = set_devprof_dns(fmgr, paramgram)
fmgr.govern_response(module=module, results=results, good_codes=[0], fmgr.govern_response(module=module, results=results, good_codes=[0], stop_on_success=False,
ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram)) ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram))
except Exception as err: except Exception as err:
raise FMGBaseException(err) raise FMGBaseException(err)
@ -1514,7 +1513,7 @@ def main():
if paramgram["admin_fortianalyzer_target"] is not None: if paramgram["admin_fortianalyzer_target"] is not None:
results = set_devprof_faz(fmgr, paramgram) results = set_devprof_faz(fmgr, paramgram)
fmgr.govern_response(module=module, results=results, good_codes=[0], fmgr.govern_response(module=module, results=results, good_codes=[0], stop_on_success=False,
ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram)) ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram))
except Exception as err: except Exception as err:
raise FMGBaseException(err) raise FMGBaseException(err)
@ -1524,7 +1523,7 @@ def main():
if paramgram["provision_targets"] is not None: if paramgram["provision_targets"] is not None:
if paramgram["mode"] != "delete": if paramgram["mode"] != "delete":
results = set_devprof_scope(fmgr, paramgram) results = set_devprof_scope(fmgr, paramgram)
fmgr.govern_response(module=module, results=results, good_codes=[0], fmgr.govern_response(module=module, results=results, good_codes=[0], stop_on_success=False,
ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram)) ansible_facts=fmgr.construct_ansible_facts(results, module.params, paramgram))
if paramgram["mode"] == "delete": if paramgram["mode"] == "delete":

Loading…
Cancel
Save