Giter VIP home page Giter VIP logo

netman's Introduction

Build Status Documentation Status PyPI version

Netman

Netman is a unified REST API that provides vendor-agnostic network automation. It abstracts the vendor-specific bits and leaves you with a clean and simplified API.

Python code usage

switch_factory = SwitchFactory(MemoryStorage(), ThreadingLockFactory())
switch = switch_factory.get_anonymous_switch(
    model="cisco", 
    hostname="hostname_or_ip", 
    username="username", 
    password="password", 
)

switch.add_vlan(1000, name="myvlan")

REST API usage

First, start the service

tox
.tox/py27/bin/python netman/main.py
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Then you can access it by http

curl -X POST http://127.0.0.1:5000/switches/hostname_or_ip/vlans -d '{"number": 1000, "name": "myvlan"}' 
    -H "Content-Type: application/json" 
    -H "Netman-model: cisco" 
    -H "Netman-username: username" 
    -H "Netman-password: password"

Disaggregated mode

Netman supports a disaggregated mode. This is a special mode of operation where netman will use a remote netman server to access the network equipment. This mode is particularly useful in the case where your network equipment is not available to your main netman server. You can start a server somewhere, let's say at 192.168.1.1, running netman as described above. And use the proxy like this for direct code usage :

switch_factory = SwitchFactory(MemoryStorage(), ThreadingLockFactory())
switch = switch_factory.get_anonymous_switch(
    model="cisco", 
    hostname="hostname_or_ip", 
    username="username", 
    password="password", 
    netman_server="http://192.168.1.1")

switch.add_vlan(1000, name="myvlan")

Or when invoked using the REST API, you can call the main server and provide the proxy netman server to be used.

curl -X POST http://127.0.0.1:5000/switches/hostname_or_ip/vlans -d '{"number": 1000, "name": "myvlan"}' 
    -H "Content-Type: application/json" 
    -H "Netman-model: cisco" 
    -H "Netman-username: username" 
    -H "Netman-password: password"
    -H "Netman-Proxy-Server: http://192.168.1.1"

Docker usage

From your computer, start a Netman container and a fake-switch container in order to mock a switch Netman will configure.

$ docker-compose up -d

Create a Vlan

curl -X POST http://localhost:32771/switches/netman_tsr1.yul1.example.net_1/vlans -d '{"number": 1000, "name": "myvlan"}' 
    -H "Content-Type: application/json" 
    -H "Netman-model: cisco" 
    -H "Netman-username: root" 
    -H "Netman-password: root"

Get information of an existing Vlan

curl -X GET http://localhost:32771/switches/netman_tsr1.yul1.example.net_1/vlans/1000 
    -H "Content-Type: application/json" 
    -H "Netman-model: cisco" 
    -H "Netman-username: root" 
    -H "Netman-password: root"

Contributing

Feel free to raise issues and send some pull request, we'll be happy to look at them!

netman's People

Contributors

cptcloud avatar emmurd avatar fbouliane avatar fguillot avatar glonlas avatar godp1301 avatar idjaw avatar joprovost avatar lhopps avatar lindycoder avatar marx314 avatar mat128 avatar maxc0c0s avatar mlecours avatar simon-begin avatar staz003 avatar stephanerobert avatar vilnitsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netman's Issues

Brocade list interface is too slow

Doing show interface takes longer than the the amount of time paramiko waits so it fails expecting a prompt.

Let's find a better way to do this

Auto-fix cisco 3750 ghost address bug

I stumbled upon a bug on the cisco 3750.

Sometimes you try to add an ip address to an interfave vlan, it's gonna tell you that it is already assigned to another vlan, you show that vlan's config and it's empty.
To solve : assign the ip to the other vlan, and remove it again and then everything works

It would be AWESOME if netman could handle this bug and make it seems seamless.

Don't know how to reproduce though, here's an example:

SWITCH(config)#int vlan 200
SWITCH(config-if)#ip address 1.1.1.1 255.255.255.248
% 1.1.1.1 is assigned as a secondary address on Vlan300
SWITCH(config-if)#do show run int vlan 300
Building configuration...

Current configuration : 236 bytes
!
interface Vlan300
 description XXXX
 no ip address
 no ip redirects
 no ip unreachables
 no ip proxy-arp
 load-interval 30
end

SWITCH(config-if)#int vlan 300
SWITCH(config-if)#ip address 1.1.1.1 255.255.255.248
SWITCH(config-if)#no ip address 1.1.1.1 255.255.255.248
SWITCH(config-if)#int vlan 200                             
SWITCH(config-if)#ip address 1.1.1.1 255.255.255.248   

... worked!

Cisco switchport mode trunk is missing a command

As tested on a physical switch, when setting an interface on trunk mode, we need to call: switchport trunk encapsulation dot1q

co-dr2.staging(config-if)#switchport mode trunk
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
co-dr2.staging(config-if)#switchport trunk encapsulation dot1q
co-dr2.staging(config-if)#switchport mode trunk
co-dr2.staging(config-if)#

