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
This commit is contained in:
Vu Tuong 2020-10-05 11:33:43 +00:00
parent 94dc6d8c27
commit b8c642a770
2 changed files with 4 additions and 3 deletions

View File

@ -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):

View File

@ -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",