-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,559 additions
and
898 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
usr/lib*/python*/*-packages/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
Format: 3.0 (quilt) | ||
Source: @PACKAGE_NAME@ | ||
Binary: @PACKAGE_NAME@, @PACKAGE_NAME@-dbg, @PACKAGE_NAME@-dev | ||
Binary: @PACKAGE_NAME@, @PACKAGE_NAME@-dbg, @PACKAGE_NAME@-dev, python3-netconf2@COMPAT_PACKAGES@, python3-netconf2@COMPAT_PACKAGES@-dbg | ||
Maintainer: CESNET <[email protected]> | ||
Version: @LIBNETCONF2_VERSION@ | ||
Architecture: any | ||
Standards-Version: 3.8.2 | ||
Homepage: https://github.com/CESNET/libnetconf2 | ||
Vcs-Git: https://github.com/CESNET/libnetconf2 | ||
Build-Depends: debhelper (>= 9), make, gcc, cmake, pkg-config, libcmocka-dev, libyang@COMPAT_PACKAGES@-dev, libssh-dev (>= 0.7.1), openssl | ||
Build-Depends: debhelper (>= 9), make, gcc, cmake, pkg-config, libcmocka-dev, libyang@COMPAT_PACKAGES@-dev, libssh-dev (>= 0.7.1), openssl, python3-dev (>= 3.4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ Source: %{url}/archive/@[email protected] | |
License: BSD-3-Clause | ||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} | ||
|
||
Requires: libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@ = %{version}-%{release} | ||
Requires: libyang@COMPAT_PACKAGES@ | ||
BuildRequires: libyang@COMPAT_PACKAGES@-devel | ||
BuildRequires: libssh-devel >= 0.7.1 | ||
BuildRequires: openssl-devel | ||
|
@@ -18,32 +18,37 @@ BuildRequires: gcc | |
%if 0%{?suse_version} | ||
BuildRequires: timezone | ||
%endif | ||
Conflicts: @CONFLICT_PACKAGE_NAME@ | ||
|
||
%package -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@ | ||
Summary: Libnetconf2 library | ||
Requires: libyang@COMPAT_PACKAGES@ | ||
Requires: %{name} = %{version}-%{release} | ||
%if 0%{?suse_version} + 0%{?fedora} > 0 | ||
BuildRequires: python3-devel | ||
%else | ||
BuildRequires: python34-devel | ||
%endif | ||
Conflicts: @CONFLICT_PACKAGE_NAME@ | ||
|
||
%package devel | ||
Summary: Headers of libnetconf2 library | ||
Requires: %{name} = %{version}-%{release} | ||
Requires: libssh-devel | ||
|
||
%description -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@ | ||
Libnetconf2 is a NETCONF library in C intended for building NETCONF clients and servers. | ||
%package -n python3-netconf2@COMPAT_PACKAGES@ | ||
Summary: Bindings to python3 | ||
Requires: %{name} = %{version}-%{release} | ||
|
||
%description devel | ||
Headers of libnetconf2 library. | ||
|
||
%description -n python3-netconf2@COMPAT_PACKAGES@ | ||
Bindings of libnetconf2 library to python3 language. | ||
|
||
%description | ||
Libnetconf2 is a NETCONF library in C intended for building NETCONF clients and servers. | ||
|
||
%prep | ||
%setup -n libnetconf2-@BRANCH@ | ||
|
||
%build | ||
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -D CMAKE_BUILD_TYPE:String="@BUILD_TYPE@" -D ENABLE_VALGRIND_TESTS:BOOL=FALSE . | ||
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE:String="@BUILD_TYPE@" -DENABLE_PYTHON=ON -DENABLE_VALGRIND_TESTS:BOOL=FALSE . | ||
make | ||
|
||
%check | ||
|
@@ -52,17 +57,15 @@ ctest --output-on-failure | |
%install | ||
make DESTDIR=%{buildroot} install | ||
|
||
%post -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@ -p /sbin/ldconfig | ||
%post -p /sbin/ldconfig | ||
|
||
%postun -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@ -p /sbin/ldconfig | ||
%postun -p /sbin/ldconfig | ||
|
||
%files | ||
%{_datadir}/libnetconf2/* | ||
%dir %{_datadir}/libnetconf2/ | ||
|
||
%files -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@ | ||
%defattr(-,root,root) | ||
%{_libdir}/libnetconf2.so.* | ||
%{_datadir}/libnetconf2/* | ||
%dir %{_datadir}/libnetconf2/ | ||
|
||
%files devel | ||
%defattr(-,root,root) | ||
|
@@ -73,4 +76,8 @@ make DESTDIR=%{buildroot} install | |
%{_includedir}/nc_server.h | ||
%dir %{_includedir}/libnetconf2/ | ||
|
||
%files -n python3-netconf2@COMPAT_PACKAGES@ | ||
%defattr(-,root,root) | ||
/usr/lib*/python*/*-packages/* | ||
|
||
%changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,9 @@ cp build-packages/debian.control debian/control | |
echo '9' >debian/compat | ||
echo '3.0 (quilt)' >debian/source/format | ||
cp "@PROJECT_SOURCE_DIR@/LICENSE" debian/copyright | ||
cp "@PROJECT_SOURCE_DIR@/packages/debian.libnetconf2.install" debian/@[email protected] | ||
cp "@PROJECT_SOURCE_DIR@/packages/debian.libnetconf2-dev.install" debian/@[email protected] | ||
cp "@PROJECT_SOURCE_DIR@/packages/debian.libnetconf2-experimental.install" debian/@[email protected] | ||
cp "@PROJECT_SOURCE_DIR@/packages/debian.libnetconf2-experimental-dev.install" debian/@[email protected] | ||
cp "@PROJECT_SOURCE_DIR@/packages/debian.python3-netconf2-experimental.install" debian/python3-netconf2@[email protected] | ||
echo -e "@PACKAGE_NAME@ (@LIBNETCONF2_VERSION@) stable; urgency=low\n" >debian/changelog | ||
git log -10 --pretty=format:' * %s (%aN)%n' 2>/dev/null >>debian/changelog || echo -e " * unknown changes \n" >>debian/changelog | ||
git log -1 --pretty=format:'%n -- %aN <%aE> %aD%n' >>debian/changelog 2>/dev/null || echo " -- ${USER} <${USER}@`hostname`> `date -R`" >>debian/changelog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/python3 | ||
|
||
import sys | ||
import os | ||
import getpass | ||
import json | ||
import yang | ||
import netconf2 as nc | ||
|
||
def interactive_auth(name, instruct, prompt, data): | ||
print(name) | ||
return getpass.getpass(prompt) | ||
|
||
def password_auth(user, host, data): | ||
return getpass.getpass((user if user else os.getlogin()) + '@' + host + ' password : ') | ||
|
||
def hostkey_check(hostname, state, keytype, hexa, priv): | ||
return True | ||
|
||
# | ||
# get know where to connect | ||
# | ||
host = input("hostname: ") | ||
try: | ||
port = int(input("port : ")) | ||
except: | ||
port = 0; | ||
user = input("username: ") | ||
|
||
# | ||
# set SSH settings | ||
# | ||
if user: | ||
ssh = nc.SSH(username=user) | ||
else: | ||
ssh = nc.SSH() | ||
ssh.setAuthInteractiveClb(interactive_auth) | ||
ssh.setAuthPasswordClb(password_auth) | ||
ssh.setAuthHostkeyCheckClb(hostkey_check) | ||
|
||
# | ||
# create NETCONF session to the server | ||
# | ||
try: | ||
session = nc.Session(host, port, ssh) | ||
except Exception as e: | ||
print(e) | ||
sys.exit(1) | ||
|
||
# prepare config content as string or data tree | ||
tm = session.context.get_module("turing-machine") | ||
# config = "<turing-machine xmlns=\"http://example.net/turing-machine\"><transition-function><delta><label>left summand</label><input><state>0</state></input></delta></transition-function></turing-machine>" | ||
config = yang.Data_Node(session.context, "/turing-machine:turing-machine/transition-function/delta[label='left summand']/input/state", "5", 0, 0) | ||
|
||
# perform <edit-config> and print result | ||
try: | ||
session.rpcEditConfig(nc.DATASTORE_RUNNING, config) | ||
except nc.ReplyError as e: | ||
reply = {'success':False, 'error': []} | ||
for err in e.args[0]: | ||
reply['error'].append(json.loads(str(err))) | ||
print(json.dumps(reply)) | ||
sys.exit(1) | ||
|
||
# print(data.print_mem(ly.LYD_XML, ly.LYP_FORMAT | ly.LYP_WITHSIBLINGS)) |
Oops, something went wrong.