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
2c225b80
Commit
2c225b80
authored
2 years ago
by
Stefano Di Frischia
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-1030
: rename adding methods
parent
0a93f7c6
No related branches found
No related tags found
1 merge request
!468
Resolve L2SS-1030 "Create configuration device"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tangostationcontrol/tangostationcontrol/common/configuration.py
+9
-9
9 additions, 9 deletions
...tationcontrol/tangostationcontrol/common/configuration.py
with
9 additions
and
9 deletions
tangostationcontrol/tangostationcontrol/common/configuration.py
+
9
−
9
View file @
2c225b80
...
...
@@ -31,23 +31,23 @@ def get_db_data(db, tangodb_timeout:int = 10000):
# Remodel the query result
device_property_result
=
query_to_tuples
(
raw_result
,
3
)
# Populate devices dictionary from query data
devices_dict
=
model
_devices_dict
(
devices_dict
,
device_property_result
)
devices_dict
=
add_to
_devices_dict
(
devices_dict
,
device_property_result
)
# Query TangoDb with built-in function for attributes data
_
,
raw_result
=
dbproxy
.
command_inout
(
"
DbMySqlSelect
"
,
ATTRS_PROPERTIES_QUERY
)
# Remodel the query result
attrs_property_result
=
query_to_tuples
(
raw_result
,
4
)
# Populate devices dictionary from query data
devices_dict
=
model
_attrs_dict
(
devices_dict
,
attrs_property_result
)
devices_dict
=
add_to
_attrs_dict
(
devices_dict
,
attrs_property_result
)
# Query TangoDb with built-in function for server data
_
,
raw_result
=
dbproxy
.
command_inout
(
"
DbMySqlSelect
"
,
SERVER_QUERY
)
# Remodel the query result
server_result
=
query_to_tuples
(
raw_result
,
3
)
# Populate server dictionary from query data and merge it with devices dict
server_dict
=
model
_server_dict
(
server_dict
,
devices_dict
,
server_result
)
server_dict
=
add_to
_server_dict
(
server_dict
,
devices_dict
,
server_result
)
return
{
"
servers
"
:
server_dict
}
def
model
_devices_dict
(
devices_dict
:
dict
,
result
:
list
):
"""
Model
a devices dictionary with the following structure:
def
add_to
_devices_dict
(
devices_dict
:
dict
,
result
:
list
):
"""
Populate
a devices dictionary with the following structure:
'
device_name
'
: {
'
properties
'
: {
'
property_name
'
: [
'
property_value
'
] } }
"""
for
device
,
property
,
value
in
result
:
...
...
@@ -61,8 +61,8 @@ def model_devices_dict(devices_dict:dict, result:list):
value_data
.
append
(
value
)
return
devices_dict
def
model
_attrs_dict
(
devices_dict
:
dict
,
result
:
list
):
"""
Model
a device dictionary with the following structure :
def
add_to
_attrs_dict
(
devices_dict
:
dict
,
result
:
list
):
"""
Populate
a device dictionary with the following structure :
'
device_name
'
: {
'
attribute_properties
'
: {
'
attribute_name
'
: {
'
property_name
'
: [
'
property_value
'
] } } }
"""
for
device
,
attribute
,
property
,
value
in
result
:
...
...
@@ -78,8 +78,8 @@ def model_attrs_dict(devices_dict:dict, result:list):
value_data
.
append
(
value
)
return
devices_dict
def
model
_server_dict
(
server_dict
:
dict
,
devices_dict
:
dict
,
result
:
list
):
"""
Model
the server dictionary and merge it with the devices dictionary.
def
add_to
_server_dict
(
server_dict
:
dict
,
devices_dict
:
dict
,
result
:
list
):
"""
Populate
the server dictionary and merge it with the devices dictionary.
At the end of the process, the dictionary will have the following structure :
'
server_name
'
: {
'
server_instance
'
: {
'
server_class
'
:
'
device_name
'
: {
'
properties
'
: {
'
property_name
'
: [
'
property_value
'
] } },
...
...
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