Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FoD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Schmitz
FoD
Commits
a75818c3
Commit
a75818c3
authored
2 years ago
by
David Schmitz
Browse files
Options
Downloads
Patches
Plain Diff
status: add status/fodtest_netconf_get for manual testing of NETCONF/XML fetching
parent
d69f3604
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
status/fodtest_netconf_get
+115
-0
115 additions, 0 deletions
status/fodtest_netconf_get
with
115 additions
and
0 deletions
status/fodtest_netconf_get
0 → 100755
+
115
−
0
View file @
a75818c3
#!/bin/bash
use_netconf_settings
=
0
old_version
=
0
parsed
=
0
while
[
$#
-gt
0
]
;
do
if
[
"
$1
"
=
"--raw"
]
;
then
shift
1
parsed
=
0
elif
[
"
$1
"
=
"--parsed"
]
;
then
shift
1
parsed
=
1
elif
[
"
$1
"
=
"--old_version"
]
;
then
shift
1
old_version
=
1
elif
[
"
$1
"
=
"--use_netconf_settings"
]
;
then
shift
1
use_netconf_settings
=
1
else
break
fi
done
#
NETCONF_DEVICE
=
"
$1
"
shift
1
NETCONF_PORT
=
"
$1
"
shift
1
NETCONF_USER
=
"
$1
"
shift
1
NETCONF_PASS
=
"
$1
"
shift
1
##
[
-n
"
$NETCONF_DEVICE
"
]
||
NETCONF_DEVICE
=
"127.0.0.1"
[
-n
"
$NETCONF_PORT
"
]
||
NETCONF_PORT
=
"830"
[
-n
"
$NETCONF_USER
"
]
||
NETCONF_USER
=
"netconf"
[
-n
"
$NETCONF_PASS
"
]
||
NETCONF_PASS
=
"netconf"
echo
"
$0
: using NETCONF_DEVICE='
$NETCONF_DEVICE
' NETCONF_PORT='
$NETCONF_PORT
' NETCONF_USER='
$NETCONF_USER
' NETCONF_PASS='
$NETCONF_PASS
'"
1>&2
##
unset
SSH_AUTH_SOCK
##
.
./venv/bin/activate
##
#exec env DJANGO_SETTINGS_MODULE="flowspy.settings" python -c $'\nfrom utils.proxy import *; \nproxy = Applier(); import logging; logger = logging.getLogger("ncclient.transport.ssh").setLevel(logging.DEBUG); logger = logging.getLogger("ncclient.operations.rpc").setLevel(logging.DEBUG); \nxml = proxy.get_existing_config_xml();\nprint(xml);\n'
##
export
DJANGO_SETTINGS_MODULE
=
"flowspy.settings"
exec
python
<<
EOF
# enable debugging in ncclient library
import logging;
logger = logging.getLogger("ncclient.transport.ssh").setLevel(logging.DEBUG);
logger = logging.getLogger("ncclient.operations.rpc").setLevel(logging.DEBUG);
###
from django.conf import settings;
# override flowspy settings to enable debugging
settings.LEVEL = logging.DEBUG; # override flowspy/settings.py
settings.LOG_FILE_LOCATION = "." #
# override flowspy NETCONF parameters with local values
# check further NETCONF_* variables in flowspec/settings.py, if needed
if not
$use_netconf_settings
:
settings.NETCONF_DEVICE = '
$NETCONF_DEVICE
'; # override flowspy/settings.py
settings.NETCONF_PORT = '
$NETCONF_PORT
'; # override flowspy/settings.py
settings.NETCONF_USER = '
$NETCONF_USER
'; # override flowspy/settings.py
settings.NETCONF_PASS = '
$NETCONF_PASS
'; # override flowspy/settings.py
# for testing with freertr for now
settings.NETCONF__TESTWISE_TRY_TO_FETCH_WITHOUT_FILTER = 1; # override flowspy/settings.py
###
# actually perform NETCONF get-config query and print result
from utils.proxy import *;
if
$old_version
:
if
$parsed
:
retriever = Retriever();
device = retriever.fetch_device();
result = device.routing_options[0].routes
print(result);
else:
applier = Applier();
result = applier.get_existing_config_xml();
print(result);
else:
retriever = PR0.Retriever();
if
$parsed
:
result = retriever.retrieve_current_routes();
print(result);
else:
result = retriever.fetch_raw();
print(result);
EOF
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment