AETHER-3648 Support loglevel configuration in enodebd

AETHER-3020 Firmware upgrade feature: integrate firmware url to enb cfg

Change-Id: Iba2e08fc6aa31c23f9eedb70ebf250c2d2066e8d
diff --git a/VERSION b/VERSION
index 373f8c6..abd4105 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.2.3
\ No newline at end of file
+0.2.4
diff --git a/common/service.py b/common/service.py
index 1e98483..33dc2dd 100644
--- a/common/service.py
+++ b/common/service.py
@@ -355,6 +355,10 @@
             "Setting logging level to %s",
             logging.getLevelName(level),
         )
+
+        # Depress the spyne log as INFO, avoid the debugging messages from enodebd service
+        logging.getLogger('spyne').setLevel(logging.INFO)
+
         logger = logging.getLogger('')
         logger.setLevel(level)
 
diff --git a/configuration/service_configs.py b/configuration/service_configs.py
index 65fd4a7..199a7ca 100644
--- a/configuration/service_configs.py
+++ b/configuration/service_configs.py
@@ -89,7 +89,7 @@
     if not os.path.exists(ENB_CONFIG_DIR):
         return ret
 
-    for fname in filter(lambda x: x.endswith(".yml"), os.listdir(ENB_CONFIG_DIR)):
+    for fname in filter(lambda x: x.endswith(".yml") or x.endswith(".yaml"), os.listdir(ENB_CONFIG_DIR)):
         sn = fname.replace(".yml", "")
         cfg_file_name = os.path.join(ENB_CONFIG_DIR, fname)
         sn_yaml = _load_yaml_file(cfg_file_name)
diff --git a/device_config/configuration_init.py b/device_config/configuration_init.py
index 97ce399..3781c69 100644
--- a/device_config/configuration_init.py
+++ b/device_config/configuration_init.py
@@ -111,6 +111,7 @@
     enb_configs = load_enb_config()
     enb_serial = device_config.get_parameter(ParameterName.SERIAL_NUMBER)
     enb_config = enb_configs.get(enb_serial, dict())
+    
 
     generated_config = dict()
     for parameter_name in ParameterName.all_paramters():
diff --git a/device_config/enodeb_configuration.py b/device_config/enodeb_configuration.py
index 8a7050b..86dd3ce 100644
--- a/device_config/enodeb_configuration.py
+++ b/device_config/enodeb_configuration.py
@@ -66,6 +66,9 @@
         """
         return self._data_model
 
+    def __str__(self) -> str:
+        return str(self._param_to_value)
+
     def get_parameter_names(self) -> List[ParameterName]:
         """
         Returns: list of ParameterName
@@ -269,6 +272,7 @@
         self.set_parameter(ParameterName.TAC1, desired_config["tac1"])
 
         # _set_bandwidth
+        # FIXME: The DL_BANDWIDTH update request wasn't able to be accepted by enodeb
         self.set_parameter(ParameterName.DL_BANDWIDTH, desired_config["downlink_bandwidth"])
         self.set_parameter(ParameterName.UL_BANDWIDTH, desired_config["uplink_bandwidth"])
 
@@ -289,7 +293,7 @@
         # enable LTE if we should
         self.set_parameter(ParameterName.ADMIN_STATE, desired_config["admin_state"])
 
-        # These parameters are already configured at above
+        # These parameters are already configured above
         exclude_list = [
             "earfcn_downlink1", "earfcn_uplink1", "subframe_assignment", "special_subframe_pattern",
             "plmnid", "tac1", "downlink_bandwidth", "uplink_bandwidth", "cell_id",
diff --git a/devices/sercomm.py b/devices/sercomm.py
index a64186a..ae4cd8b 100644
--- a/devices/sercomm.py
+++ b/devices/sercomm.py
@@ -640,7 +640,7 @@
         ParameterName.UL_BANDWIDTH: TrParam(
             FAPSERVICE_PATH + "CellConfig.LTE.RAN.RF.ULBandwidth",
             is_invasive=False,
-            type=TrParameterType.STRING,
+            type=TrParameterType.INT,
             is_optional=False,
         ),
         ParameterName.PCI_LIST: TrParam(
diff --git a/magma_configs/enodebd.yml.example b/magma_configs/enodebd.yml.example
index 9890582..56870ab 100644
--- a/magma_configs/enodebd.yml.example
+++ b/magma_configs/enodebd.yml.example
@@ -29,3 +29,16 @@
 
 # Network interface to terminate S1
 s1_interface: eth1
+
+# enodebd log_level - supported options: INFO, DEBUG, WARNING, ERROR, FATAl
+log_level: INFO
+
+# firmware download information and credential used by enodebd
+# for "filesize", calculated in Bytes, for device to check if it has enough space to download file
+# put 0 to ask device to download the firmware anyway (but it may fail)
+firmware:
+  url: ""
+  filename: ""
+  filesize: 0
+  username: ""
+  password: ""
diff --git a/state_machines/acs_state_utils.py b/state_machines/acs_state_utils.py
index e35f37d..b335546 100644
--- a/state_machines/acs_state_utils.py
+++ b/state_machines/acs_state_utils.py
@@ -268,6 +268,7 @@
     data_model: DataModel,
     exclude_admin: bool = False,
 ) -> Dict[ParameterName, Any]:
+
     """ Returns a map of param names to values that we need to set """
     param_values = get_param_values_to_set(
         desired_cfg, device_cfg,
diff --git a/state_machines/enb_acs_states.py b/state_machines/enb_acs_states.py
index 2c3e53b..2a0a911 100644
--- a/state_machines/enb_acs_states.py
+++ b/state_machines/enb_acs_states.py
@@ -3,6 +3,7 @@
 #
 # SPDX-License-Identifier: BSD-3-Clause
 
+import datetime
 import time
 from abc import ABC, abstractmethod
 from collections import namedtuple
@@ -1294,6 +1295,8 @@
 
     def get_msg(self, message: Any) -> AcsMsgAndTransition:
 
+        enodebd_cfg = load_service_config("enodebd")
+
         # Switch enodeb status to firmware upgrading
         metrics.set_enb_status(
             self.acs.device_cfg.get_parameter("Serial number"),
@@ -1301,13 +1304,13 @@
         )
 
         request = models.Download()
-        request.CommandKey = "20220206215200"
+        request.CommandKey = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
         request.FileType = "1 Firmware Upgrade Image"
-        request.URL = "http://10.128.250.131/firmware/Qproject_RC3923_2202151120.ffw"
-        request.Username = ""
-        request.Password = ""
-        request.FileSize = 57399275
-        request.TargetFileName = "Qproject_RC3923_2202151120.ffw"
+        request.URL = enodebd_cfg["firmware"]["url"]
+        request.Username = enodebd_cfg["firmware"]["username"]
+        request.Password = enodebd_cfg["firmware"]["password"]
+        request.FileSize = enodebd_cfg["firmware"]["filesize"]
+        request.TargetFileName = enodebd_cfg["firmware"]["filename"]
         request.DelaySeconds = 0
         request.SuccessURL = ""
         request.FailureURL = ""