Exemplo n.º 1
0
def display_costs(project: Project, routers: Routers):
    for router in routers.values():
        conf = resolve_router_config(router)
        for intf in conf['interfaces']:
            try:
                cost = intf['ospf6_cost']
                for ri in router.interfaces:
                    ro_int: Interface = ri
                    if ro_int.name == intf['name']:
                        peer = ro_int.peer
                x = int((router.x * 1.5 + peer.x * 0.5) / 2)
                y = int((router.y * 1.5 + peer.y * 0.5) / 2)
                project.create_drawing(
                    svg=
                    f'<svg width="80" height="35">{MAGIC_SVG}<rect width="80" height="35" fill="#000000" fill-opacity="1.0"/></svg>',
                    x=x + 1,
                    y=y + 5,
                    locked=True)
                project.create_drawing(
                    svg=
                    f'<svg width=\"39\" height=\"30\"><!-- fait par le script --><text font-family=\"TypeWriter\" font-size=\"10.0\" font-weight=\"bold\" fill=\"#ffffff\" stroke=\"#afafe1\" stroke-width=\"100\" fill-opacity=\"1.0\">ospf6_cost\n  {cost}</text></svg>',
                    x=x,
                    y=y,
                    locked=True)
            except KeyError:
                continue
            except Exception as e:
                raise e
Exemplo n.º 2
0
def display_router_ids(project: Project, routers: Routers):
    # affiche les router-ids et les ASN
    for node in routers.values():
        x = node.x
        y = node.y + 10
        try:
            project.create_drawing(
                svg=
                f'<svg width="60" height="15">{MAGIC_SVG}<rect width="60" height="15" fill="#ffffff" fill-opacity="1.0"/></svg>',
                x=x,
                y=y,
                locked=True)
            project.create_drawing(
                svg=
                f'<svg width="100" height="15">{MAGIC_SVG}<text>{node.router_id}\n   {node.asn}</text></svg>',
                x=x,
                y=y - 4,
                locked=True)
        except AttributeError:  # des fois GNS3 est pas content
            pass
Exemplo n.º 3
0
def display_tracked_subnets(project: Project, liens: List[Lien]):
    # affiche les subnets entre routeurs
    for lien in liens:
        text = f"{lien.network4_display}"
        x = (lien.side_a.x + lien.side_b.x) // 2 - 25
        y = (lien.side_a.y + lien.side_b.y) // 2
        try:
            project.create_drawing(
                svg=
                f'<svg width="125" height="40">{MAGIC_SVG}<rect width="125" height="40" fill="#ffffff" fill-opacity="1.0" stroke-width="2" stroke="#000000"/></svg>',
                x=x,
                y=y,
                z=1,
                locked=True)
            project.create_drawing(
                svg=
                f'<svg width="39" height="30">{MAGIC_SVG}<text font-family="TypeWriter" font-size="10.0" font-weight="bold" fill="#346c59" stroke="#afafe1" stroke-width="100" fill-opacity="1.0">{text}\n</text>'
                + '</svg>',
                x=x,
                y=y,
                z=100,
                locked=True)
        except AttributeError:
            pass  # truc à la con de l'API gns3 qui arrive temps en temps