Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tango Images
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LOFAR2.0
Tango Images
Commits
4742ba55
Commit
4742ba55
authored
4 years ago
by
user
Browse files
Options
Downloads
Patches
Plain Diff
AT1-709
: Resolve review comment- Address pylint warnings.
parent
a02bad89
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
charts/archiver/data/configure_hdbpp.py
+54
-38
54 additions, 38 deletions
charts/archiver/data/configure_hdbpp.py
with
54 additions
and
38 deletions
charts/archiver/data/configure_hdbpp.py
+
54
−
38
View file @
4742ba55
"
Script to configure hdbpp archiver
"
#Imports
#Imports
import
sys
,
getopt
import
sys
import
getopt
import
json
import
json
from
tango
import
DeviceProxy
,
DevFailed
,
AttributeProxy
from
time
import
sleep
from
time
import
sleep
import
os
import
os
from
tango
import
DeviceProxy
,
DevFailed
,
AttributeProxy
def
cm_configure_attributes
():
def
cm_configure_attributes
():
"""
Method to configure an attribute.
"""
configure_success_count
=
0
configure_success_count
=
0
configure_fail_count
=
0
configure_fail_count
=
0
already_configured_count
=
0
already_configured_count
=
0
total_attrib_count
=
0
total_attrib_count
=
0
attribute_started_count
=
0
attribute_started_count
=
0
error_starting_attrib_count
=
0
error_starting_attrib_count
=
0
with
open
(
attr_list_file
,
'
r
'
)
as
attrib_list_file
:
with
open
(
ATTR_LIST_FILE
,
'
r
'
)
as
attrib_list_file
:
configuration_blocks
=
json
.
load
(
attrib_list_file
)
configuration_blocks
=
json
.
load
(
attrib_list_file
)
for
cb
in
configuration_blocks
:
for
c
_
b
in
configuration_blocks
:
attribute_list
=
cb
[
'
attributes
'
]
attribute_list
=
c
_
b
[
'
attributes
'
]
polling_period
=
cb
[
'
polling_period
'
]
polling_period
=
c
_
b
[
'
polling_period
'
]
period_event
=
cb
[
'
period_event
'
]
period_event
=
c
_
b
[
'
period_event
'
]
for
attribute
in
attribute_list
:
for
attribute
in
attribute_list
:
total_attrib_count
+=
1
total_attrib_count
+=
1
...
@@ -31,7 +34,9 @@ def cm_configure_attributes():
...
@@ -31,7 +34,9 @@ def cm_configure_attributes():
print
(
"
Attribute
"
+
attribute
+
"
already configured.
"
)
print
(
"
Attribute
"
+
attribute
+
"
already configured.
"
)
is_already_archived
=
True
is_already_archived
=
True
already_configured_count
+=
1
already_configured_count
+=
1
attribute_started_count
,
error_starting_attrib_count
=
start_archiving
(
attribute
,
attribute_started_count
,
error_starting_attrib_count
)
attribute_started_count
,
error_starting_attrib_count
=
\
start_archiving
(
attribute
,
attribute_started_count
,
error_starting_attrib_count
)
break
break
if
not
is_already_archived
:
if
not
is_already_archived
:
...
@@ -39,30 +44,33 @@ def cm_configure_attributes():
...
@@ -39,30 +44,33 @@ def cm_configure_attributes():
max_retries
=
5
max_retries
=
5
sleep_time
=
1
sleep_time
=
1
not_online
=
False
not_online
=
False
for
x
in
range
(
0
,
max_retries
):
for
loop_cnt
in
range
(
0
,
max_retries
):
try
:
try
:
att
=
AttributeProxy
(
attribute_fqdn
)
att
=
AttributeProxy
(
attribute_fqdn
)
att
.
read
()
att
.
read
()
break
break
except
DevFailed
as
d
f
:
except
DevFailed
as
d
ev_failed
:
if
(
x
==
(
max_retries
-
1
)
)
:
if
loop_cnt
==
(
max_retries
-
1
):
print
(
"
Attribute
"
+
attribute
+
"
not online. Skipping it.
"
)
print
(
"
Attribute
"
+
attribute
+
"
not online. Skipping it.
"
)
not_online
=
True
not_online
=
True
break
break
print
(
"
DevFailed exception:
"
+
str
(
df
.
args
[
0
].
reason
)
+
"
. Sleeping for
"
+
str
(
sleep_time
)
+
"
ss
"
)
print
(
"
DevFailed exception:
"
+
str
(
dev_failed
.
args
[
0
].
reason
)
+
"
. Sleeping for
"
+
str
(
sleep_time
)
+
"
ss
"
)
sleep
(
sleep_time
)
sleep
(
sleep_time
)
if
(
not_online
)
:
if
not_online
:
continue
continue
try
:
try
:
conf_manager_proxy
.
write_attribute
(
"
SetAttributeName
"
,
attribute_fqdn
)
conf_manager_proxy
.
write_attribute
(
"
SetAttributeName
"
,
attribute_fqdn
)
conf_manager_proxy
.
write_attribute
(
"
SetArchiver
"
,
evt_subscriber_device_fqdn
)
conf_manager_proxy
.
write_attribute
(
"
SetArchiver
"
,
EVT_SUBSCRIBER_DEVICE_FQDN
)
conf_manager_proxy
.
write_attribute
(
"
SetStrategy
"
,
"
ALWAYS
"
)
conf_manager_proxy
.
write_attribute
(
"
SetStrategy
"
,
"
ALWAYS
"
)
conf_manager_proxy
.
write_attribute
(
"
SetPollingPeriod
"
,
int
(
polling_period
))
conf_manager_proxy
.
write_attribute
(
"
SetPollingPeriod
"
,
int
(
polling_period
))
conf_manager_proxy
.
write_attribute
(
"
SetPeriodEvent
"
,
int
(
period_event
))
conf_manager_proxy
.
write_attribute
(
"
SetPeriodEvent
"
,
int
(
period_event
))
except
Exception
as
except_occured
:
except
Exception
as
except_occured
:
print
(
"
Exception while setting configuration manager arrtibutes:
"
,
except_occured
)
print
(
"
Exception while setting configuration manager arrtibutes:
"
,
except_occured
)
configure_fail_count
+=
1
configure_fail_count
+=
1
continue
continue
...
@@ -70,14 +78,17 @@ def cm_configure_attributes():
...
@@ -70,14 +78,17 @@ def cm_configure_attributes():
conf_manager_proxy
.
AttributeAdd
()
conf_manager_proxy
.
AttributeAdd
()
configure_success_count
+=
1
configure_success_count
+=
1
print
(
"
attribute_fqdn
"
+
attribute_fqdn
+
"
"
+
"
added successfuly
"
)
print
(
"
attribute_fqdn
"
+
attribute_fqdn
+
"
"
+
"
added successfuly
"
)
except
DevFailed
as
d
f
:
except
DevFailed
as
d
ev_failed
:
configure_fail_count
+=
1
configure_fail_count
+=
1
print
(
"
Exception occured while adding attribute for archiving:
"
,
df
)
print
(
"
Exception occured while adding attribute for archiving:
"
,
dev_failed
)
return
configure_success_count
,
configure_fail_count
,
already_configured_count
,
total_attrib_count
,
attribute_started_count
,
error_starting_attrib_count
return
configure_success_count
,
configure_fail_count
,
already_configured_count
,
\
total_attrib_count
,
attribute_started_count
,
error_starting_attrib_count
def
start_archiving
(
str_attribute
,
attribute_started_count
,
error_starting_attrib_count
):
def
start_archiving
(
str_attribute
,
attribute_started_count
,
error_starting_attrib_count
):
"""
Method to start archiving an attribute.
"""
try
:
try
:
conf_manager_proxy
.
command_inout
(
"
AttributeStart
"
,
str_attribute
)
conf_manager_proxy
.
command_inout
(
"
AttributeStart
"
,
str_attribute
)
attribute_started_count
+=
1
attribute_started_count
+=
1
...
@@ -88,9 +99,9 @@ def start_archiving(str_attribute, attribute_started_count, error_starting_attri
...
@@ -88,9 +99,9 @@ def start_archiving(str_attribute, attribute_started_count, error_starting_attri
return
attribute_started_count
,
error_starting_attrib_count
return
attribute_started_count
,
error_starting_attrib_count
# Main entrypoint of the script.
# Main entrypoint of the script.
conf_manager_device_fqdn
=
""
CONF_MANAGER_DEVICE_FQDN
=
""
evt_subscriber_device_fqdn
=
""
EVT_SUBSCRIBER_DEVICE_FQDN
=
""
attr_list_file
=
""
ATTR_LIST_FILE
=
""
## parse arguments
## parse arguments
try
:
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"
c:e:a:
"
,
[
"
cm=
"
,
"
es=
"
,
"
attrfile=
"
])
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
"
c:e:a:
"
,
[
"
cm=
"
,
"
es=
"
,
"
attrfile=
"
])
...
@@ -105,39 +116,44 @@ except getopt.GetoptError:
...
@@ -105,39 +116,44 @@ except getopt.GetoptError:
sys
.
exit
(
2
)
sys
.
exit
(
2
)
for
opt
,
arg
in
opts
:
for
opt
,
arg
in
opts
:
if
opt
in
(
"
-c
"
,
"
--cm
"
):
if
opt
in
(
"
-c
"
,
"
--cm
"
):
conf_manager_device_fqdn
=
arg
CONF_MANAGER_DEVICE_FQDN
=
arg
elif
opt
in
(
"
-e
"
,
"
--es
"
):
elif
opt
in
(
"
-e
"
,
"
--es
"
):
evt_subscriber_device_fqdn
=
arg
EVT_SUBSCRIBER_DEVICE_FQDN
=
arg
elif
opt
in
(
"
-a
"
,
"
--attrfile
"
):
elif
opt
in
(
"
-a
"
,
"
--attrfile
"
):
attr_list_file
=
arg
ATTR_LIST_FILE
=
arg
conf_manager_proxy
=
DeviceProxy
(
conf_manager_device_fqdn
)
conf_manager_proxy
=
DeviceProxy
(
CONF_MANAGER_DEVICE_FQDN
)
evt_subscriber_proxy
=
DeviceProxy
(
evt_subscriber_device_fqdn
)
evt_subscriber_proxy
=
DeviceProxy
(
EVT_SUBSCRIBER_DEVICE_FQDN
)
sleep_time
=
6
SLEEP_TIME
=
6
max_retries
=
10
MAX_RETRIES
=
10
for
x
in
range
(
0
,
max_retries
):
for
x
in
range
(
0
,
MAX_RETRIES
):
try
:
try
:
configure_success_count
,
configure_fail_count
,
already_configured_count
,
total_attrib_count
,
attribute_started_count
,
error_starting_attrib_count
=
cm_configure_attributes
()
configure_success_count
,
configure_fail_count
,
already_configured_count
,
\
print
(
"
Configured successfully:
"
,
configure_success_count
,
"
Failed:
"
,
configure_fail_count
,
"
Already configured:
"
,
total_attrib_count
,
attribute_started_count
,
error_starting_attrib_count
=
\
already_configured_count
,
"
Total attributes:
"
,
total_attrib_count
,
"
Attribute started:
"
,
attribute_started_count
,
cm_configure_attributes
()
print
(
"
Configured successfully:
"
,
configure_success_count
,
"
Failed:
"
,
configure_fail_count
,
"
Already configured:
"
,
already_configured_count
,
"
Total attributes:
"
,
total_attrib_count
,
"
Attribute started:
"
,
attribute_started_count
,
"
Error starting attribute:
"
,
error_starting_attrib_count
)
"
Error starting attribute:
"
,
error_starting_attrib_count
)
break
break
except
:
except
:
print
(
"
configure_attribute exception:
"
+
str
(
sys
.
exc_info
()))
print
(
"
configure_attribute exception:
"
+
str
(
sys
.
exc_info
()))
if
(
x
==
(
max_retries
-
1
)
)
:
if
x
==
(
MAX_RETRIES
-
1
):
sys
.
exit
(
-
1
)
sys
.
exit
(
-
1
)
try
:
try
:
deviceAdm
=
DeviceProxy
(
"
dserver/hdbppcm-srv/01
"
)
DEVICE_ADM
=
None
deviceAdm
.
RestartServer
()
DEVICE_ADM
=
DeviceProxy
(
"
dserver/hdbppcm-srv/01
"
)
DEVICE_ADM
.
RestartServer
()
except
:
except
:
print
(
"
reset_conf_manager exception:
"
+
str
(
sys
.
exc_info
()[
0
]))
print
(
"
reset_conf_manager exception:
"
+
str
(
sys
.
exc_info
()[
0
]))
sleep
(
sleep_time
)
sleep
(
SLEEP_TIME
)
if
configure_fail_count
>
0
:
if
configure_fail_count
>
0
:
exit
(
-
1
)
sys
.
exit
(
-
1
)
evt_subscriber_proxy
.
Start
()
evt_subscriber_proxy
.
Start
()
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