Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
opennsa3
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
Michal Hažlinský
opennsa3
Commits
2f06d536
Commit
2f06d536
authored
13 years ago
by
Henrik Thostrup Jensen
Browse files
Options
Downloads
Patches
Plain Diff
add config.py module (forgot to add previously)
parent
2bab4482
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
opennsa/config.py
+56
-0
56 additions, 0 deletions
opennsa/config.py
with
56 additions
and
0 deletions
opennsa/config.py
0 → 100644
+
56
−
0
View file @
2f06d536
"""
Configuration reader and defaults.
Author: Henrik Thostrup Jensen <htj@nordu.net>
Copyright: NORDUnet (2011)
"""
import
ConfigParser
# defaults
DEFAULT_CONFIG_FILE
=
'
/etc/opennsa.conf
'
DEFAULT_LOG_FILE
=
'
/var/log/opennsa.log
'
DEFAULT_TOPOLOGY_FILE
=
'
/usr/share/nsi/topology.owl
'
DEFAULT_WSDL_DIRECTORY
=
'
/usr/share/nsi/wsdl
'
DEFAULT_TCP_PORT
=
9080
DEFAULT_TLS_PORT
=
9443
DEFAULT_VERIFY
=
'
true
'
# config blocks and options
BLOCK_SERVICE
=
'
service
'
BLOCK_DUD
=
'
dud
'
BLOCK_JUNOS
=
'
junos
'
BLOCK_ARGIA
=
'
argia
'
# service block
CONFIG_NETWORK_NAME
=
'
network
'
# mandatory
CONFIG_HOST
=
'
host
'
CONFIG_PORT
=
'
port
'
CONFIG_TOPOLOGY_FILE
=
'
topology
'
CONFIG_WSDL_DIRECTORY
=
'
wsdl
'
CONFIG_HOSTKEY
=
'
hostkey
'
# mandatory
CONFIG_HOSTCERT
=
'
hostcert
'
# mandatory
CONFIG_CERTIFICATE_DIR
=
'
certdir
'
# mandatory (but dir can be empty)
CONFIG_VERIFY
=
'
verify
'
def
readConfig
(
filename
):
cfg
=
ConfigParser
.
SafeConfigParser
()
# add defaults, only section so far
cfg
.
add_section
(
BLOCK_SERVICE
)
cfg
.
set
(
BLOCK_SERVICE
,
CONFIG_LOG_FILE
,
DEFAULT_LOG_FILE
)
cfg
.
set
(
BLOCK_SERVICE
,
CONFIG_TOPOLOGY_FILE
,
DEFAULT_TOPOLOGY_FILE
)
cfg
.
set
(
BLOCK_SERVICE
,
CONFIG_WSDL_DIRECTORY
,
DEFAULT_WSDL_DIRECTORY
)
cfg
.
set
(
BLOCK_SERVICE
,
CONFIG_VERIFY
,
DEFAULT_VERIFY
)
cfg
.
read
(
[
filename
]
)
return
cfg
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