Coder Social home page Coder Social logo

network-interfaces's Introduction

network-interfaces

Python library for representing and manipulating the /etc/network/interfaces

TODO:

network-interfaces's People

Contributors

mehrdad1373pedramfar avatar moojanabolhassani avatar plieningerweb avatar pylover avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

network-interfaces's Issues

No such file or directory: '/etc/network/interfaces.d/*' while file is interfaces

Traceback (most recent call last):
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/application.py", line 64, in __call__
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     response_body = self.__root__(*remaining_paths)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/restfulpy/controllers.py", line 18, in __call__
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return super().__call__(*remaining_paths)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/controllers.py", line 83, in __call__
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return self._serve_handler(handler, remaining_paths)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/controllers.py", line 78, in _serve_handler
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return handler(*remaining_paths, **kwargs)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/controllers.py", line 83, in __call__
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return self._serve_handler(handler, remaining_paths)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/controllers.py", line 78, in _serve_handler
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return handler(*remaining_paths, **kwargs)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/controllers.py", line 83, in __call__
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return self._serve_handler(handler, remaining_paths)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/controllers.py", line 78, in _serve_handler
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return handler(*remaining_paths, **kwargs)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/controllers.py", line 83, in __call__
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return self._serve_handler(handler, remaining_paths)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/controllers.py", line 78, in _serve_handler
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return handler(*remaining_paths, **kwargs)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/nanohttp/decorators.py", line 52, in wrapper
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     result = func(*args, **kwargs)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/restfulpy/authorization.py", line 21, in wrapper
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return func(*args, **kwargs)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/ursa/ursa/controllers/interface.py", line 40, in get
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     interface = self.ensure_default_interface()
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/ursa/ursa/controllers/interface.py", line 31, in ensure_default_interface
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     interfaces = interfaces or self.ensure_interfaces()
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/ursa/ursa/controllers/interface.py", line 28, in ensure_interfaces
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     return InterfacesFile(settings.network.interfaces_file)
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/network_interfaces/interface_file.py", line 71, in __init__
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     self.sub_files.append(InterfacesFile(subfile[0], source=subfile[1]))
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:   File "/usr/local/lib/python3.6/site-packages/network_interfaces/interface_file.py", line 37, in __init__
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]:     with open(self.absolute_filename) as f:
Feb  1 19:14:58 sandbox-ubuntu gunicorn[1871]: FileNotFoundError: [Errno 2] No such file or directory: '/etc/network/interfaces.d/*'
Feb  1 19:15:01 sandbox-ubuntu CRON[2067]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)

find_iface() does not look up interface

A correct implementation should have been something like:

def find_iface(self, name):
    result = [iface for iface in self.interfaces + self.mappings if iface.name == name]
    return result[0] if result else None

Validation

Validation the interfaces file.
And auto correcting based on ipcalc.

Tests fails with import error.

# python ./tests/test_interfaces.py
Traceback (most recent call last):
  File "./tests/test_interfaces.py", line 6, in <module>
    from network_interfaces import InterfacesFile, Auto, Allow, ValidationError
ImportError: cannot import name ValidationError

Where ValidationError should have been defined?

Describe how to add enty to interfaces file.

It would be really convinient if sample, how to add new interface definition to existing file will be provided.

I came to a following solution:

new_iface = Iface
new_iface.name = 'eth4'

new_iface.method = 'static'
new_iface.address_family = 'inet'
new_iface.address = '1.2.3.4'
new_iface.netmask = '255.0.0.0'
new_iface.gateway = '4.3.2.1'
new_iface.startup = Allow

f1 = InterfacesFile('/etc/network/interfaces2')
f1.interfaces.append(new_iface)

f1.save()

Whicth is obviously do not work - there is only <class 'network_interfaces.iface.Iface'> in result file.

Test fails on removal of network interface

Tests fail for revision ee2d666 or the master branch

# python test_interfaces.py
..F
======================================================================
FAIL: test_validate (__main__.NetworkingCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_interfaces.py", line 144, in test_validate
    self.assertRaises(ValidationError, eth0.validate)
AssertionError: ValidationError not raised

----------------------------------------------------------------------
Ran 3 tests in 0.013s

FAILED (failures=1)

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.