Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
FofbTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DG
FOFB
FofbTool
Commits
0e0a0ee1
Commit
0e0a0ee1
authored
Jun 6, 2024
by
BRONES Romain
Browse files
Options
Downloads
Patches
Plain Diff
feat(force): Allow force action in Utils and CLI
parent
7f800c7b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
FofbTool/Utils.py
+19
-15
19 additions, 15 deletions
FofbTool/Utils.py
scripts/FofbTool
+10
-14
10 additions, 14 deletions
scripts/FofbTool
with
29 additions
and
29 deletions
FofbTool/Utils.py
+
19
−
15
View file @
0e0a0ee1
...
...
@@ -15,13 +15,13 @@ import FofbTool.Operation
# Get the module logger
logger
=
logging
.
getLogger
(
"
FofbTool
"
)
def
init_opcua
():
def
init_opcua
(
force
=
False
):
"""
Run init on all OPCUA devices. Catch DevFailed and inform via log.
Does nothing if Fofb is running.
"""
if
not
check_fofbnotrunning
():
if
not
check_fofbnotrunning
(
force
):
logger
.
warning
(
"
Not running configuration of combpm because FOFB seems to be running.
"
)
return
...
...
@@ -33,13 +33,13 @@ def init_opcua():
logger
.
error
(
"
Could not perform init()
'
{}
'
, got DevFailed.
"
.
format
(
p
))
logger
.
debug
(
str
(
e
))
def
init_watcher
():
def
init_watcher
(
force
=
False
):
"""
Run init on Fofb-Watcher, waiting for its completion then init on the FofbCommand.
Does nothing if Fofb is running.
"""
if
not
check_fofbnotrunning
():
if
not
check_fofbnotrunning
(
force
):
logger
.
warning
(
"
Not running configuration of combpm because FOFB seems to be running.
"
)
return
...
...
@@ -89,7 +89,7 @@ def confds_opcua():
logger
.
debug
(
str
(
e
))
def
check_fofbnotrunning
():
def
check_fofbnotrunning
(
force
=
False
):
"""
Check if the FOFB is not running.
If it fails to know, return False and log error.
...
...
@@ -100,6 +100,10 @@ def check_fofbnotrunning():
True if FOFB is not running
"""
if
force
:
logger
.
warning
(
"
Forced action even if FOFB might be running
"
)
return
True
p
=
FofbTool
.
Configuration
.
config
[
"
tangopath
"
][
"
fofb-watcher
"
]
try
:
prx
=
tango
.
DeviceProxy
(
p
)
...
...
@@ -115,7 +119,7 @@ def check_fofbnotrunning():
logger
.
debug
(
str
(
e
))
return
False
def
conf_all_combpm
():
def
conf_all_combpm
(
force
=
False
):
"""
Run default configuration of all combpm blocks.
Check beforehand that the FOFB is not running.
...
...
@@ -126,7 +130,7 @@ def conf_all_combpm():
True if FOFB is not running
"""
if
not
check_fofbnotrunning
():
if
not
check_fofbnotrunning
(
force
):
logger
.
warning
(
"
Not running configuration of combpm because FOFB seems to be running.
"
)
return
False
...
...
@@ -139,7 +143,7 @@ def conf_all_combpm():
return
success
def
conf_all_comcorr
(
enable
=
True
):
def
conf_all_comcorr
(
force
=
False
,
enable
=
True
):
"""
Run default configuration of all comcorr blocks.
Check beforehand that the FOFB is not running.
...
...
@@ -155,7 +159,7 @@ def conf_all_comcorr(enable=True):
True if FOFB is not running
"""
if
not
check_fofbnotrunning
():
if
not
check_fofbnotrunning
(
force
):
logger
.
warning
(
"
Not running configuration of comcorr because FOFB seems to be running.
"
)
return
False
...
...
@@ -168,7 +172,7 @@ def conf_all_comcorr(enable=True):
return
success
def
conf_all_ccn
():
def
conf_all_ccn
(
force
=
False
):
"""
Run default configuration of all comcellnode blocks.
Check beforehand that the FOFB is not running.
...
...
@@ -179,7 +183,7 @@ def conf_all_ccn():
True if FOFB is not running
"""
if
not
check_fofbnotrunning
():
if
not
check_fofbnotrunning
(
force
):
logger
.
warning
(
"
Not running configuration of comcorr because FOFB seems to be running.
"
)
return
False
...
...
@@ -224,14 +228,14 @@ def get_prx_from_nodename(nodename):
return
prx
def
stop_all_combpm
():
def
stop_all_combpm
(
force
=
False
):
"""
Apply stop command on all Cellnodes.
Check beforehand that the FOFB is not running. Display warning if.
"""
if
not
check_fofbnotrunning
():
if
not
check_fofbnotrunning
(
force
):
logger
.
warning
(
"
Not running stop combpm because FOFB seems to be running.
"
)
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath.fofbnodes
"
].
items
():
...
...
@@ -239,14 +243,14 @@ def stop_all_combpm():
FofbTool
.
Operation
.
stop_combpm
(
n
)
def
stop_all_ccn
():
def
stop_all_ccn
(
force
=
False
):
"""
Apply stop and reset commands on all fofbnodes.
Check beforehand that the FOFB is not running. Display warning if.
"""
if
not
check_fofbnotrunning
():
if
not
check_fofbnotrunning
(
force
):
logger
.
warning
(
"
Not running stop combpm because FOFB seems to be running.
"
)
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath.fofbnodes
"
].
items
():
...
...
This diff is collapsed.
Click to expand it.
scripts/FofbTool
+
10
−
14
View file @
0e0a0ee1
...
...
@@ -86,35 +86,31 @@ if __name__ == '__main__':
## Check running
if
not
FofbTool
.
Utils
.
check_fofbnotrunning
():
logger
.
warning
(
"
FOFB is running
"
)
if
not
args
.
force
:
logger
.
warning
(
"
Stoping here
"
)
if
not
FofbTool
.
Utils
.
check_fofbnotrunning
(
force
=
args
.
force
):
logger
.
warning
(
"
FOFB is running, Stopping here
"
)
exit
(
1
)
else
:
logger
.
warning
(
"
Action forced
"
)
## Device Server related commands
if
args
.
DS_init_opcua
:
FofbTool
.
Utils
.
init_opcua
()
FofbTool
.
Utils
.
init_opcua
(
force
=
args
.
force
)
if
args
.
DS_init_watcher
:
FofbTool
.
Utils
.
init_watcher
()
FofbTool
.
Utils
.
init_watcher
(
force
=
args
.
force
)
if
args
.
DS_conf
:
FofbTool
.
Utils
.
confds_opcua
()
if
args
.
stop
or
args
.
stop_combpm
:
FofbTool
.
Utils
.
stop_all_combpm
()
FofbTool
.
Utils
.
stop_all_combpm
(
force
=
args
.
force
)
if
args
.
stop
or
args
.
stop_ccn
:
FofbTool
.
Utils
.
stop_all_ccn
()
FofbTool
.
Utils
.
stop_all_ccn
(
force
=
args
.
force
)
if
args
.
configure
in
(
"
combpm
"
,
"
all
"
):
FofbTool
.
Utils
.
conf_all_combpm
()
FofbTool
.
Utils
.
conf_all_combpm
(
force
=
args
.
force
)
if
args
.
configure
in
(
"
comcorr
"
,
"
all
"
):
FofbTool
.
Utils
.
conf_all_comcorr
()
FofbTool
.
Utils
.
conf_all_comcorr
(
force
=
args
.
force
)
if
args
.
configure
in
(
"
ccn
"
,
"
all
"
):
FofbTool
.
Utils
.
conf_all_ccn
()
FofbTool
.
Utils
.
conf_all_ccn
(
force
=
args
.
force
)
if
args
.
configure
in
(
"
corr
"
,
"
all
"
):
FofbTool
.
Configuration
.
centralnode_configure_corr
()
...
...
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