Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
EUDAT-TOOLS
SVMON
pysvmon
Commits
8e1962d8
Commit
8e1962d8
authored
Dec 03, 2021
by
Agustin Pane
Browse files
Merge branch 'fix/b2safe-issues' into 'development'
(Fix) - B2safe issues / operating system issues See merge request
!21
parents
8a5cce90
b4ce3e61
Changes
6
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
8e1962d8
...
...
@@ -28,5 +28,14 @@ PySVMON is a develoment project for SVMON client. It migrates bash-based client
You can check the current available list also using svmon --list-service-type command
## How to build and deploy pysvmon
1) Go to pysvmon folder
2) Update the svmon version in setup.py
3) Run
`python3 -m build`
4) Upload to python repository (credentials are needed):
*
Production:
`python3 -m twine upload dist/*`
*
Development/test:
`python3 -m twine upload --repository testpypi dist/*`
5) Then the new version will be available for instaling via pip:
*
Production:
`pip install svmon-client`
*
Development:
`pip install -i https://test.pypi.org/simple/ svmon-client`
setup.py
View file @
8e1962d8
...
...
@@ -4,7 +4,7 @@ from setuptools import setup
setup
(
name
=
'svmon-client'
,
version
=
'2.3.
2
'
,
version
=
'2.3.
3
'
,
packages
=
[
'svmon_client'
],
scripts
=
[
'svmon'
],
package_data
=
{
''
:
[
'*.json'
,
'*.pem'
]},
...
...
svmon
View file @
8e1962d8
...
...
@@ -128,7 +128,7 @@ def main(argv):
for
item
in
reports
:
print
(
item
)
else
:
print
(
"
reporting zer
o service components
in printing
"
)
print
(
"
N
o service components
found to report, skipping report...
"
)
exit
(
0
)
...
...
svmon_client/operating_system_parser.py
View file @
8e1962d8
...
...
@@ -8,10 +8,10 @@ def get_os_from_file():
# centos :
files
=
[
"/etc/redhat-release"
,
"/etc/centos-release"
,
"/etc/issue"
,
"/etc/os-release"
,
"/etc/SuSE-release"
,
"/etc/release"
]
res_str
=
""
ubuntuflag
=
0
ubuntu
_
flag
=
0
afile
=
""
for
afile
in
files
:
exist
=
os
.
path
.
exists
(
afile
)
exist
=
os
.
path
.
exists
(
afile
)
if
exist
:
f
=
open
(
afile
,
'r'
)
while
True
:
...
...
@@ -49,7 +49,7 @@ def get_os_from_file():
f
.
close
()
tmp
=
line
.
split
(
"
\"
"
)
return
text_processing
(
tmp
[
1
])
if
afile
==
"/etc/SuSE-release"
:
if
line
.
find
(
"openSUSE"
)
!=
-
1
or
line
.
find
(
"SLE"
)
!=-
1
:
f
.
close
()
...
...
@@ -62,8 +62,8 @@ def get_os_from_file():
print
(
"The operating system can not resolved"
)
exit
(
1
)
def
text_processing
(
input_text
):
if
input_text
==
None
or
isinstance
(
input_text
,
str
)
==
False
or
input_text
==
""
:
print
(
"wrong input for text processing in op parser"
)
...
...
svmon_client/report.py
View file @
8e1962d8
...
...
@@ -115,6 +115,7 @@ class SVMONReport:
exit
(
1
)
else
:
self
.
tags
=
services
.
get_service_tag
(
self
.
service_type
)
self
.
service_names
=
services
.
get_service_name
(
self
.
service_type
)
def
get_site
(
self
):
return
self
.
site
...
...
@@ -160,6 +161,9 @@ class SVMONReport:
this
.
tags
.
append
(
tag
)
def
print_report
(
self
):
enableDebug
=
self
.
config
[
"DEBUG_MODE"
]
if
(
enableDebug
):
print
(
'print_report called with services: '
,
self
.
service_names
)
if
len
(
self
.
service_names
)
>
0
:
res
=
[]
if
self
.
service_names
==
None
or
len
(
self
.
service_names
)
<
1
:
...
...
svmon_client/services.py
View file @
8e1962d8
...
...
@@ -51,7 +51,12 @@ def get_service_name(service_type):
def
get_service_tag
(
service_type
,
configs
=
None
):
print
(
"Get service tag called... with service type: "
,
service_type
)
config
=
remoteConfig
.
RemoteConfig
().
getConfig
()
enableDebug
=
config
[
"DEBUG_MODE"
]
if
(
enableDebug
):
print
(
"Get service tag called... with service type: "
,
service_type
)
tags
=
[]
if
service_type
==
None
or
service_type
==
""
or
isinstance
(
service_type
,
str
)
==
False
:
print
(
"The service type argument should be a non-empty string"
)
...
...
@@ -68,6 +73,8 @@ def get_service_tag(service_type,configs=None):
elif
service_type
==
"gitlab"
:
tmp
=
get_by_rpm_packages
(
"gitlab"
,
0
,
1
)
if
(
enableDebug
):
print
(
'get_service_tag for gitlab result: '
,
tmp
)
if
tmp
==
None
or
tmp
==
''
or
tmp
.
find
(
'Failed'
)
>-
1
:
print
(
"no gitlab version can be resolved"
)
exit
(
1
)
...
...
@@ -76,16 +83,22 @@ def get_service_tag(service_type,configs=None):
elif
service_type
==
"b2safe"
:
tmp
=
get_by_rpm_packages
(
"b2safe"
)
if
(
enableDebug
):
print
(
'get_service_tag for b2safe result: '
,
tmp
)
if
tmp
==
""
:
print
(
"no b2safe version can be resolved"
)
exit
(
1
)
tags
.
append
(
tmp
)
tmp
=
get_by_rpm_packages
(
"irods-server"
)
if
(
enableDebug
):
print
(
'get_service_tag for irods-server result: '
+
tmp
)
if
tmp
!=
None
and
tmp
!=
''
and
tmp
.
find
(
'Failed'
)
==
-
1
:
tags
.
append
(
tmp
)
return
tags
tmp
=
get_by_rpm_packages
(
"irods-icat"
)
if
(
enableDebug
):
print
(
'get_service_tag for irods-icat result: '
+
tmp
)
if
tmp
!=
None
and
tmp
!=
''
and
tmp
.
find
(
'Failed'
)
==
-
1
:
tags
.
append
(
tmp
)
return
tags
...
...
@@ -117,8 +130,12 @@ def get_service_tag(service_type,configs=None):
# for package version that can be accessed via rpm management
def
get_by_rpm_packages
(
software
,
start
=
0
,
end
=
0
):
config
=
remoteConfig
.
RemoteConfig
().
getConfig
()
enableDebug
=
config
[
"DEBUG_MODE"
]
if
(
enableDebug
):
print
(
'Get_by_rpm_packages for software: '
+
software
)
if
isinstance
(
software
,
str
)
==
False
or
software
==
""
or
software
==
None
:
print
(
"
s
oftware name should be a non-empty string"
)
print
(
"
S
oftware name should be a non-empty string"
)
exit
(
1
)
if
isinstance
(
start
,
int
)
==
False
or
isinstance
(
end
,
int
)
==
False
:
print
(
"The input of indices should be integers to fetch correct version,"
)
...
...
@@ -126,12 +143,17 @@ def get_by_rpm_packages(software,start=0,end=0):
tmp
=
subprocess
.
Popen
(
"rpm -qa"
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
)
tmp
=
subprocess
.
Popen
(
'grep '
+
software
,
shell
=
True
,
stdin
=
tmp
.
stdout
,
stdout
=
subprocess
.
PIPE
)
tmp
=
tmp
.
communicate
()
if
(
enableDebug
):
print
(
'Get_by_rpm_packages final rpm-qa before parse result: '
,
tmp
)
tmp
=
tmp
[
0
]
if
tmp
==
None
or
tmp
==
""
:
return
"Failed, no rpm packages can be found for "
+
software
if
tmp
==
None
or
tmp
==
""
:
print
(
'Failed, no rpm packages can be found for '
,
software
)
return
''
ind
=
tmp
.
find
(
software
)
ind
=
ind
+
len
(
software
)
ltmp
=
tmp
[
ind
+
1
:
len
(
tmp
)].
split
(
'-'
)
if
(
enableDebug
):
print
(
'Get_by_rpm_packages final ltmp test result: '
,
ltmp
)
if
len
(
ltmp
)
>
end
:
if
start
==
end
:
...
...
@@ -142,16 +164,17 @@ def get_by_rpm_packages(software,start=0,end=0):
res
=
res
+
ltmp
[
i
]
return
res
else
:
return
"Failed, the start index should be smaller than end index for a correct rpm package resolver"
print
(
'Failed, the start index should be smaller than end index for a correct rpm package resolver'
)
return
''
else
:
return
"Failed,"
+
software
+
" version not resolved"
print
(
"Failed,"
+
software
+
" version not resolved"
)
return
''
def
get_user
():
tmp
=
subprocess
.
Popen
(
"whoami"
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
)
tmp
=
tmp
.
communicate
()
return
tmp
[
0
].
replace
(
'
\n
'
,
''
)
def
get
():
tags
=
get_service_tag
(
"svmon_client"
)
return
tags
[
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment