diff --git a/main.py b/main.py index 78d2799..d26f237 100755 --- a/main.py +++ b/main.py @@ -118,16 +118,32 @@ class Switch: def apply_conf_hp(self): """Apply config restore via rest""" url_restore = "http://" + self.switch["ipv4"] + "/rest/v4/system/config/cfg_restore" - data = { - "server_type": "ST_TFTP", - "file_name": self.get_conf_file_name(), - "tftp_server_address": { - "server_address": { - "ip_address": { - "version":"IAV_IP_V4", - "octets":self.settings["switchs_management_interface_ip"]}}}, - "is_forced_reboot_enabled": True, - } + provision_mode = self.settings["switchs_provision"] + if provision_mode == "tftp": + data = { + "server_type": "ST_TFTP", + "file_name": self.get_conf_file_name(), + "tftp_server_address": { + "server_address": { + "ip_address": { + "version":"IAV_IP_V4", + "octets":self.settings["switchs_management_interface_ip"]}}}, + "is_forced_reboot_enabled": True, + } + elif provision_mode == "sftp": + data = { + "server_type": "ST_SFTP", + "file_name": self.get_conf_file_name(), + "tftp_server_address": { + "server_address": { + "ip_address": { + "version":"IAV_IP_V4", + "octets":self.settings["switchs_management_interface_ip"]}}, + "user_name": self.settings["switchs_management_sftp_creds"]["login"], + "password": self.settings["switchs_management_sftp_creds"]["pass"], + }, + "is_forced_reboot_enabled": True, + } # Nous lançons la requête de type POST. post_restore = requests.post(url_restore, data=json.dumps(data), headers=self.headers) diff --git a/templates/hp.tpl b/templates/hp.tpl index ce50cf5..cff6914 100644 --- a/templates/hp.tpl +++ b/templates/hp.tpl @@ -62,8 +62,6 @@ vlan {{ id }} {%- for ipv6, subnet6 in vlan.ipv6.items() %} ipv6 address {{ ipv6 }}/{{ subnet6.netmask_cidr }} {%- endfor %} - {%- else %} - no ipv6 address {%- if id in additionals.igmp_vlans %} no ip igmp querier {%- endif %}