From a6409b338d245251905574fb4bcff1fc3285bf76 Mon Sep 17 00:00:00 2001 From: Fred-sun Date: Fri, 24 Feb 2023 18:47:15 +0800 Subject: [PATCH 1/3] Add max_message_size_in_kilobytes to azure_rm_servicebustopic.py and azure_rm_servicebusqueue.py --- plugins/modules/azure_rm_servicebusqueue.py | 11 +++++++++++ plugins/modules/azure_rm_servicebustopic.py | 10 ++++++++++ .../targets/azure_rm_servicebus/tasks/main.yml | 11 ++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/plugins/modules/azure_rm_servicebusqueue.py b/plugins/modules/azure_rm_servicebusqueue.py index a86abc49b..6dc6a6ef9 100644 --- a/plugins/modules/azure_rm_servicebusqueue.py +++ b/plugins/modules/azure_rm_servicebusqueue.py @@ -82,6 +82,11 @@ - The maximum delivery count. - A message is automatically deadlettered after this number of deliveries. type: int + max_message_size_in_kb: + description: + - The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. + - Default is 1024. + type: int max_size_in_mb: description: - The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. @@ -179,6 +184,7 @@ def __init__(self): forward_to=dict(type='str'), lock_duration_in_seconds=dict(type='int'), max_delivery_count=dict(type='int'), + max_message_size_in_kb = dict(type='int'), max_size_in_mb=dict(type='int'), requires_duplicate_detection=dict(type='bool'), requires_session=dict(type='bool'), @@ -207,6 +213,7 @@ def __init__(self): self.requires_duplicate_detection = None self.status = None self.requires_session = None + self.max_message_size_in_kb = None self.results = dict( changed=False, @@ -234,6 +241,7 @@ def exec_module(self, **kwargs): forward_dead_lettered_messages_to=self.forward_dead_lettered_messages_to, forward_to=self.forward_to, max_delivery_count=self.max_delivery_count, + max_message_size_in_kilobytes=self.max_message_size_in_kb, max_size_in_megabytes=self.max_size_in_mb, requires_session=self.requires_session, requires_duplicate_detection=self.requires_duplicate_detection @@ -270,6 +278,7 @@ def exec_module(self, **kwargs): return self.results def create_or_update(self, param): + try: client = self._get_client() return client.create_or_update(self.resource_group, self.namespace, self.name, param) @@ -317,6 +326,8 @@ def to_dict(self, instance): result[attribute] = to_native(value) elif attribute == 'max_size_in_megabytes': result['max_size_in_mb'] = value + elif attribute == 'max_size_in_kilobytes': + result['max_size_in_kb'] = value else: result[attribute] = value return result diff --git a/plugins/modules/azure_rm_servicebustopic.py b/plugins/modules/azure_rm_servicebustopic.py index 11937cecf..335a5cf75 100644 --- a/plugins/modules/azure_rm_servicebustopic.py +++ b/plugins/modules/azure_rm_servicebustopic.py @@ -61,6 +61,11 @@ description: - A value that indicates whether the topic is to be partitioned across multiple message brokers. type: bool + max_message_size_in_kb: + description: + - The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. + - Default is 1024. + type: int max_size_in_mb: description: - The maximum size of the topic in megabytes, which is the size of memory allocated for the topic. @@ -150,6 +155,7 @@ def __init__(self): enable_express=dict(type='bool'), enable_partitioning=dict(type='bool'), max_size_in_mb=dict(type='int'), + max_message_size_in_kb=dict(type='int'), name=dict(type='str', required=True), namespace=dict(type='str'), requires_duplicate_detection=dict(type='bool'), @@ -173,6 +179,7 @@ def __init__(self): self.requires_duplicate_detection = None self.status = None self.support_ordering = None + self.max_message_size_in_kb = None self.results = dict( changed=False, @@ -196,6 +203,7 @@ def exec_module(self, **kwargs): enable_express=self.enable_express, enable_partitioning=self.enable_partitioning, max_size_in_megabytes=self.max_size_in_mb, + max_message_size_in_kilobytes=self.max_message_size_in_kb, support_ordering=self.support_ordering ) if self.status: @@ -277,6 +285,8 @@ def to_dict(self, instance): result[attribute] = to_native(value) elif attribute == 'max_size_in_megabytes': result['max_size_in_mb'] = value + elif attribute == 'max_message_size_in_kilobyte': + result['max_message_size_in_kb'] = value else: result[attribute] = value return result diff --git a/tests/integration/targets/azure_rm_servicebus/tasks/main.yml b/tests/integration/targets/azure_rm_servicebus/tasks/main.yml index 93f56ebb2..84bd6927e 100644 --- a/tests/integration/targets/azure_rm_servicebus/tasks/main.yml +++ b/tests/integration/targets/azure_rm_servicebus/tasks/main.yml @@ -7,6 +7,7 @@ azure_rm_servicebus: name: "ns{{ rpfx }}" resource_group: "{{ resource_group }}" + sku: premium register: namespace - assert: @@ -29,6 +30,8 @@ name: "queue{{ rpfx }}" namespace: "ns{{ rpfx }}" resource_group: "{{ resource_group }}" + max_message_size_in_kb: 2048 + max_size_in_mb: 2048 register: queue - assert: @@ -42,6 +45,8 @@ resource_group: "{{ resource_group }}" namespace: "ns{{ rpfx }}" duplicate_detection_time_in_seconds: 600 + max_message_size_in_kb: 2048 + max_size_in_mb: 2048 check_mode: yes register: output @@ -55,6 +60,8 @@ resource_group: "{{ resource_group }}" namespace: "ns{{ rpfx }}" duplicate_detection_time_in_seconds: 600 + max_message_size_in_kb: 2048 + max_size_in_mb: 2048 register: output - assert: @@ -69,6 +76,8 @@ resource_group: "{{ resource_group }}" namespace: "ns{{ rpfx }}" duplicate_detection_time_in_seconds: 600 + max_message_size_in_kb: 2048 + max_size_in_mb: 2048 register: output - assert: @@ -166,4 +175,4 @@ azure_rm_servicebus: name: "ns{{ rpfx }}" resource_group: "{{ resource_group }}" - state: absent \ No newline at end of file + state: absent From ba586e9f06fafa8f3157bd568e84374cff50aeba Mon Sep 17 00:00:00 2001 From: Fred-sun Date: Fri, 24 Feb 2023 19:06:43 +0800 Subject: [PATCH 2/3] fix sanity fail --- plugins/modules/azure_rm_servicebusqueue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/azure_rm_servicebusqueue.py b/plugins/modules/azure_rm_servicebusqueue.py index 6dc6a6ef9..dca8f5b7c 100644 --- a/plugins/modules/azure_rm_servicebusqueue.py +++ b/plugins/modules/azure_rm_servicebusqueue.py @@ -184,7 +184,7 @@ def __init__(self): forward_to=dict(type='str'), lock_duration_in_seconds=dict(type='int'), max_delivery_count=dict(type='int'), - max_message_size_in_kb = dict(type='int'), + max_message_size_in_kb=dict(type='int'), max_size_in_mb=dict(type='int'), requires_duplicate_detection=dict(type='bool'), requires_session=dict(type='bool'), From 007d48e9b3ea2e789931033584c09900cdd40780 Mon Sep 17 00:00:00 2001 From: Fred-sun Date: Fri, 24 Feb 2023 19:15:59 +0800 Subject: [PATCH 3/3] Modify the document! --- plugins/modules/azure_rm_servicebusqueue.py | 4 ++-- plugins/modules/azure_rm_servicebustopic.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/modules/azure_rm_servicebusqueue.py b/plugins/modules/azure_rm_servicebusqueue.py index dca8f5b7c..5c022cb05 100644 --- a/plugins/modules/azure_rm_servicebusqueue.py +++ b/plugins/modules/azure_rm_servicebusqueue.py @@ -84,8 +84,8 @@ type: int max_message_size_in_kb: description: - - The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. - - Default is 1024. + - Maximum size (in KB) of the message payload that can be accepted by the queue. + - This property is only used in Premium today and default is 1024. type: int max_size_in_mb: description: diff --git a/plugins/modules/azure_rm_servicebustopic.py b/plugins/modules/azure_rm_servicebustopic.py index 335a5cf75..a39019c1a 100644 --- a/plugins/modules/azure_rm_servicebustopic.py +++ b/plugins/modules/azure_rm_servicebustopic.py @@ -63,8 +63,8 @@ type: bool max_message_size_in_kb: description: - - The maximum size of the queue in megabytes, which is the size of memory allocated for the queue. - - Default is 1024. + - Maximum size (in KB) of the message payload that can be accepted by the queue. + - This property is only used in Premium today and default is 1024. type: int max_size_in_mb: description: