Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
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
Harbor 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
dCache
cta
Commits
ef380823
Commit
ef380823
authored
12 years ago
by
Sebastien Ponce
Browse files
Options
Downloads
Patches
Plain Diff
added handling of comments in parsing of NSCONFIG for python tools
parent
d7d996bf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hsmtools/castor_tools.py
+19
-15
19 additions, 15 deletions
hsmtools/castor_tools.py
with
19 additions
and
15 deletions
hsmtools/castor_tools.py
+
19
−
15
View file @
ef380823
...
...
@@ -226,21 +226,25 @@ def getVdqmDBConnectParams():
#-------------------------------------------------------------------------------
def
getNSDBConnectParam
(
filename
):
'''
Gets the connection parameters for nameserver like DBs from the given config file
'''
line
=
open
(
'
/etc/castor/
'
+
filename
).
readline
()
line
=
line
[
0
:
len
(
line
)
-
1
]
#drop trailing \n
sl
=
line
.
find
(
'
/
'
)
if
sl
==
-
1
:
raise
ValueError
,
'
Invalid connection string in /etc/castor/NSCONFIG
'
ar
=
line
.
find
(
'
@
'
,
sl
)
if
ar
==
-
1
:
raise
ValueError
,
'
Invalid connection string in /etc/castor/NSCONFIG
'
user
=
line
[
0
:
sl
]
passwd
=
line
[
sl
+
1
:
ar
]
dbname
=
line
[
ar
+
1
:]
_checkValueFound
(
"
user name
"
,
user
,
'
nameserver
'
,
file
)
_checkValueFound
(
"
password
"
,
passwd
,
'
nameserver
'
,
file
)
_checkValueFound
(
"
DB name
"
,
dbname
,
'
nameserver
'
,
file
)
return
user
,
passwd
,
dbname
for
rawline
in
open
(
'
/etc/castor/
'
+
filename
).
readlines
():
# ignore empty and commented lines
line
=
rawline
.
strip
()
if
len
(
line
)
==
0
or
line
[
0
]
==
'
#
'
:
continue
sl
=
line
.
find
(
'
/
'
)
if
sl
==
-
1
:
raise
ValueError
,
'
Invalid connection string in /etc/castor/NSCONFIG :
"
%s
"'
%
line
ar
=
line
.
find
(
'
@
'
,
sl
)
if
ar
==
-
1
:
raise
ValueError
,
'
Invalid connection string in /etc/castor/NSCONFIG :
"
%s
"'
%
line
user
=
line
[
0
:
sl
]
passwd
=
line
[
sl
+
1
:
ar
]
dbname
=
line
[
ar
+
1
:]
_checkValueFound
(
"
user name
"
,
user
,
'
nameserver
'
,
file
)
_checkValueFound
(
"
password
"
,
passwd
,
'
nameserver
'
,
file
)
_checkValueFound
(
"
DB name
"
,
dbname
,
'
nameserver
'
,
file
)
return
user
,
passwd
,
dbname
raise
ValueError
,
'
empty config file /etc/castor/NSCONFIG
'
#-------------------------------------------------------------------------------
# connectTo_ methods
...
...
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