summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssaf Muller <amuller@redhat.com>2014-08-14 15:47:45 +0300
committerAssaf Muller <amuller@redhat.com>2014-09-11 21:40:48 +0300
commit9660c7da2761c2d6ac0f67a8ceae5488c52f402b (patch)
tree9f73ad82ded667ec93176593a0538bdc486526c7
parent46630bad74174adfcf1cfff9b60be89b168cc406 (diff)
downloadpython-neutronclient-9660c7da2761c2d6ac0f67a8ceae5488c52f402b.tar.gz
Add L3 HA / VRRP support to CLI
Change-Id: Ia1f758f5536780a3170d624d61a3b2fa66eff76e Partially-implements: blueprint l3-high-availability
-rw-r--r--neutronclient/neutron/v2_0/router.py10
-rw-r--r--neutronclient/tests/unit/test_cli20_router.py25
2 files changed, 28 insertions, 7 deletions
diff --git a/neutronclient/neutron/v2_0/router.py b/neutronclient/neutron/v2_0/router.py
index 5d03877..cd1cf51 100644
--- a/neutronclient/neutron/v2_0/router.py
+++ b/neutronclient/neutron/v2_0/router.py
@@ -36,7 +36,7 @@ class ListRouter(neutronV20.ListCommand):
resource = 'router'
_formatters = {'external_gateway_info': _format_external_gateway_info, }
- list_columns = ['id', 'name', 'external_gateway_info', 'distributed']
+ list_columns = ['id', 'name', 'external_gateway_info', 'distributed', 'ha']
pagination_support = True
sorting_support = True
@@ -71,11 +71,17 @@ class CreateRouter(neutronV20.CreateCommand):
choices=['True', 'False'],
default=argparse.SUPPRESS,
help=_('Create a distributed router.'))
+ parser.add_argument(
+ '--ha',
+ dest='ha',
+ choices=['True', 'False'],
+ default=argparse.SUPPRESS,
+ help=_('Create a highly available router.'))
def args2body(self, parsed_args):
body = {self.resource: {'admin_state_up': parsed_args.admin_state}}
neutronV20.update_dict(parsed_args, body[self.resource],
- ['name', 'tenant_id', 'distributed'])
+ ['name', 'tenant_id', 'distributed', 'ha'])
return body
diff --git a/neutronclient/tests/unit/test_cli20_router.py b/neutronclient/tests/unit/test_cli20_router.py
index 372c15f..6320750 100644
--- a/neutronclient/tests/unit/test_cli20_router.py
+++ b/neutronclient/tests/unit/test_cli20_router.py
@@ -60,19 +60,34 @@ class CLITestV20RouterJSON(test_cli20.CLITestV20Base):
position_names, position_values,
admin_state_up=False)
- def test_create_router_distributed(self):
- """Create router: --distributed=True myname."""
+ def _create_router_distributed_or_ha(self, distributed=None, ha=None):
+ """Create router: --distributed distributed --ha ha myname."""
resource = 'router'
cmd = router.CreateRouter(test_cli20.MyApp(sys.stdout), None)
name = 'myname'
myid = 'myid'
- distributed = 'True'
- args = ['--distributed', distributed, name, ]
+ args = []
+ if distributed is not None:
+ args += ['--distributed', str(distributed)]
+ if ha is not None:
+ args += ['--ha', str(ha)]
+ args.append(name)
position_names = ['name', ]
position_values = [name, ]
+ expected = {}
+ if distributed is not None:
+ expected['distributed'] = str(distributed)
+ if ha is not None:
+ expected['ha'] = str(ha)
self._test_create_resource(resource, cmd, name, myid, args,
position_names, position_values,
- distributed=distributed)
+ **expected)
+
+ def test_create_router_distributed(self):
+ self._create_router_distributed_or_ha(distributed=True)
+
+ def test_create_router_ha(self):
+ self._create_router_distributed_or_ha(ha=True)
def test_list_routers_detail(self):
"""list routers: -D."""