Merge "Provide client bindings for DELETE method of auto-allocated-topology extension"
This commit is contained in:
commit
a33edfa08d
@ -14,6 +14,8 @@
|
||||
# under the License.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
from cliff import show
|
||||
from oslo_serialization import jsonutils
|
||||
@ -79,3 +81,33 @@ class ShowAutoAllocatedTopology(v2_0.NeutronCommand, show.ShowOne):
|
||||
return zip(*sorted(data[self.resource].items()))
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class DeleteAutoAllocatedTopology(v2_0.NeutronCommand):
|
||||
"""Delete the auto-allocated topology of a given tenant."""
|
||||
|
||||
resource = 'auto_allocated_topology'
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteAutoAllocatedTopology, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'--tenant-id', metavar='tenant-id',
|
||||
help=_('The owner tenant ID.'))
|
||||
# Allow people to do
|
||||
# neutron auto-allocated-topology-delete <tenant-id>
|
||||
# (Only useful to users who can look at other tenants' topologies.)
|
||||
# We use a different name for this arg because the default will
|
||||
# override whatever is in the named arg otherwise.
|
||||
parser.add_argument(
|
||||
'pos_tenant_id',
|
||||
help=argparse.SUPPRESS, nargs='?')
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
client = self.get_client()
|
||||
tenant_id = parsed_args.tenant_id or parsed_args.pos_tenant_id
|
||||
client.delete_auto_allocated_topology(tenant_id)
|
||||
# It tenant is None, let's be clear on what it means.
|
||||
tenant_id = tenant_id or 'None (i.e. yours)'
|
||||
print(_('Deleted topology for tenant %s.') % tenant_id,
|
||||
file=self.app.stdout)
|
||||
|
@ -413,6 +413,8 @@ COMMAND_V2 = {
|
||||
'availability-zone-list': availability_zone.ListAvailabilityZone,
|
||||
'auto-allocated-topology-show': (
|
||||
auto_allocated_topology.ShowAutoAllocatedTopology),
|
||||
'auto-allocated-topology-delete': (
|
||||
auto_allocated_topology.DeleteAutoAllocatedTopology),
|
||||
'bgp-dragent-speaker-add': (
|
||||
bgp_drsched.AddBGPSpeakerToDRAgent
|
||||
),
|
||||
|
@ -53,3 +53,24 @@ class TestAutoAllocatedTopologyJSON(test_cli20.CLITestV20Base):
|
||||
args = ['--dry-run', 'some-tenant']
|
||||
self._test_show_resource(resource, cmd, "some-tenant", args,
|
||||
fields=('dry-run',))
|
||||
|
||||
def test_delete_auto_allocated_topology_arg(self):
|
||||
resource = 'auto_allocated_topology'
|
||||
cmd = aat.DeleteAutoAllocatedTopology(test_cli20.MyApp(sys.stdout),
|
||||
None)
|
||||
args = ['--tenant-id', self.test_id]
|
||||
self._test_delete_resource(resource, cmd, self.test_id, args)
|
||||
|
||||
def test_delete_auto_allocated_topology_posarg(self):
|
||||
resource = 'auto_allocated_topology'
|
||||
cmd = aat.DeleteAutoAllocatedTopology(test_cli20.MyApp(sys.stdout),
|
||||
None)
|
||||
args = ['some-tenant']
|
||||
self._test_delete_resource(resource, cmd, "some-tenant", args)
|
||||
|
||||
def test_delete_auto_allocated_topology_no_arg(self):
|
||||
resource = 'auto_allocated_topology'
|
||||
cmd = aat.DeleteAutoAllocatedTopology(test_cli20.MyApp(sys.stdout),
|
||||
None)
|
||||
args = []
|
||||
self._test_delete_resource(resource, cmd, "None", args)
|
||||
|
@ -1807,6 +1807,14 @@ class Client(ClientBase):
|
||||
self.auto_allocated_topology_path % project_id,
|
||||
params=_params)
|
||||
|
||||
@debtcollector.renames.renamed_kwarg(
|
||||
'tenant_id', 'project_id', replace=True)
|
||||
def delete_auto_allocated_topology(self, project_id, **_params):
|
||||
"""Delete a project's auto-allocated topology."""
|
||||
return self.delete(
|
||||
self.auto_allocated_topology_path % project_id,
|
||||
params=_params)
|
||||
|
||||
@debtcollector.renames.renamed_kwarg(
|
||||
'tenant_id', 'project_id', replace=True)
|
||||
def validate_auto_allocated_topology_requirements(self, project_id):
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- The ``auto-allocated-topology-delete`` command allows users to
|
||||
delete the auto allocated topology.
|
Loading…
Reference in New Issue
Block a user