def sys_fw_config(task, tenant): #trunks = device_trunks(f'{task.host.name}', "agg") interfaces = dc_fw_prefixes(tenant) intf_status = False for intf in interfaces: r = task.run( task=networking.netmiko_send_command, name="Loading Configuration on the device", command_string="changeto system\n show interface Port-channel11.{}" .format(intf["vlan_id"])) if "ERROR" not in r.result: intf_status = True break print(intf_status) # Transform inventory data to configuration via a template file r = task.run(task=text.template_file, name="Base Configuration", template="sys_fw.j2", path=f"/home/wamer/netops/automation/templates/cisco", interfaces=interfaces, cust=tenant) task.host["config"] = r.result task.run(task=networking.netmiko_send_config, name="Loading Configuration on the device", config_commands=task.host["config"])
def dc_fw_params(task, tenant): trunks = device_trunks(f'{task.host.name}', "agg") interfaces = dc_fw_prefixes(tenant) pat_ip = get_pat_ip(tenant) temp = {} temp['trunks'] = trunks temp['interfaces'] = interfaces temp['pat_ip'] = pat_ip data[task.host.name] = temp
def dc_fw_rollback(task, tenant): trunks = device_trunks(f'{task.host.name}', "agg") interafces = dc_fw_prefixes(tenant) # Transform inventory data to configuration via a template file r = task.run(task=text.template_file, name="Rollback Configuration", template="dc_fw.j2", path=f"/home/wamer/netops/automation/templates/rollback", interfaces=interafces, trunk=trunks[0]) task.host["config"] = r.result task.run(task=networking.netmiko_send_config, name="Loading Rollback Configuration on the device", config_commands=task.host["config"])
def dc_fw_config(task, tenant): trunks = device_trunks(f'{task.host.name}', "agg") interfaces = dc_fw_prefixes(tenant) pat_ip = get_pat_ip(tenant) r = task.run(task=text.template_file, name="Base Configuration", template="dc_fw.j2", path=f"/home/wamer/netops/automation/templates/cisco", interfaces=interfaces, trunk=trunks[0], cust=tenant, site=task.host['site'], pat_ip=pat_ip) task.host["config"] = r.result task.run(task=networking.netmiko_send_config, name="Loading Configuration on the device", config_commands=task.host["config"])