From 116526275d0953fda93c7ff8eacd8631c5af68d5 Mon Sep 17 00:00:00 2001
From: Daniel Speichert <Daniel_Speichert@comcast.com>
Date: Tue, 14 Nov 2017 11:14:11 -0500
Subject: [PATCH] Send 'changes-since' instead of 'changes_since' query
 parameter

Per API reference, only 'changes-since' is accepted and the variant
with underscore is ignored, making the CLI functionality broken.

[dtroyer] added release note and fixed unit tests.

Change-Id: I0c596531a8af03da17d5ce39d75b12e941403aa5
Closes-Bug: 1732216
---
 openstackclient/compute/v2/server.py                | 13 +++++++------
 .../tests/unit/compute/v2/test_server.py            |  4 ++--
 .../notes/bug-1732216-b41bfedebff911e1.yaml         |  5 +++++
 3 files changed, 14 insertions(+), 8 deletions(-)
 create mode 100644 releasenotes/notes/bug-1732216-b41bfedebff911e1.yaml

diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py
index 034199822d..3b805639e3 100644
--- a/openstackclient/compute/v2/server.py
+++ b/openstackclient/compute/v2/server.py
@@ -1056,17 +1056,18 @@ class ListServer(command.Lister):
             'all_tenants': parsed_args.all_projects,
             'user_id': user_id,
             'deleted': parsed_args.deleted,
-            'changes_since': parsed_args.changes_since,
+            'changes-since': parsed_args.changes_since,
         }
         LOG.debug('search options: %s', search_opts)
 
-        if search_opts['changes_since']:
+        if search_opts['changes-since']:
             try:
-                timeutils.parse_isotime(search_opts['changes_since'])
+                timeutils.parse_isotime(search_opts['changes-since'])
             except ValueError:
-                raise exceptions.CommandError(_('Invalid changes-since value:'
-                                              ' %s') % search_opts['changes'
-                                                                   '_since'])
+                raise exceptions.CommandError(
+                    _('Invalid changes-since value: %s') %
+                    search_opts['changes-since']
+                )
 
         if parsed_args.long:
             columns = (
diff --git a/openstackclient/tests/unit/compute/v2/test_server.py b/openstackclient/tests/unit/compute/v2/test_server.py
index ad52e23225..99cdfb7775 100644
--- a/openstackclient/tests/unit/compute/v2/test_server.py
+++ b/openstackclient/tests/unit/compute/v2/test_server.py
@@ -1584,7 +1584,7 @@ class TestServerList(TestServer):
             'all_tenants': False,
             'user_id': None,
             'deleted': False,
-            'changes_since': None,
+            'changes-since': None,
         }
 
         # Default params of the core function of the command in the case of no
@@ -1791,7 +1791,7 @@ class TestServerList(TestServer):
         parsed_args = self.check_parser(self.cmd, arglist, verifylist)
         columns, data = self.cmd.take_action(parsed_args)
 
-        self.search_opts['changes_since'] = '2016-03-04T06:27:59Z'
+        self.search_opts['changes-since'] = '2016-03-04T06:27:59Z'
         self.search_opts['deleted'] = True
         self.servers_mock.list.assert_called_with(**self.kwargs)
 
diff --git a/releasenotes/notes/bug-1732216-b41bfedebff911e1.yaml b/releasenotes/notes/bug-1732216-b41bfedebff911e1.yaml
new file mode 100644
index 0000000000..d792f25a28
--- /dev/null
+++ b/releasenotes/notes/bug-1732216-b41bfedebff911e1.yaml
@@ -0,0 +1,5 @@
+---
+fixes:
+  - |
+    Fix the operation of the ``--changes-since`` option to the ``server list`` command.
+    [Bug `1732216 <https://bugs.launchpad.net/python-openstackclient/+bug/1732216>`_]