[DMAAP-PLUGIN] Fix incorrect var name in DMaaP plugin topic creation 08/121008/7
authorefiacor <fiachra.corcoran@est.tech>
Thu, 29 Apr 2021 13:06:09 +0000 (14:06 +0100)
committerefiacor <fiachra.corcoran@est.tech>
Fri, 21 May 2021 14:10:39 +0000 (15:10 +0100)
Signed-off-by: efiacor <fiachra.corcoran@est.tech>
Change-Id: I5a17503b55380cd568f76a51656268592b778a26
Issue-ID: DCAEGEN2-2750

dmaap/README.md
dmaap/dmaap_types.yaml
dmaap/dmaapcontrollerif/dmaap_requests.py
dmaap/dmaapplugin/mr_lifecycle.py
dmaap/pom.xml
dmaap/tests/test_dmaapcontrollerif.py

index 55ac621..69d956f 100644 (file)
@@ -145,7 +145,7 @@ Property|Type|Required?|Description
 --------|----|---------|---------------------------------------
 topic_name|string|no|a name that uniquely identifies the feed (plugin will generate if absent or is empty string or contain only whitespace)
 topic_description|string|no|human-readable description of the feed
-txenable|boolean|no|flag indicating whether transactions are enabled for this topic
+tnxEnabled|boolean|no|flag indicating whether transactions are enabled for this topic
 replication_case|string|no|type of replication required for the topic (defaults to no replication)
 global_mr_url|string|no|Global MR host name for replication to a global MR instance
 
index 720f68f..b6508bf 100644 (file)
@@ -2,6 +2,7 @@
 # org.onap.dcaegen2
 # =============================================================================
 # Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
+# Modifications Copyright © 2021 Nordix Foundation.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -25,7 +26,7 @@ plugins:
   dmaapplugin:
     executor: 'central_deployment_agent'
     package_name: dmaap
-    package_version: 1.5.0
+    package_version: 1.5.1
 
 
 node_types:
@@ -109,7 +110,7 @@ node_types:
       topic_description:
         type: string
         required: false
-      txenable:
+      tnxEnabled:
         type: boolean
         required: false
       replication_case:
index 039643d..24889e3 100644 (file)
@@ -3,6 +3,7 @@
 # =============================================================================
 # Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
 # Copyright (c) 2020 Pantheon.tech. All rights reserved.
+# Modifications Copyright (c) 2021 Nordix Foundation.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -201,24 +202,24 @@ class DMaaPControllerHandle(object):
         return self._delete_resource("{0}/{1}".format(self.subs_path, sub_id))
 
     # Message router topics
-    def create_topic(self, name, description = None, txenable = None, owner = None, replication_case = None, global_mr_url = None, useExisting = None):
+    def create_topic(self, name, description = None, tnx_enabled = None, owner = None, replication_case = None, global_mr_url = None, use_existing = None):
         '''
         Create a message router topic with the topic name 'name' and optionally the topic_description
-        'description', the 'txenable' flag, the 'useExisting' flag and the topic owner 'owner'.
+        'description', the 'tnxEnabled' flag, the 'useExisting' flag and the topic owner 'owner'.
         '''
         topic_definition = {'topicName' : name}
         if description:
             topic_definition['topicDescription'] = description
         if owner:
             topic_definition['owner'] = owner
-        if txenable != None:                            # It's a boolean!
-            topic_definition['txenable'] = txenable
+        if tnx_enabled is not None:                            # It's a boolean!
+            topic_definition['tnxEnabled'] = tnx_enabled
         if replication_case:
             topic_definition['replicationCase'] = replication_case
         if global_mr_url:
             topic_definition['globalMrURL'] = global_mr_url
         topics_path_query = self.topics_path
-        if useExisting == True:                         # It's a boolean!
+        if use_existing:                         # It's a boolean!
             topics_path_query += "?useExisting=true"
 
         return self._create_resource(topics_path_query, topic_definition)
index 6fe3023..f280d2d 100644 (file)
@@ -3,6 +3,7 @@
 # =============================================================================
 # Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
 # Copyright (c) 2020 Pantheon.tech. All rights reserved.
