Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open 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
Show more breadcrumbs
LOFAR2.0
tango
Commits
9670e449
Commit
9670e449
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Plain Diff
Merge branch '
L2SS-550
-fix-archiver-config-install' into 'master'
L2SS-550
: Install archiver config Closes
L2SS-550
See merge request
!202
parents
b547c733
5847e826
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!202
L2SS-550: Install archiver config
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tangostationcontrol/setup.cfg
+4
-0
4 additions, 0 deletions
tangostationcontrol/setup.cfg
tangostationcontrol/tangostationcontrol/toolkit/archiver.py
+14
-36
14 additions, 36 deletions
tangostationcontrol/tangostationcontrol/toolkit/archiver.py
with
18 additions
and
36 deletions
tangostationcontrol/setup.cfg
+
4
−
0
View file @
9670e449
...
@@ -57,3 +57,7 @@ console_scripts =
...
@@ -57,3 +57,7 @@ console_scripts =
l2ss-random-data
=
tangostationcontrol.test.devices.random_data:main
l2ss-random-data
=
tangostationcontrol.test.devices.random_data:main
l2ss-snmp
=
tangostationcontrol.examples.snmp.snmp:main
l2ss-snmp
=
tangostationcontrol.examples.snmp.snmp:main
l2ss-version
=
tangostationcontrol.common.lofar_version:main
l2ss-version
=
tangostationcontrol.common.lofar_version:main
[options.package_data]
*
=
*.json
This diff is collapsed.
Click to expand it.
tangostationcontrol/tangostationcontrol/toolkit/archiver.py
+
14
−
36
View file @
9670e449
...
@@ -6,6 +6,7 @@ from tango import DeviceProxy, AttributeProxy, DevState, DevFailed
...
@@ -6,6 +6,7 @@ from tango import DeviceProxy, AttributeProxy, DevState, DevFailed
import
time
import
time
import
json
,
os
import
json
,
os
import
pkg_resources
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
...
@@ -82,10 +83,10 @@ class Archiver():
...
@@ -82,10 +83,10 @@ class Archiver():
"""
"""
# Global 'DEVELOPMENT' environment variables set by configuration file
# Global 'DEVELOPMENT' environment variables set by configuration file
dev_polling_time
=
None
dev_polling_time
=
600
dev_archive_time
=
None
dev_archive_time
=
3600
def
__init__
(
self
,
selector_filename
:
str
=
None
,
cm_name
:
str
=
'
archiving/hdbppts/confmanager01
'
,
context
:
str
=
'
RUN
'
):
def
__init__
(
self
,
cm_name
:
str
=
'
archiving/hdbppts/confmanager01
'
,
context
:
str
=
'
RUN
'
):
self
.
cm_name
=
cm_name
self
.
cm_name
=
cm_name
self
.
cm
=
DeviceProxy
(
cm_name
)
self
.
cm
=
DeviceProxy
(
cm_name
)
try
:
try
:
...
@@ -95,11 +96,6 @@ class Archiver():
...
@@ -95,11 +96,6 @@ class Archiver():
raise
Exception
(
f
"
Connection failed with Configuration Manager
{
cm_name
}
"
)
from
e
raise
Exception
(
f
"
Connection failed with Configuration Manager
{
cm_name
}
"
)
from
e
self
.
es_list
=
[
es_name
for
es_name
in
self
.
get_subscribers
(
from_db
=
False
)]
self
.
es_list
=
[
es_name
for
es_name
in
self
.
get_subscribers
(
from_db
=
False
)]
self
.
cm
.
write_attribute
(
'
Context
'
,
context
)
# Set default Context Archiving for all the subscribers
self
.
cm
.
write_attribute
(
'
Context
'
,
context
)
# Set default Context Archiving for all the subscribers
self
.
selector
=
Selector
()
if
selector_filename
is
None
else
Selector
(
selector_filename
)
# Create selector for customized strategies
try
:
self
.
apply_selector
()
except
Exception
as
e
:
raise
Exception
(
"
Error in selecting configuration. Archiving framework will not be updated.
"
)
from
e
def
get_db_config
(
self
,
device_name
:
str
)
->
dict
:
def
get_db_config
(
self
,
device_name
:
str
)
->
dict
:
"""
"""
...
@@ -152,11 +148,15 @@ class Archiver():
...
@@ -152,11 +148,15 @@ class Archiver():
min_es
=
min
(
load_dict
,
key
=
load_dict
.
get
)
min_es
=
min
(
load_dict
,
key
=
load_dict
.
get
)
return
min_es
return
min_es
def
apply_selector
(
self
):
def
get_configuration
(
self
,
resource
:
str
=
'
lofar2
'
)
->
dict
:
"""
Read an archiver configuration from one of the preinstalled resources in archiver_config.
"""
resource
=
pkg_resources
.
resource_stream
(
__name__
,
f
'
archiver_config/
{
resource
}
.json
'
)
return
json
.
load
(
resource
)
def
apply_configuration
(
self
,
config_dict
:
dict
):
"""
"""
Apply the customized strategy defined by the
selector
Apply the customized strategy defined by the
given archiver configuration.
"""
"""
config_dict
=
self
.
selector
.
get_dict
()
# Set global development env variables
# Set global development env variables
var_dict
=
config_dict
.
get
(
'
global_variables
'
)
var_dict
=
config_dict
.
get
(
'
global_variables
'
)
self
.
dev_polling_time
=
int
(
var_dict
.
get
(
'
development_polling_time
'
))
self
.
dev_polling_time
=
int
(
var_dict
.
get
(
'
development_polling_time
'
))
...
@@ -191,7 +191,6 @@ class Archiver():
...
@@ -191,7 +191,6 @@ class Archiver():
logger
.
warning
(
f
"
Device
{
device
}
not defined in TangoDB
"
)
logger
.
warning
(
f
"
Device
{
device
}
not defined in TangoDB
"
)
else
:
else
:
raise
Exception
from
e
raise
Exception
from
e
return
env_dict
def
add_event_subscriber
(
self
,
es_name
:
str
=
None
):
def
add_event_subscriber
(
self
,
es_name
:
str
=
None
):
"""
"""
...
@@ -454,24 +453,3 @@ class AttributeFormatException(Exception):
...
@@ -454,24 +453,3 @@ class AttributeFormatException(Exception):
def
__init__
(
self
,
message
=
"
Wrong Tango attribute format! Try: domain/family/member/attribute (e.g. STAT/RECV/1/temperature)
"
):
def
__init__
(
self
,
message
=
"
Wrong Tango attribute format! Try: domain/family/member/attribute (e.g. STAT/RECV/1/temperature)
"
):
self
.
message
=
message
self
.
message
=
message
super
().
__init__
(
self
.
message
)
super
().
__init__
(
self
.
message
)
class
Selector
():
"""
The Selector class implements operations on select customized retrieval strategies
"""
def
__init__
(
self
,
filename
=
'
lofar2.json
'
):
self
.
filename
=
filename
def
get_dict
(
self
):
"""
Create a dictionary from the JSON file
"""
try
:
filepath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'
archiver_config
'
,
self
.
filename
)
f
=
open
(
filepath
)
data
=
json
.
load
(
f
)
f
.
close
()
except
FileNotFoundError
as
e
:
raise
return
data
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