Add api bindings for datasource request-request trigger
Change-Id: Ib045e0a92fdfba454bda5e48531091a56656b289
This commit is contained in:
parent
b520516b87
commit
8c31d3fa29
5
NEWS
5
NEWS
@ -1,3 +1,8 @@
|
|||||||
|
1.0.4 - XXXX-XX-XX
|
||||||
|
------------------
|
||||||
|
- Add new CLI command to trigger a datasource to poll
|
||||||
|
- congress datasource request-refresh Trigger a datasource to poll.
|
||||||
|
|
||||||
1.0.3 - 2015-03-30
|
1.0.3 - 2015-03-30
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
@ -279,3 +279,25 @@ class DeleteDatasource(command.Command):
|
|||||||
datasource_id = utils.get_resource_id_from_name(
|
datasource_id = utils.get_resource_id_from_name(
|
||||||
parsed_args.datasource, results)
|
parsed_args.datasource, results)
|
||||||
client.delete_datasource(datasource_id)
|
client.delete_datasource(datasource_id)
|
||||||
|
|
||||||
|
|
||||||
|
class DatasourceRequestRefresh(command.Command):
|
||||||
|
"""Trigger a datasource to poll."""
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__ + '.DatasourceRequestRefresh')
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(DatasourceRequestRefresh, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
'datasource',
|
||||||
|
metavar="<datasource-name>",
|
||||||
|
help="Name of the datasource to poll")
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
|
client = self.app.client_manager.congressclient
|
||||||
|
results = client.list_datasources()
|
||||||
|
datasource_id = utils.get_resource_id_from_name(
|
||||||
|
parsed_args.datasource, results)
|
||||||
|
client.request_refresh(datasource_id, {})
|
||||||
|
@ -264,3 +264,23 @@ class TestDeleteDatasourceDriver(common.TestCongressBase):
|
|||||||
result = cmd.take_action(parsed_args)
|
result = cmd.take_action(parsed_args)
|
||||||
mocker.assert_called_with("id")
|
mocker.assert_called_with("id")
|
||||||
self.assertEqual(None, result)
|
self.assertEqual(None, result)
|
||||||
|
|
||||||
|
|
||||||
|
class TestDatasourceRequestRefresh(common.TestCongressBase):
|
||||||
|
|
||||||
|
def test_datasource_request_refresh(self):
|
||||||
|
driver = 'neutronv2'
|
||||||
|
|
||||||
|
arglist = [driver]
|
||||||
|
verifylist = [('datasource', driver), ]
|
||||||
|
|
||||||
|
mocker = mock.Mock(return_value=None)
|
||||||
|
self.app.client_manager.congressclient.request_refresh = mocker
|
||||||
|
self.app.client_manager.congressclient.list_datasources = mock.Mock()
|
||||||
|
cmd = datasource.DatasourceRequestRefresh(self.app, self.namespace)
|
||||||
|
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
||||||
|
with mock.patch.object(utils, "get_resource_id_from_name",
|
||||||
|
return_value="id"):
|
||||||
|
result = cmd.take_action(parsed_args)
|
||||||
|
mocker.assert_called_with("id", {})
|
||||||
|
self.assertEqual(None, result)
|
||||||
|
@ -175,3 +175,9 @@ class Client(object):
|
|||||||
resp, body = self.httpclient.get(self.driver_path %
|
resp, body = self.httpclient.get(self.driver_path %
|
||||||
(driver))
|
(driver))
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
def request_refresh(self, driver, body=None):
|
||||||
|
resp, body = self.httpclient.post(self.datasource_path %
|
||||||
|
(driver) + "?action=request-refresh",
|
||||||
|
body=body)
|
||||||
|
return body
|
||||||
|
@ -42,6 +42,7 @@ openstack.congressclient.v1 =
|
|||||||
congress_datasource_list = congressclient.osc.v1.datasource:ListDatasources
|
congress_datasource_list = congressclient.osc.v1.datasource:ListDatasources
|
||||||
congress_datasource_create = congressclient.osc.v1.datasource:CreateDatasource
|
congress_datasource_create = congressclient.osc.v1.datasource:CreateDatasource
|
||||||
congress_datasource_delete = congressclient.osc.v1.datasource:DeleteDatasource
|
congress_datasource_delete = congressclient.osc.v1.datasource:DeleteDatasource
|
||||||
|
congress_datasource_request-refresh = congressclient.osc.v1.datasource:DatasourceRequestRefresh
|
||||||
congress_datasource_table_list = congressclient.osc.v1.datasource:ListDatasourceTables
|
congress_datasource_table_list = congressclient.osc.v1.datasource:ListDatasourceTables
|
||||||
congress_datasource_row_list = congressclient.osc.v1.datasource:ListDatasourceRows
|
congress_datasource_row_list = congressclient.osc.v1.datasource:ListDatasourceRows
|
||||||
congress_datasource_status_show = congressclient.osc.v1.datasource:ShowDatasourceStatus
|
congress_datasource_status_show = congressclient.osc.v1.datasource:ShowDatasourceStatus
|
||||||
|
Loading…
Reference in New Issue
Block a user