TCA deployment with policy failed on below error 

      2021-03-11 20:29:45.818  LOG <tca-clamp> [tcagen2_policy_ohymri.create] INFO: latest policy for policy_id(onap.vfirewall.tca) status(200) response: {"policy_id": "onap.vfirewall.tca", "policy_body": {"type": "onap.policies.monitoring.tcagen2", "type_version": "1.0.0", "name": "onap.vfirewall.tca", "version": "1.0.0", "metadata": {"policy-id": "onap.vfirewall.tca", "policy-version": "1.0.0"}, "policyName": "onap.vfirewall.tca.1-0-0.xml", "policyVersion": "1.0.0", "config": {"tca.policy": {"domain": "measurementsForVfScaling", "metricsPerEventName": [{"eventName": "vFirewallBroadcastPackets", "controlLoopSchemaType": "VM", "policyScope": "DCAE", "policyName": "DCAE.Config_tca-hi-lo", "policyVersion": "v0.0.1", "thresholds": [{"closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", "version": "1.0.2", "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta", "thresholdValue": 300, "direction": "LESS_OR_EQUAL", "severity": "MAJOR", "closedLoopEventStatus": "ONSET"}, {"closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", "version": "1.0.2", "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta", "thresholdValue": 700, "direction": "GREATER_OR_EQUAL", "severity": "CRITICAL", "closedLoopEventStatus": "ONSET"}]}]}}}}
       2021-03-11 20:29:45.819  LOG <tca-clamp> [tcagen2_policy_ohymri.create] INFO: found policy onap.vfirewall.tca: {"policy_id": "onap.vfirewall.tca", "policy_body": {"type": "onap.policies.monitoring.tcagen2", "type_version": "1.0.0", "name": "onap.vfirewall.tca", "version": "1.0.0", "metadata": {"policy-id": "onap.vfirewall.tca", "policy-version": "1.0.0"}, "policyName": "onap.vfirewall.tca.1-0-0.xml", "policyVersion": "1.0.0", "config": {"tca.policy": {"domain": "measurementsForVfScaling", "metricsPerEventName": [{"eventName": "vFirewallBroadcastPackets", "controlLoopSchemaType": "VM", "policyScope": "DCAE", "policyName": "DCAE.Config_tca-hi-lo", "policyVersion": "v0.0.1", "thresholds": [{"closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", "version": "1.0.2", "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta", "thresholdValue": 300, "direction": "LESS_OR_EQUAL", "severity": "MAJOR", "closedLoopEventStatus": "ONSET"}, {"closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", "version": "1.0.2", "fieldPath": "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta", "thresholdValue": 700, "direction": "GREATER_OR_EQUAL", "severity": "CRITICAL", "closedLoopEventStatus": "ONSET"}]}]}}}}
       2021-03-11 20:29:45.872  LOG <tca-clamp> [tcagen2_policy_ohymri.create] INFO: exit policy_get
       2021-03-11 20:29:46.240  CFY <tca-clamp> [tcagen2_policy_ohymri.create] Task succeeded 'dcaepolicyplugin.policy_get'
       2021-03-11 20:29:46.241  CFY <tca-clamp> [tcagen2_policy_ohymri] Node instance created
       2021-03-11 20:29:46.361  CFY <tca-clamp> [tcagen2_policy_ohymri] Configuring node instance: nothing to do
       2021-03-11 20:29:46.363  CFY <tca-clamp> [tcagen2_policy_ohymri] Starting node instance: nothing to do
       2021-03-11 20:29:46.365  CFY <tca-clamp> [tcagen2_policy_ohymri] Poststarting node instance: nothing to do
       2021-03-11 20:29:46.368  CFY <tca-clamp> [tcagen2_policy_ohymri] Node instance started
       2021-03-11 20:29:46.762  CFY <tca-clamp> [docker.tca_kp6gc7] Validating node instance before creation: nothing to do
       2021-03-11 20:29:46.763  CFY <tca-clamp> [docker.tca_kp6gc7] Precreating node instance: nothing to do
       2021-03-11 20:29:46.770  CFY <tca-clamp> [docker.tca_kp6gc7] Creating node instance
       2021-03-11 20:29:47.203  CFY <tca-clamp> [docker.tca_kp6gc7.create] Sending task 'k8splugin.create_for_components'
       2021-03-11 20:29:50.883  LOG <tca-clamp> [docker.tca_kp6gc7.create] INFO: Added config for s899ce9681e8f412b94ada94c739eee73-dcae-tcagen2
       2021-03-11 20:29:50.883  LOG <tca-clamp> [docker.tca_kp6gc7.create] INFO: Done setting up: s899ce9681e8f412b94ada94c739eee73-dcae-tcagen2
       2021-03-11 20:29:51.320  CFY <tca-clamp> [docker.tca_kp6gc7.create] Task failed 'k8splugin.create_for_components' -> a bytes-like object is required, not 'str'
       Traceback (most recent call last):
         File "/opt/mgmtworker/env/lib/python3.6/site-packages/cloudify/dispatch.py", line 793, in main
           payload = handler.handle()
         File "/opt/mgmtworker/env/lib/python3.6/site-packages/cloudify/dispatch.py", line 456, in handle
           result = self._run_operation_func(ctx, kwargs)
         File "/opt/mgmtworker/env/lib/python3.6/site-packages/cloudify/dispatch.py", line 509, in _run_operation_func
           return self.func(*self.args, **kwargs)
         File "/opt/mgmtworker/env/plugins/default_tenant/k8splugin/3.7.0/lib/python3.6/site-packages/k8splugin/decorators.py", line 88, in wrapper
           dict(ctx.node.properties), **kwargs)
         File "/opt/mgmtworker/env/plugins/default_tenant/k8splugin/3.7.0/lib/python3.6/site-packages/k8splugin/decorators.py", line 77, in _wrapper_merge_inputs
           return task_func(**inputs)
         File "/opt/mgmtworker/env/plugins/default_tenant/k8splugin/3.7.0/lib/python3.6/site-packages/k8splugin/decorators.py", line 38, in wrapper
           return task_func(**kwargs)
         File "/opt/mgmtworker/env/plugins/default_tenant/k8splugin/3.7.0/lib/python3.6/site-packages/onap_dcae_dcaepolicy_lib/dcae_policy.py", line 198, in wrapper
           PoliciesOutput.store_policies(ACTION_GATHERED, policy_bodies)
         File "/opt/mgmtworker/env/plugins/default_tenant/k8splugin/3.7.0/lib/python3.6/site-packages/onap_dcae_dcaepolicy_lib/policies_output.py", line 114, in store_policies
           for policy_id, policy_body in policy_bodies.items()
         File "/opt/mgmtworker/env/plugins/default_tenant/k8splugin/3.7.0/lib/python3.6/site-packages/onap_dcae_dcaepolicy_lib/policies_output.py", line 114, in <listcomp>
           for policy_id, policy_body in policy_bodies.items()
         File "/opt/mgmtworker/env/plugins/default_tenant/k8splugin/3.7.0/lib/python3.6/site-packages/onap_dcae_dcaepolicy_lib/policies_output.py", line 60, in _gen_txn_operation
           return {"KV": {"Verb": verb, "Key": key, "Value": base64.b64encode(value)}}
         File "/opt/mgmtworker/env/plugins/default_tenant/k8splugin/3.7.0/lib64/python3.6/base64.py", line 58, in b64encode
           encoded = binascii.b2a_base64(s, newline=False)
       TypeError: a bytes-like object is required, not 'str'
      

      Fix required in policylib to change from 

      return {"KV": {"Verb": verb, "Key": key, "Value": base64.b64encode(value)}}

      to

      return {"KV": {"Verb": verb, "Key": key, "Value": base64.b64encode(value.encode("utf8")).decode("utf8")}}

      value.encode("utf8") <- convert value (a string) to a byte array
      base64.b64encode(str).decode("utf8") <- convert the byte array returned by b64encode into a string

       

      New lib to be pushed into Pypi, k8s plugin requirement should be updated to fetch revised plugin followed by CM container update

            vv770d vv770d
            vv770d vv770d
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: