Skip to content
Snippets Groups Projects
Commit 2c225b80 authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-1030: rename adding methods

parent 0a93f7c6
No related branches found
No related tags found
1 merge request!468Resolve L2SS-1030 "Create configuration device"
......@@ -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'] } },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment