New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openvswitch_db: Make 'key' parameter optional #42110
Conversation
col_value_to_dict = {} | ||
if col_value and col_value != '{}': | ||
if MAP_RE.match(col_value): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the need for this re again ? 'is_map' can be used to figure if column value is a map ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's to decide whether the column is a non-empty map. is_map doesn't take into account the content of the map
|
||
# Map types require key argument | ||
has_key = module.params['key'] is not None | ||
is_map = col_value[0] == '{' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_map should be done using global re 'MAP_RE' so we have one way to identify map in a column value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
has_key = module.params['key'] is not None | ||
is_map = col_value[0] == '{' | ||
if is_map and not has_key: | ||
module.fail_json(msg="missing required arguments: key") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this error message can be more informative by saying missing required argument : key for map type of column
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -102,8 +113,16 @@ def map_obj_to_commands(want, have, module): | |||
templatized_command = "%(ovs-vsctl)s -t %(timeout)s remove %(table)s %(record)s " \ | |||
"%(col)s %(key)s=%(value)s" | |||
commands.append(templatized_command % module.params) | |||
elif module.params['key'] is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is confusing. why not have simple 'else'. Is there a path where have.keys() do not have 'key' and module.params['key'] is not None ? If no then putting simple else will make code much readable .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not, you're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a case when you try to delete a record that is non-existent. So we need to keep this condition.
The test
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cubeek Thanks for making changes . looks good to me. Please push these changes to this PR.
The OVSDB schema consists of typed columns. The 'key' parameter is required only for columns with type of a 'map'. This patch makes 'key' an optional parameter to allow setting values for other column types like int. Fixes ansible#42108
I force-pushed to my branch, the changes should be available in this PR as far as I can tell. If I should not be doing force-push, please let me know and I can stack the changes. |
The OVSDB schema consists of typed columns. The 'key' parameter is required only for columns with type of a 'map'. This patch makes 'key' an optional parameter to allow setting values for other column types like int. Fixes ansible#42108 (cherry picked from commit 26b0908)
The OVSDB schema consists of typed columns. The 'key' parameter is required only for columns with type of a 'map'. This patch makes 'key' an optional parameter to allow setting values for other column types like int. Fixes ansible#42108 (cherry picked from commit 26b0908) (cherry picked from commit 0109771)
The patch adds simple test where LLC information is passed to a Neutron logical port. This triggers Ansible mechanism driver that is configured to talk to local Open vSwitch database. The port on OVS side should be configured with VLAN tag that is taken from Neutron logical network segmentation ID. VLAN tag is validated using ovsdbapp querying Port OVS table. update_port method for openvswitch provider is added in order to be able to talk to OVS DB. NOTE: Current Ansible contains bug in openvswitch_db module, the PR is pending review at the time of pushing this patch at ansible/ansible#42110 This is not a real tempest test as it assumes all-in-one and checks OVS installed on the local machine from which tempest is run. This is because we're in time pressure and such test adds a big value and there is no better testing framework at this moment. Change-Id: Ic73065175746a10ebef1ec731f947ee1c0919e72
* openvswitch_db: Split key-value pairs correctly (#33335) Map values can contain commas, e.g. - name: Configure OVN bridge mapping openvswitch_db: state: present table: open_vswitch record: . col: external_ids key: ovn-bridge-mappings value: '"vmnet-static:br-vmnet-st,vmnet-dynamic:br-vmnet-dyn"' Previous behaviour was splitting the value and raised an exception. (cherry picked from commit 3c53e2f) * openvswitch_db: Make 'key' parameter optional (#42110) The OVSDB schema consists of typed columns. The 'key' parameter is required only for columns with type of a 'map'. This patch makes 'key' an optional parameter to allow setting values for other column types like int. Fixes #42108 (cherry picked from commit 26b0908) (cherry picked from commit 0109771)
Hi,
|
|
@cubeek Thank you for taking the time to provide this feedback, it truly is useful. I'm glad to hear the Issue and PR templates are user friendly. |
The OVSDB schema consists of typed columns. The 'key' parameter is
required only for columns with type of a 'map'. This patch makes 'key'
an optional parameter to allow setting values for other column types
like int.
Fixes #42108
SUMMARY
ISSUE TYPE
COMPONENT NAME
openvswitch_db
ANSIBLE VERSION
ADDITIONAL INFORMATION
Before:
After: