Add delete_agent to AgentsClient

This patchset add delete_agent method that implements respective API [1]

[1] https://developer.openstack.org/api-ref/network/v2/index.html#delete-agent

Change-Id: I093574579bcecb08c2e2d4deeeda0438f3900ad6
Closes-Bug: 1792007
This commit is contained in:
Mykola Yakovliev 2018-09-11 14:01:36 -05:00
parent 138807b7e3
commit 709c8d36f1
4 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,7 @@
---
features:
- |
Adds the new method to AgentsClient that implements agent deletion
according to the API [0].
[0] https://developer.openstack.org/api-ref/network/v2/index.html#delete-agent

View File

@ -15,7 +15,9 @@
from tempest.api.network import base
from tempest.common import tempest_fixtures as fixtures
from tempest.common import utils
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
class AgentManagementTestJSON(base.BaseAdminNetworkTest):
@ -86,3 +88,11 @@ class AgentManagementTestJSON(base.BaseAdminNetworkTest):
origin_agent = {'description': description}
self.admin_agents_client.update_agent(agent_id=self.agent['id'],
agent=origin_agent)
@decorators.idempotent_id('b33af888-b6ac-4e68-a0ca-0444c2696cf9')
@decorators.attr(type=['negative'])
def test_delete_agent_negative(self):
non_existent_id = data_utils.rand_uuid()
self.assertRaises(
lib_exc.NotFound,
self.agents_client.delete_agent, non_existent_id)

View File

@ -37,6 +37,16 @@ class AgentsClient(base.BaseNetworkClient):
uri = '/agents/%s' % agent_id
return self.show_resource(uri, **fields)
def delete_agent(self, agent_id):
"""Delete agent.
For a full list of available parameters, please refer to the official
API reference:
https://developer.openstack.org/api-ref/network/v2/index.html#delete-agent
"""
uri = '/agents/%s' % agent_id
return self.delete_resource(uri)
def list_agents(self, **filters):
"""List all agents.

View File

@ -0,0 +1,37 @@
# Copyright 2018 AT&T Corporation.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest.lib.services.network import agents_client
from tempest.tests.lib import fake_auth_provider
from tempest.tests.lib.services import base
class TestAgentsClient(base.BaseServiceTest):
FAKE_AGENT_ID = "d32019d3-bc6e-4319-9c1d-6123f4135a88"
def setUp(self):
super(TestAgentsClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
self.agents_client = agents_client.AgentsClient(
fake_auth, "network", "regionOne")
def test_delete_agent(self):
self.check_service_client_function(
self.agents_client.delete_agent,
"tempest.lib.common.rest_client.RestClient.delete",
{},
status=204,
agent_id=self.FAKE_AGENT_ID)