Brocade always enabling interface vlans

On any operation on an interface vlan, brocade enables it.

That was originally to work around them being disabled by default, but it's clearly a problem if your interface vlan is shutdown and you want to modify it with bringing it up

Licensing header issue

The per-file header license is hard to keep up-to-date and pollutes diff. The license's year of modification should not be a burden. The exact timestamp and author of modification is tracked using git anyway.
I think we should remove those License headers in our open-source project.

Is there anyone against the removal of those headers ?

Interesting talks on the subject :

A test for multi proxy

A test using a real double proxy should be writen

The proposed way is to launch a netman in the tests and use it as a proxy in a call to the actual flask test

Juniper configuration-less ports are not in the interfaces list

A juniper with no configuration on a port will not show it when querying interfaces via the netconf protocol

So the /interfaces should look for an official list

There is a CLI command : show interfaces terse
That will show all interfaces names, we need to find how to do it the netconf-way

Get vlans timeout when too many vlans exists.

Getting the vlans on a router that have many vlans will ultimately timeout after 5 minutes. Since netman is only relying on the prompt to determine if a command is done, the router may still be outputting the vlans while netmans pulls the plugs.

Netman could look if there are new characters incoming in the buffer before calling it quits.

Juniper interfaces names contain new lines

This is fairly new... here's a sample of the return of the /interfaces on a Juniper

{
"access_vlan": null,
"trunk_vlans": [],
"bond_master": null,
"trunk_native_vlan": null,
"shutdown": false,
"port_mode": "access",
"name": "\nae0\n"
},

Lock should be acquired before connecting

actually the connect to the switch is made before acquiring the lock, this means if 10 sessions opens on a switch with max 5 connections, even though we have a lock, we'll fail.

This mecanism has to be rethought

Werkzeug data vs get_data

Werkzeug will deprecate the request's data attribute soon in favor of the get_data method. When including netman in a project that has an older version of werkzeug, the get_data method is not found.

Netman should support pagination

We saw Netman wait forever when we display an interface configuration and the uplink port channel is huge.

Command

show running-config interface port-channel 10

CoS

  • Netman doesn't wait forever when the switch asks to hit a key to continue the pagination

Missing compliance tests / nomenclature violations

The following methods have been identified as violating the nomenclature guidelines. Proper compliance tests for those would help us move forward.

$ grep 'TODO' -A1 netman/core/objects/switch_base.py
    # TODO(mmitchell): Should be called unset_access_vlan
    def remove_access_vlan(self, interface_id):
--
    # TODO(mmitchell): Should be called set_interface_state
    def shutdown_interface(self, interface_id):
--
    # TODO(mmitchell): Should be part of set_interface_state
    def openup_interface(self, interface_id):
--
    # TODO(mmitchell): Should be called set_native_vlan
    def configure_native_vlan(self, interface_id, vlan):
--
    # TODO(mmitchell): Should be called unset_native_vlan
    def remove_native_vlan(self, interface_id):
--
    # TODO(mmitchell): Should be called unset_vlan_access_group
    def remove_vlan_access_group(self, vlan_number, direction):
--
    # TODO(mmitchell): Should be called unset_vlan_vrf
    def remove_vlan_vrf(self, vlan_number):
--
    # TODO(mmitchell): Should be called unset_interface_description
    def remove_interface_description(self, interface_id):
--
    # TODO(mmitchell): Should be called set_interface_spanning_tree_state
    def edit_interface_spanning_tree(self, interface_id, edge=None):
--
    # TODO(mmitchell): Should be called unset_bond_description
    def remove_bond_description(self, number):
--
    # TODO(mmitchell): Should be called set_bond_native_vlan
    def configure_bond_native_vlan(self, number, vlan):
--
    # TODO(mmitchell): Should be called unset_bond_native_vlan
    def remove_bond_native_vlan(self, number):
--
    # TODO(mmitchell): Should be called set_bond_interface_spanning_tree_state
    def edit_bond_spanning_tree(self, number, edge=None):
--
    # TODO(mmitchell): Should be called set_interface_lldp_state
    def enable_lldp(self, interface_id, enabled):

Allow using netman without installing lxml

Currently, netman depends on ncclient and pulls lxml when installing. This is problematic because lxml often has to be compiled. Additionally, the version of lxml used (3.6.1) clashes with Ubuntu Xenial's packaged version (3.5.0). This library is useless when using netman to access switches other than Juniper models.

A workaround is to specify lxml at the same time as installing netman (or a package requiring netman), as such:
pip install lxml==3.5.0 netman
When doing so, pip honors the specific request for lxml and skips the version requirement for netman.

Using the extra dependencies (https://www.python.org/dev/peps/pep-0508/#extras) or different packages for switch model support (that could all use a "core" netman) would be extremely beneficial for external usage.

Brocade vlan tagged lists

Some brocade use ethe 1/1 in the tagged directive when configuring a vlan and some use only e 1/1

we should support both

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.