コード例 #1
0
ファイル: views.py プロジェクト: walidamer711/netops
def services(request):
    if request.method == 'POST':
        nr = start_nornir('mza-infra')
        form = DCAccessForm(request.POST)
        if form.is_valid():
            group = request.POST.get('domain')
            tenant = request.POST.get('tenant')
            site = request.POST.get('site')
            hosts = nr.filter(role=group, site=site)
            data_list = []
            if group == "dc-access":
                result = hosts.run(task=dc_access_template, tenant=tenant)
                for r in result:
                    data_list.append(result[r][1])
            elif group == "dc-aggregation":
                result = hosts.run(task=dc_agg_template, tenant=tenant)
                for r in result:
                    data_list.append(result[r][1])
                    data_list.append(result[r][2])
            return render(request, 'dashboard/dc_access_template.html',
                          {'data': data_list})
    else:
        form = DCAccessForm()

    return render(request, 'dashboard/services_config_list.html',
                  {'form': form})
コード例 #2
0
ファイル: checkview.py プロジェクト: walidamer711/netops
def check_dc_vlan(tenant, site):
    vlan_list = dc_join_vlans(tenant)
    command = "show vlan id {}".format(vlan_list)
    nr = start_nornir('mza-infra')
    hosts = nr.filter(F(vlandomain__label=site))
    result = hosts.run(task=networking.netmiko_send_command,
                       command_string=command)
    return result
コード例 #3
0
def main():
    infra = 'lab'
    tenant = 'ipam'
    site = 'gns3'
    nr = start_nornir(infra)
    h1 = nr.filter(role="dc-access", site=site)
    result = h1.run(task=dc_access_config, tenant=tenant)
    print_result(result)
コード例 #4
0
ファイル: wan_config.py プロジェクト: walidamer711/netops
def main():
    infra = 'lab'
    tenant = 'ipam'
    site = 'gns3'

    nr = start_nornir(infra)
    h2 = nr.filter(role="wan-router", site=site)
    result = h2.run(task=wan_pe_config, tenant=tenant)
    print_result(result)
コード例 #5
0
ファイル: dc_agg_config.py プロジェクト: walidamer711/netops
def main():
    infra = 'lab'
    tenant = 'ipam'
    site = 'gns3'

    nr = start_nornir(infra)
    h2 = nr.filter(role="dc-aggregation", site=site)
    #result = h2.run(task=int_agg_config, tenant=tenant)
    result = h2.run(task=show_command)
    print_result(result)
コード例 #6
0
def main():
    nr = start_nornir()

    h1 = nr.filter(role="dc-access", site="gns3")
    r1 = h1.run(task=dc_access_rollback, tenant="ipam")
    print_result(r1)
    h2 = nr.filter(role="dc-aggregation", site="gns3")
    r21 = h2.run(task=int_agg_rollback, tenant="ipam")
    print_result(r21)
    r22 = h2.run(task=dc_agg_rollback, tenant="ipam")
    print_result(r22)
    h3 = nr.filter(role="dc-fw", site="gns3")
    r3 = h3.run(task=dc_fw_rollback, tenant="ipam")
    print_result(r3)
コード例 #7
0
def main():
    #infra = 'mza-infra'
    #tenant = 'qlc'
    #site = 'mv2'
    infra = 'mza-infra'
    tenant = 'commvault'
    site = 'mv1'
    #infra = 'lab'
    #tenant = 'ipam'
    #site = 'gns3'
    nr = start_nornir(infra)
    h1 = nr.filter(role="dc-access", site=site)
    h1.run(task=dc_access_params, tenant=tenant)
    h2 = nr.filter(role="dc-aggregation", site=site)
    r2 = h2.run(task=dc_agg_params, tenant=tenant)
    print_result(r2)
    h3 = nr.filter(role="dc-fw", site=site)
    h3.run(task=dc_fw_params, tenant=tenant)
    noalias_dumper = yaml.dumper.SafeDumper
    noalias_dumper.ignore_aliases = lambda self, data: True
    with open(f'/home/wamer/netops/automation/files/{tenant}.yaml', 'w') as f:
        yaml.dump(data, f, default_flow_style=False, Dumper=noalias_dumper)