+# Modifications Copyright (c) 2021 Nordix Foundation.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -29,11 +30,11 @@ from dmaapcontrollerif.dmaap_requests import DMaaPControllerHandle
 def create_topic(**kwargs):
     '''
     Creates a message router topic.
-    Allows 'topic_name', 'topic_description', 'txenable', 'replication_case', 'global_mr_url',
+    Allows 'topic_name', 'topic_description', 'tnxEnabled', 'replication_case', 'global_mr_url',
     and 'useExisting' as optional node properties.  If 'topic_name' is not set,
     generates a random one.
     Sets 'fqtn' in the instance runtime_properties.
-    Note that 'txenable' is a Message Router flag indicating whether transactions
+    Note that 'tnxEnabled' is a Message Router flag indicating whether transactions
     are enabled on the topic.
     Note that 'useExisting' is a flag indicating whether DBCL will use existing topic if
     the topic already exists.
@@ -48,36 +49,21 @@ def create_topic(**kwargs):
             topic_name = random_string(12)
 
         # Make sure there's a topic description
-        if "topic_description" in ctx.node.properties:
-            topic_description = ctx.node.properties["topic_description"]
-        else:
-            topic_description = "No description provided"
+        topic_description = ctx.node.properties.get("topic_description", "No description provided")
 
         # ..and the truly optional setting
-        if "txenable" in ctx.node.properties:
-            txenable = ctx.node.properties["txenable"]
-        else:
-            txenable= False
+        tnx_enabled = ctx.node.properties.get("tnxEnabled", False)
 
-        if "replication_case" in ctx.node.properties:
-            replication_case = ctx.node.properties["replication_case"]
-        else:
-            replication_case = None
+        replication_case = ctx.node.properties.get("replication_case")
 
-        if "global_mr_url" in ctx.node.properties:
-            global_mr_url = ctx.node.properties["global_mr_url"]
-        else:
-            global_mr_url = None
+        global_mr_url = ctx.node.properties.get("global_mr_url")
 
-        if "useExisting" in ctx.node.properties:
-            useExisting = ctx.node.properties["useExisting"]
-        else:
-            useExisting = False
+        use_existing = ctx.node.properties.get("useExisting", False)
 
         # Make the request to the controller
         dmc = DMaaPControllerHandle(DMAAP_API_URL, DMAAP_USER, DMAAP_PASS, ctx.logger)
         ctx.logger.info("Attempting to create topic name {0}".format(topic_name))
-        t = dmc.create_topic(topic_name, topic_description, txenable, DMAAP_OWNER, replication_case, global_mr_url, useExisting)
+        t = dmc.create_topic(topic_name, topic_description, tnx_enabled, DMAAP_OWNER, replication_case, global_mr_url, use_existing)
         t.raise_for_status()
 
         # Capture important properties from the result
index afc6089..76fb0a0 100644 (file)
@@ -4,6 +4,7 @@
 org.onap.dcaegen2
 ================================================================================
 Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
+Modifications Copyright (c) 2021 Nordix Foundation.
 ================================================================================
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
@@ -31,7 +32,7 @@ limitations under the License.
   <artifactId>dmaap</artifactId>
   <name>dmaap</name>
 
-  <version>1.5.0-SNAPSHOT</version>
+  <version>1.5.1-SNAPSHOT</version>
   <url>http://maven.apache.org</url>
   <properties>
     <!-- name from the setup.py file -->
index 25ddb88..07f2beb 100644 (file)
@@ -3,6 +3,7 @@
 # ================================================================================
 # Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
 # Copyright (c) 2020 Pantheon.tech. All rights reserved.
+# Modifications Copyright (c) 2021 Nordix Foundation.
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -76,30 +77,18 @@ def test_dmaapc (monkeypatch, mockconsul, mockdmaapbc):
         topic_name = random_string(12)
 
     # Make sure there's a topic description
-    if "topic_description" in ctx.node.properties:
-        topic_description = ctx.node.properties["topic_description"]
-    else:
-        topic_description = "No description provided"
+    topic_description = ctx.node.properties.get("topic_description", "No description provided")
 
     # ..and the truly optional setting
-    if "txenable" in ctx.node.properties:
-        txenable = ctx.node.properties["txenable"]
-    else:
-        txenable= False
+    tnx_enabled = ctx.node.properties.get("tnxEnabled", False)
 
-    if "replication_case" in ctx.node.properties:
-        replication_case = ctx.node.properties["replication_case"]
-    else:
-        replication_case = None
+    replication_case = ctx.node.properties.get("replication_case")
 
-    if "global_mr_url" in ctx.node.properties:
-        global_mr_url = ctx.node.properties["global_mr_url"]
-    else:
-        global_mr_url = None
+    global_mr_url = ctx.node.properties.get("global_mr_url")
 
     dmc = DMaaPControllerHandle(DMAAP_API_URL, DMAAP_USER, DMAAP_PASS, ctx.logger)
     ctx.logger.info("Attempting to create topic name {0}".format(topic_name))
-    t = dmc.create_topic(topic_name, topic_description, txenable, DMAAP_OWNER, replication_case, global_mr_url)
+    t = dmc.create_topic(topic_name, topic_description, tnx_enabled, DMAAP_OWNER, replication_case, global_mr_url)
 
     # Capture important properties from the result
     topic = t.json()