summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2021-04-29 14:06:09 +0100
committerefiacor <fiachra.corcoran@est.tech>2021-05-21 15:10:39 +0100
commit94d5e62176cb6a3d70e651bd51f0ab4029cd6cf2 (patch)
treec705479ef5c13a9e4d6d7f93deac1c98b83d6894
parent495e8f8283bd6dfb7b4d4f822b06291a7cf04205 (diff)
[DMAAP-PLUGIN] Fix incorrect var name in DMaaP plugin topic creation
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Change-Id: I5a17503b55380cd568f76a51656268592b778a26 Issue-ID: DCAEGEN2-2750
-rw-r--r--dmaap/README.md2
-rw-r--r--dmaap/dmaap_types.yaml5
-rw-r--r--dmaap/dmaapcontrollerif/dmaap_requests.py11
-rw-r--r--dmaap/dmaapplugin/mr_lifecycle.py32
-rw-r--r--dmaap/pom.xml3
-rw-r--r--dmaap/tests/test_dmaapcontrollerif.py23
6 files changed, 27 insertions, 49 deletions
diff --git a/dmaap/README.md b/dmaap/README.md
index 55ac621..69d956f 100644
--- a/dmaap/README.md
+++ b/dmaap/README.md
@@ -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
diff --git a/dmaap/dmaap_types.yaml b/dmaap/dmaap_types.yaml
index 720f68f..b6508bf 100644
--- a/dmaap/dmaap_types.yaml
+++ b/dmaap/dmaap_types.yaml
@@ -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:
diff --git a/dmaap/dmaapcontrollerif/dmaap_requests.py b/dmaap/dmaapcontrollerif/dmaap_requests.py
index 039643d..24889e3 100644
--- a/dmaap/dmaapcontrollerif/dmaap_requests.py
+++ b/dmaap/dmaapcontrollerif/dmaap_requests.py
@@ -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)
diff --git a/dmaap/dmaapplugin/mr_lifecycle.py b/dmaap/dmaapplugin/mr_lifecycle.py
index 6fe3023..f280d2d 100644
--- a/dmaap/dmaapplugin/mr_lifecycle.py
+++ b/dmaap/dmaapplugin/mr_lifecycle.py
@@ -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
diff --git a/dmaap/pom.xml b/dmaap/pom.xml
index afc6089..76fb0a0 100644
--- a/dmaap/pom.xml
+++ b/dmaap/pom.xml
@@ -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 -->
diff --git a/dmaap/tests/test_dmaapcontrollerif.py b/dmaap/tests/test_dmaapcontrollerif.py
index 25ddb88..07f2beb 100644
--- a/dmaap/tests/test_dmaapcontrollerif.py
+++ b/dmaap/tests/test_dmaapcontrollerif.py
@@ -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()