summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-09-23 18:26:55 +0000
committerGerrit Code Review <review@openstack.org>2016-09-23 18:26:55 +0000
commit578cd12dfb2140da48dd5f8d2ed3e6a3e2906a2d (patch)
treebb21d1a777e3749b615550d4126f3a4ab47c0976
parentb0750c76eca8e8ec8849f70c839fac550d33f28c (diff)
parent0981931628cdea07793850631595cf7299badeaa (diff)
downloadpython-openstackclient-578cd12dfb2140da48dd5f8d2ed3e6a3e2906a2d.tar.gz
Merge "Add --description to Neutron commands"
-rw-r--r--doc/source/command-objects/floating-ip.rst6
-rw-r--r--doc/source/command-objects/router.rst10
-rw-r--r--openstackclient/network/v2/floating_ip.py8
-rw-r--r--openstackclient/network/v2/router.py13
-rw-r--r--openstackclient/tests/unit/network/v2/fakes.py2
-rw-r--r--openstackclient/tests/unit/network/v2/test_floating_ip.py9
-rw-r--r--openstackclient/tests/unit/network/v2/test_router.py7
-rw-r--r--releasenotes/notes/bp-neutron-client-descriptions-a80902b4295843cf.yaml7
8 files changed, 60 insertions, 2 deletions
diff --git a/doc/source/command-objects/floating-ip.rst b/doc/source/command-objects/floating-ip.rst
index 093bb8e4..2ab21f36 100644
--- a/doc/source/command-objects/floating-ip.rst
+++ b/doc/source/command-objects/floating-ip.rst
@@ -17,6 +17,7 @@ Create floating IP
[--port <port>]
[--floating-ip-address <floating-ip-address>]
[--fixed-ip-address <fixed-ip-address>]
+ [--description <description>]
<network>
.. option:: --subnet <subnet>
@@ -39,6 +40,11 @@ Create floating IP
Fixed IP address mapped to the floating IP
*Network version 2 only*
+.. option:: --description <description>
+
+ Set floating IP description
+ *Network version 2 only*
+
.. describe:: <network>
Network to allocate floating IP from (name or ID)
diff --git a/doc/source/command-objects/router.rst b/doc/source/command-objects/router.rst
index bbdca054..13a75158 100644
--- a/doc/source/command-objects/router.rst
+++ b/doc/source/command-objects/router.rst
@@ -64,6 +64,7 @@ Create new router
[--project <project> [--project-domain <project-domain>]]
[--enable | --disable]
[--distributed]
+ [--description <description>]
[--availability-zone-hint <availability-zone>]
<name>
@@ -88,6 +89,10 @@ Create new router
Create a distributed router
+.. option:: --description <description>
+
+ Set router description
+
.. option:: --availability-zone-hint <availability-zone>
Availability Zone in which to create this router
@@ -186,6 +191,7 @@ Set router properties
[--name <name>]
[--enable | --disable]
[--distributed | --centralized]
+ [--description <description>]
[--route destination=<subnet>,gateway=<ip-address> | --no-route]
<router>
@@ -209,6 +215,10 @@ Set router properties
Set router to centralized mode (disabled router only)
+.. option:: --description <description>
+
+ Set router description
+
.. option:: --route destination=<subnet>,gateway=<ip-address>
Routes associated with the router
diff --git a/openstackclient/network/v2/floating_ip.py b/openstackclient/network/v2/floating_ip.py
index 454335f1..bb75540c 100644
--- a/openstackclient/network/v2/floating_ip.py
+++ b/openstackclient/network/v2/floating_ip.py
@@ -55,6 +55,9 @@ def _get_attrs(client_manager, parsed_args):
if parsed_args.fixed_ip_address:
attrs['fixed_ip_address'] = parsed_args.fixed_ip_address
+ if parsed_args.description is not None:
+ attrs['description'] = parsed_args.description
+
return attrs
@@ -97,6 +100,11 @@ class CreateFloatingIP(common.NetworkAndComputeShowOne):
dest='fixed_ip_address',
help=_("Fixed IP address mapped to the floating IP")
)
+ parser.add_argument(
+ '--description',
+ metavar='<description>',
+ help=_('Set floating IP description')
+ )
return parser
def take_action_network(self, client, parsed_args):
diff --git a/openstackclient/network/v2/router.py b/openstackclient/network/v2/router.py
index 03134b8c..cb40d774 100644
--- a/openstackclient/network/v2/router.py
+++ b/openstackclient/network/v2/router.py
@@ -82,7 +82,8 @@ def _get_attrs(client_manager, parsed_args):
if ('availability_zone_hints' in parsed_args
and parsed_args.availability_zone_hints is not None):
attrs['availability_zone_hints'] = parsed_args.availability_zone_hints
-
+ if parsed_args.description is not None:
+ attrs['description'] = parsed_args.description
# "router set" command doesn't support setting project.
if 'project' in parsed_args and parsed_args.project is not None:
identity_client = client_manager.identity
@@ -180,6 +181,11 @@ class CreateRouter(command.ShowOne):
help=_("Create a distributed router")
)
parser.add_argument(
+ '--description',
+ metavar='<description>',
+ help=_('Set router description')
+ )
+ parser.add_argument(
'--project',
metavar='<project>',
help=_("Owner's project (name or ID)")
@@ -370,6 +376,11 @@ class SetRouter(command.Command):
metavar='<name>',
help=_("Set router name")
)
+ parser.add_argument(
+ '--description',
+ metavar='<description>',
+ help=_('Set router description')
+ )
admin_group = parser.add_mutually_exclusive_group()
admin_group.add_argument(
'--enable',
diff --git a/openstackclient/tests/unit/network/v2/fakes.py b/openstackclient/tests/unit/network/v2/fakes.py
index 91aebf9f..d7ebd0bc 100644
--- a/openstackclient/tests/unit/network/v2/fakes.py
+++ b/openstackclient/tests/unit/network/v2/fakes.py
@@ -654,6 +654,7 @@ class FakeRouter(object):
'name': 'router-name-' + uuid.uuid4().hex,
'status': 'ACTIVE',
'admin_state_up': True,
+ 'description': 'router-description-' + uuid.uuid4().hex,
'distributed': False,
'ha': False,
'tenant_id': 'project-id-' + uuid.uuid4().hex,
@@ -973,6 +974,7 @@ class FakeFloatingIP(object):
'router_id': 'router-id-' + uuid.uuid4().hex,
'port_id': 'port-id-' + uuid.uuid4().hex,
'tenant_id': 'project-id-' + uuid.uuid4().hex,
+ 'description': 'floating-ip-description-' + uuid.uuid4().hex,
}
# Overwrite default attributes.
diff --git a/openstackclient/tests/unit/network/v2/test_floating_ip.py b/openstackclient/tests/unit/network/v2/test_floating_ip.py
index a77fb24b..1f30f2e9 100644
--- a/openstackclient/tests/unit/network/v2/test_floating_ip.py
+++ b/openstackclient/tests/unit/network/v2/test_floating_ip.py
@@ -49,6 +49,7 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
)
columns = (
+ 'description',
'dns_domain',
'dns_name',
'fixed_ip_address',
@@ -62,6 +63,7 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
)
data = (
+ floating_ip.description,
floating_ip.dns_domain,
floating_ip.dns_name,
floating_ip.fixed_ip_address,
@@ -117,14 +119,16 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
'--port', self.floating_ip.port_id,
'--floating-ip-address', self.floating_ip.floating_ip_address,
'--fixed-ip-address', self.floating_ip.fixed_ip_address,
+ '--description', self.floating_ip.description,
self.floating_ip.floating_network_id,
]
verifylist = [
('subnet', self.subnet.id),
('port', self.floating_ip.port_id),
- ('floating_ip_address', self.floating_ip.floating_ip_address),
('fixed_ip_address', self.floating_ip.fixed_ip_address),
('network', self.floating_ip.floating_network_id),
+ ('description', self.floating_ip.description),
+ ('floating_ip_address', self.floating_ip.floating_ip_address),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -136,6 +140,7 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
'floating_ip_address': self.floating_ip.floating_ip_address,
'fixed_ip_address': self.floating_ip.fixed_ip_address,
'floating_network_id': self.floating_ip.floating_network_id,
+ 'description': self.floating_ip.description,
})
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, data)
@@ -269,6 +274,7 @@ class TestShowFloatingIPNetwork(TestFloatingIPNetwork):
floating_ip = network_fakes.FakeFloatingIP.create_one_floating_ip()
columns = (
+ 'description',
'dns_domain',
'dns_name',
'fixed_ip_address',
@@ -282,6 +288,7 @@ class TestShowFloatingIPNetwork(TestFloatingIPNetwork):
)
data = (
+ floating_ip.description,
floating_ip.dns_domain,
floating_ip.dns_name,
floating_ip.fixed_ip_address,
diff --git a/openstackclient/tests/unit/network/v2/test_router.py b/openstackclient/tests/unit/network/v2/test_router.py
index 5ed969b4..d12289e1 100644
--- a/openstackclient/tests/unit/network/v2/test_router.py
+++ b/openstackclient/tests/unit/network/v2/test_router.py
@@ -118,6 +118,7 @@ class TestCreateRouter(TestRouter):
'admin_state_up',
'availability_zone_hints',
'availability_zones',
+ 'description',
'distributed',
'external_gateway_info',
'ha',
@@ -131,6 +132,7 @@ class TestCreateRouter(TestRouter):
router._format_admin_state(new_router.admin_state_up),
osc_utils.format_list(new_router.availability_zone_hints),
osc_utils.format_list(new_router.availability_zones),
+ new_router.description,
new_router.distributed,
router._format_external_gateway_info(new_router.external_gateway_info),
new_router.ha,
@@ -502,12 +504,14 @@ class TestSetRouter(TestRouter):
'--enable',
'--distributed',
'--name', 'noob',
+ '--description', 'router',
]
verifylist = [
('router', self._router.name),
('enable', True),
('distributed', True),
('name', 'noob'),
+ ('description', 'router'),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -517,6 +521,7 @@ class TestSetRouter(TestRouter):
'admin_state_up': True,
'distributed': True,
'name': 'noob',
+ 'description': 'router',
}
self.network.update_router.assert_called_once_with(
self._router, **attrs)
@@ -680,6 +685,7 @@ class TestShowRouter(TestRouter):
'admin_state_up',
'availability_zone_hints',
'availability_zones',
+ 'description',
'distributed',
'external_gateway_info',
'ha',
@@ -693,6 +699,7 @@ class TestShowRouter(TestRouter):
router._format_admin_state(_router.admin_state_up),
osc_utils.format_list(_router.availability_zone_hints),
osc_utils.format_list(_router.availability_zones),
+ _router.description,
_router.distributed,
router._format_external_gateway_info(_router.external_gateway_info),
_router.ha,
diff --git a/releasenotes/notes/bp-neutron-client-descriptions-a80902b4295843cf.yaml b/releasenotes/notes/bp-neutron-client-descriptions-a80902b4295843cf.yaml
new file mode 100644
index 00000000..3c4f4a50
--- /dev/null
+++ b/releasenotes/notes/bp-neutron-client-descriptions-a80902b4295843cf.yaml
@@ -0,0 +1,7 @@
+---
+features:
+ - |
+ Add ``--description`` option for core network resources. Allows users to
+ set a description for: ``floating ip create`` and ``router set/create``.
+ [Blueprint :oscbp:`neutron-client-descriptions`]
+ [Blueprint :oscbp:`network-commands-options`]