commit b8c642a7703f96c1585cc85b7640fd3d716c6e2a Author: Vu Tuong Date: Mon Oct 5 11:33:43 2020 +0000 Fix python3 utf-8 decode issue and typo while creating app_monitor This change corrects the input for ast.literal_eval() and also corrects the variable (zapi.URL) called in zabbix_api.py and zabbix.py. From the Python3 documentation for ast.literal_eval(): Safely evaluate an expression node or a string containing a Python expression. The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None. Change-Id: I710feff170cb464371d76ef3ee52392fa818c18d Related-Bug: #1898515 Closes-Bug: #1898526 diff --git a/tacker/vnfm/monitor.py b/tacker/vnfm/monitor.py index 8defa8b..49035fc 100644 --- a/tacker/vnfm/monitor.py +++ b/tacker/vnfm/monitor.py @@ -232,7 +232,8 @@ class VNFAppMonitor(object): def _create_app_monitoring_dict(self, dev_attrs, mgmt_ip_address): app_policy = 'app_monitoring_policy' - appmonitoring_dict = ast.literal_eval(dev_attrs[app_policy]) + appmonitoring_dict = ast.literal_eval( + dev_attrs[app_policy].decode('utf-8')) vdulist = appmonitoring_dict['vdus'].keys() for vduname in vdulist: @@ -242,7 +243,7 @@ class VNFAppMonitor(object): def create_app_dict(self, context, vnf_dict): dev_attrs = vnf_dict['attributes'] - mgmt_ip_address = vnf_dict['mgmt_ip_address'] + mgmt_ip_address = vnf_dict['mgmt_ip_address'].decode("utf-8") return self._create_app_monitoring_dict(dev_attrs, mgmt_ip_address) def _invoke(self, driver, **kwargs): diff --git a/tacker/vnfm/monitor_drivers/zabbix/zabbix_api.py b/tacker/vnfm/monitor_drivers/zabbix/zabbix_api.py index 760fab6..fb1015a5 100644 --- a/tacker/vnfm/monitor_drivers/zabbix/zabbix_api.py +++ b/tacker/vnfm/monitor_drivers/zabbix/zabbix_api.py @@ -11,7 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. # -URL_ = "/zabbix/api_jsonrpc.php" +URL = "/zabbix/api_jsonrpc.php" HEADERS = {'Content-Type': 'application/json-rpc'} dAUTH_API = {'jsonrpc': "2.0",