Add 'description' option to os subnet (pool) create/set cmd
This patch adds '--description' option to the commands. Change-Id: Ifc2828670c3c48a87a0493d98686a5babf9b2ae7 Closes-Bug: #1614458 Closes-Bug: #1614823 Partially-Implements: blueprint network-commands-options
This commit is contained in:
parent
7e990ba1e2
commit
4265002e59
doc/source/command-objects
openstackclient
releasenotes/notes
@ -19,6 +19,7 @@ Create subnet pool
|
|||||||
[--default-prefix-length <default-prefix-length>]
|
[--default-prefix-length <default-prefix-length>]
|
||||||
[--min-prefix-length <min-prefix-length>]
|
[--min-prefix-length <min-prefix-length>]
|
||||||
[--max-prefix-length <max-prefix-length>]
|
[--max-prefix-length <max-prefix-length>]
|
||||||
|
[--description <description>]
|
||||||
[--project <project> [--project-domain <project-domain>]]
|
[--project <project> [--project-domain <project-domain>]]
|
||||||
[--address-scope <address-scope>]
|
[--address-scope <address-scope>]
|
||||||
[--default | --no-default]
|
[--default | --no-default]
|
||||||
@ -38,6 +39,10 @@ Create subnet pool
|
|||||||
|
|
||||||
Set subnet pool maximum prefix length
|
Set subnet pool maximum prefix length
|
||||||
|
|
||||||
|
.. option:: --description <description>
|
||||||
|
|
||||||
|
Set subnet pool description
|
||||||
|
|
||||||
.. option:: --project <project>
|
.. option:: --project <project>
|
||||||
|
|
||||||
Owner's project (name or ID)
|
Owner's project (name or ID)
|
||||||
@ -125,6 +130,7 @@ Set subnet pool properties
|
|||||||
[--max-prefix-length <max-prefix-length>]
|
[--max-prefix-length <max-prefix-length>]
|
||||||
[--address-scope <address-scope> | --no-address-scope]
|
[--address-scope <address-scope> | --no-address-scope]
|
||||||
[--default | --no-default]
|
[--default | --no-default]
|
||||||
|
[--description <description>]
|
||||||
<subnet-pool>
|
<subnet-pool>
|
||||||
|
|
||||||
.. option:: --name <name>
|
.. option:: --name <name>
|
||||||
@ -165,6 +171,10 @@ Set subnet pool properties
|
|||||||
|
|
||||||
Set this as a non-default subnet pool
|
Set this as a non-default subnet pool
|
||||||
|
|
||||||
|
.. option:: --description <description>
|
||||||
|
|
||||||
|
Set subnet pool description
|
||||||
|
|
||||||
.. _subnet_pool_set-subnet-pool:
|
.. _subnet_pool_set-subnet-pool:
|
||||||
.. describe:: <subnet-pool>
|
.. describe:: <subnet-pool>
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ Create new subnet
|
|||||||
[--gateway <gateway>]
|
[--gateway <gateway>]
|
||||||
[--host-route destination=<subnet>,gateway=<ip-address>]
|
[--host-route destination=<subnet>,gateway=<ip-address>]
|
||||||
[--ip-version {4,6}]
|
[--ip-version {4,6}]
|
||||||
|
[--description <description>]
|
||||||
[--ipv6-ra-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}]
|
[--ipv6-ra-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}]
|
||||||
[--ipv6-address-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}]
|
[--ipv6-address-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}]
|
||||||
[--network-segment <network-segment>]
|
[--network-segment <network-segment>]
|
||||||
@ -100,6 +101,10 @@ Create new subnet
|
|||||||
IP version is determined from the subnet pool and this option
|
IP version is determined from the subnet pool and this option
|
||||||
is ignored.
|
is ignored.
|
||||||
|
|
||||||
|
.. option:: --description <description>
|
||||||
|
|
||||||
|
Set subnet description
|
||||||
|
|
||||||
.. option:: --ipv6-ra-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}
|
.. option:: --ipv6-ra-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}
|
||||||
|
|
||||||
IPv6 RA (Router Advertisement) mode,
|
IPv6 RA (Router Advertisement) mode,
|
||||||
@ -202,6 +207,7 @@ Set subnet properties
|
|||||||
[--host-route destination=<subnet>,gateway=<ip-address>]
|
[--host-route destination=<subnet>,gateway=<ip-address>]
|
||||||
[--service-type <service-type>]
|
[--service-type <service-type>]
|
||||||
[--name <new-name>]
|
[--name <new-name>]
|
||||||
|
[--description <description>]
|
||||||
<subnet>
|
<subnet>
|
||||||
|
|
||||||
.. option:: --allocation-pool start=<ip-address>,end=<ip-address>
|
.. option:: --allocation-pool start=<ip-address>,end=<ip-address>
|
||||||
@ -243,6 +249,9 @@ Set subnet properties
|
|||||||
``network:floatingip_agent_gateway``.
|
``network:floatingip_agent_gateway``.
|
||||||
Must be a valid device owner value for a network port
|
Must be a valid device owner value for a network port
|
||||||
(repeat option to set multiple service types)
|
(repeat option to set multiple service types)
|
||||||
|
.. option:: --description <description>
|
||||||
|
|
||||||
|
Set subnet description
|
||||||
|
|
||||||
.. option:: --name
|
.. option:: --name
|
||||||
|
|
||||||
|
@ -196,6 +196,8 @@ def _get_attrs(client_manager, parsed_args, is_create=True):
|
|||||||
if ('service_types' in parsed_args and
|
if ('service_types' in parsed_args and
|
||||||
parsed_args.service_types is not None):
|
parsed_args.service_types is not None):
|
||||||
attrs['service_types'] = parsed_args.service_types
|
attrs['service_types'] = parsed_args.service_types
|
||||||
|
if parsed_args.description is not None:
|
||||||
|
attrs['description'] = parsed_args.description
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
|
||||||
@ -294,6 +296,11 @@ class CreateSubnet(command.ShowOne):
|
|||||||
metavar='<network>',
|
metavar='<network>',
|
||||||
help=_("Network this subnet belongs to (name or ID)")
|
help=_("Network this subnet belongs to (name or ID)")
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--description',
|
||||||
|
metavar='<description>',
|
||||||
|
help=_("Set subnet description")
|
||||||
|
)
|
||||||
_get_common_parse_arguments(parser)
|
_get_common_parse_arguments(parser)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
@ -447,6 +454,11 @@ class SetSubnet(command.Command):
|
|||||||
"'none': This subnet will not use a gateway, "
|
"'none': This subnet will not use a gateway, "
|
||||||
"e.g.: --gateway 192.168.9.1, --gateway none.")
|
"e.g.: --gateway 192.168.9.1, --gateway none.")
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--description',
|
||||||
|
metavar='<description>',
|
||||||
|
help=_("Set subnet description")
|
||||||
|
)
|
||||||
_get_common_parse_arguments(parser)
|
_get_common_parse_arguments(parser)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -81,6 +81,9 @@ def _get_attrs(client_manager, parsed_args):
|
|||||||
).id
|
).id
|
||||||
attrs['tenant_id'] = project_id
|
attrs['tenant_id'] = project_id
|
||||||
|
|
||||||
|
if parsed_args.description is not None:
|
||||||
|
attrs['description'] = parsed_args.description
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
|
|
||||||
@ -167,6 +170,11 @@ class CreateSubnetPool(command.ShowOne):
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help=_("Set this subnet pool as not shared"),
|
help=_("Set this subnet pool as not shared"),
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--description',
|
||||||
|
metavar='<description>',
|
||||||
|
help=_("Set subnet pool description")
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@ -299,6 +307,11 @@ class SetSubnetPool(command.Command):
|
|||||||
help=_("Remove address scope associated with the subnet pool")
|
help=_("Remove address scope associated with the subnet pool")
|
||||||
)
|
)
|
||||||
_add_default_options(parser)
|
_add_default_options(parser)
|
||||||
|
parser.add_argument(
|
||||||
|
'--description',
|
||||||
|
metavar='<description>',
|
||||||
|
help=_("Set subnet pool description")
|
||||||
|
)
|
||||||
|
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
@ -891,6 +891,7 @@ class FakeSubnet(object):
|
|||||||
'segment_id': None,
|
'segment_id': None,
|
||||||
'service_types': [],
|
'service_types': [],
|
||||||
'subnetpool_id': None,
|
'subnetpool_id': None,
|
||||||
|
'description': 'subnet-description-' + uuid.uuid4().hex,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
@ -1046,6 +1047,7 @@ class FakeSubnetPool(object):
|
|||||||
'min_prefixlen': '8',
|
'min_prefixlen': '8',
|
||||||
'default_quota': None,
|
'default_quota': None,
|
||||||
'ip_version': '4',
|
'ip_version': '4',
|
||||||
|
'description': 'subnet-pool-description-' + uuid.uuid4().hex,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Overwrite default attributes.
|
# Overwrite default attributes.
|
||||||
|
@ -110,6 +110,7 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
columns = (
|
columns = (
|
||||||
'allocation_pools',
|
'allocation_pools',
|
||||||
'cidr',
|
'cidr',
|
||||||
|
'description',
|
||||||
'dns_nameservers',
|
'dns_nameservers',
|
||||||
'enable_dhcp',
|
'enable_dhcp',
|
||||||
'gateway_ip',
|
'gateway_ip',
|
||||||
@ -129,6 +130,7 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
data = (
|
data = (
|
||||||
subnet_v2._format_allocation_pools(_subnet.allocation_pools),
|
subnet_v2._format_allocation_pools(_subnet.allocation_pools),
|
||||||
_subnet.cidr,
|
_subnet.cidr,
|
||||||
|
_subnet.description,
|
||||||
utils.format_list(_subnet.dns_nameservers),
|
utils.format_list(_subnet.dns_nameservers),
|
||||||
_subnet.enable_dhcp,
|
_subnet.enable_dhcp,
|
||||||
_subnet.gateway_ip,
|
_subnet.gateway_ip,
|
||||||
@ -148,6 +150,7 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
data_subnet_pool = (
|
data_subnet_pool = (
|
||||||
subnet_v2._format_allocation_pools(_subnet_from_pool.allocation_pools),
|
subnet_v2._format_allocation_pools(_subnet_from_pool.allocation_pools),
|
||||||
_subnet_from_pool.cidr,
|
_subnet_from_pool.cidr,
|
||||||
|
_subnet_from_pool.description,
|
||||||
utils.format_list(_subnet_from_pool.dns_nameservers),
|
utils.format_list(_subnet_from_pool.dns_nameservers),
|
||||||
_subnet_from_pool.enable_dhcp,
|
_subnet_from_pool.enable_dhcp,
|
||||||
_subnet_from_pool.gateway_ip,
|
_subnet_from_pool.gateway_ip,
|
||||||
@ -167,6 +170,7 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
data_ipv6 = (
|
data_ipv6 = (
|
||||||
subnet_v2._format_allocation_pools(_subnet_ipv6.allocation_pools),
|
subnet_v2._format_allocation_pools(_subnet_ipv6.allocation_pools),
|
||||||
_subnet_ipv6.cidr,
|
_subnet_ipv6.cidr,
|
||||||
|
_subnet_ipv6.description,
|
||||||
utils.format_list(_subnet_ipv6.dns_nameservers),
|
utils.format_list(_subnet_ipv6.dns_nameservers),
|
||||||
_subnet_ipv6.enable_dhcp,
|
_subnet_ipv6.enable_dhcp,
|
||||||
_subnet_ipv6.gateway_ip,
|
_subnet_ipv6.gateway_ip,
|
||||||
@ -427,6 +431,40 @@ class TestCreateSubnet(TestSubnet):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
|
def test_create_with_description(self):
|
||||||
|
# Mock SDK calls for this test.
|
||||||
|
self.network.create_subnet = mock.Mock(return_value=self._subnet)
|
||||||
|
self._network.id = self._subnet.network_id
|
||||||
|
|
||||||
|
arglist = [
|
||||||
|
"--subnet-range", self._subnet.cidr,
|
||||||
|
"--network", self._subnet.network_id,
|
||||||
|
"--description", self._subnet.description,
|
||||||
|
self._subnet.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('name', self._subnet.name),
|
||||||
|
('description', self._subnet.description),
|
||||||
|
('subnet_range', self._subnet.cidr),
|
||||||
|
('network', self._subnet.network_id),
|
||||||
|
('ip_version', self._subnet.ip_version),
|
||||||
|
('gateway', 'auto'),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.network.create_subnet.assert_called_once_with(**{
|
||||||
|
'cidr': self._subnet.cidr,
|
||||||
|
'ip_version': self._subnet.ip_version,
|
||||||
|
'name': self._subnet.name,
|
||||||
|
'network_id': self._subnet.network_id,
|
||||||
|
'description': self._subnet.description,
|
||||||
|
})
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
|
|
||||||
class TestDeleteSubnet(TestSubnet):
|
class TestDeleteSubnet(TestSubnet):
|
||||||
|
|
||||||
@ -768,6 +806,30 @@ class TestSetSubnet(TestSubnet):
|
|||||||
_testsubnet, **attrs)
|
_testsubnet, **attrs)
|
||||||
self.assertIsNone(result)
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
def test_set_non_append_options(self):
|
||||||
|
arglist = [
|
||||||
|
"--description", "new_description",
|
||||||
|
"--dhcp",
|
||||||
|
"--gateway", self._subnet.gateway_ip,
|
||||||
|
self._subnet.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('description', "new_description"),
|
||||||
|
('dhcp', True),
|
||||||
|
('gateway', self._subnet.gateway_ip),
|
||||||
|
('subnet', self._subnet.name),
|
||||||
|
]
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
attrs = {
|
||||||
|
'enable_dhcp': True,
|
||||||
|
'gateway_ip': self._subnet.gateway_ip,
|
||||||
|
'description': "new_description",
|
||||||
|
}
|
||||||
|
self.network.update_subnet.assert_called_with(self._subnet, **attrs)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
|
||||||
class TestShowSubnet(TestSubnet):
|
class TestShowSubnet(TestSubnet):
|
||||||
# The subnets to be shown
|
# The subnets to be shown
|
||||||
@ -776,6 +838,7 @@ class TestShowSubnet(TestSubnet):
|
|||||||
columns = (
|
columns = (
|
||||||
'allocation_pools',
|
'allocation_pools',
|
||||||
'cidr',
|
'cidr',
|
||||||
|
'description',
|
||||||
'dns_nameservers',
|
'dns_nameservers',
|
||||||
'enable_dhcp',
|
'enable_dhcp',
|
||||||
'gateway_ip',
|
'gateway_ip',
|
||||||
@ -795,6 +858,7 @@ class TestShowSubnet(TestSubnet):
|
|||||||
data = (
|
data = (
|
||||||
subnet_v2._format_allocation_pools(_subnet.allocation_pools),
|
subnet_v2._format_allocation_pools(_subnet.allocation_pools),
|
||||||
_subnet.cidr,
|
_subnet.cidr,
|
||||||
|
_subnet.description,
|
||||||
utils.format_list(_subnet.dns_nameservers),
|
utils.format_list(_subnet.dns_nameservers),
|
||||||
_subnet.enable_dhcp,
|
_subnet.enable_dhcp,
|
||||||
_subnet.gateway_ip,
|
_subnet.gateway_ip,
|
||||||
|
@ -50,6 +50,7 @@ class TestCreateSubnetPool(TestSubnetPool):
|
|||||||
'address_scope_id',
|
'address_scope_id',
|
||||||
'default_prefixlen',
|
'default_prefixlen',
|
||||||
'default_quota',
|
'default_quota',
|
||||||
|
'description',
|
||||||
'id',
|
'id',
|
||||||
'ip_version',
|
'ip_version',
|
||||||
'is_default',
|
'is_default',
|
||||||
@ -64,6 +65,7 @@ class TestCreateSubnetPool(TestSubnetPool):
|
|||||||
_subnet_pool.address_scope_id,
|
_subnet_pool.address_scope_id,
|
||||||
_subnet_pool.default_prefixlen,
|
_subnet_pool.default_prefixlen,
|
||||||
_subnet_pool.default_quota,
|
_subnet_pool.default_quota,
|
||||||
|
_subnet_pool.description,
|
||||||
_subnet_pool.id,
|
_subnet_pool.id,
|
||||||
_subnet_pool.ip_version,
|
_subnet_pool.ip_version,
|
||||||
_subnet_pool.is_default,
|
_subnet_pool.is_default,
|
||||||
@ -245,6 +247,29 @@ class TestCreateSubnetPool(TestSubnetPool):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
|
def test_create_with_description(self):
|
||||||
|
arglist = [
|
||||||
|
'--pool-prefix', '10.0.10.0/24',
|
||||||
|
'--description', self._subnet_pool.description,
|
||||||
|
self._subnet_pool.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('prefixes', ['10.0.10.0/24']),
|
||||||
|
('description', self._subnet_pool.description),
|
||||||
|
('name', self._subnet_pool.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = (self.cmd.take_action(parsed_args))
|
||||||
|
|
||||||
|
self.network.create_subnet_pool.assert_called_once_with(**{
|
||||||
|
'name': self._subnet_pool.name,
|
||||||
|
'prefixes': ['10.0.10.0/24'],
|
||||||
|
'description': self._subnet_pool.description,
|
||||||
|
})
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
|
|
||||||
class TestDeleteSubnetPool(TestSubnetPool):
|
class TestDeleteSubnetPool(TestSubnetPool):
|
||||||
|
|
||||||
@ -611,6 +636,26 @@ class TestSetSubnetPool(TestSubnetPool):
|
|||||||
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
self.assertRaises(tests_utils.ParserException, self.check_parser,
|
||||||
self.cmd, arglist, verifylist)
|
self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
def test_set_description(self):
|
||||||
|
arglist = [
|
||||||
|
'--description', 'new_description',
|
||||||
|
self._subnet_pool.name,
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('description', "new_description"),
|
||||||
|
('subnet_pool', self._subnet_pool.name),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
result = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
attrs = {
|
||||||
|
'description': "new_description",
|
||||||
|
}
|
||||||
|
self.network.update_subnet_pool.assert_called_once_with(
|
||||||
|
self._subnet_pool, **attrs)
|
||||||
|
self.assertIsNone(result)
|
||||||
|
|
||||||
|
|
||||||
class TestShowSubnetPool(TestSubnetPool):
|
class TestShowSubnetPool(TestSubnetPool):
|
||||||
|
|
||||||
@ -621,6 +666,7 @@ class TestShowSubnetPool(TestSubnetPool):
|
|||||||
'address_scope_id',
|
'address_scope_id',
|
||||||
'default_prefixlen',
|
'default_prefixlen',
|
||||||
'default_quota',
|
'default_quota',
|
||||||
|
'description',
|
||||||
'id',
|
'id',
|
||||||
'ip_version',
|
'ip_version',
|
||||||
'is_default',
|
'is_default',
|
||||||
@ -636,6 +682,7 @@ class TestShowSubnetPool(TestSubnetPool):
|
|||||||
_subnet_pool.address_scope_id,
|
_subnet_pool.address_scope_id,
|
||||||
_subnet_pool.default_prefixlen,
|
_subnet_pool.default_prefixlen,
|
||||||
_subnet_pool.default_quota,
|
_subnet_pool.default_quota,
|
||||||
|
_subnet_pool.description,
|
||||||
_subnet_pool.id,
|
_subnet_pool.id,
|
||||||
_subnet_pool.ip_version,
|
_subnet_pool.ip_version,
|
||||||
_subnet_pool.is_default,
|
_subnet_pool.is_default,
|
||||||
|
6
releasenotes/notes/bug-1614458-c42be5738f447db8.yaml
Normal file
6
releasenotes/notes/bug-1614458-c42be5738f447db8.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Adds ``description`` option to ``subnet create`` and
|
||||||
|
``subnet set`` commands.
|
||||||
|
[Bug `1614458 <https://bugs.launchpad.net/bugs/1614458>`_]
|
6
releasenotes/notes/bug-1614823-e89080342f25f2c0.yaml
Normal file
6
releasenotes/notes/bug-1614823-e89080342f25f2c0.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Adds ``description`` option to ``subnet pool create``
|
||||||
|
and ``subnet pool set`` commands.
|
||||||
|
[Bug `1614823 <https://bugs.launchpad.net/bugs/1614823>`_]
|
Loading…
x
Reference in New Issue
Block a user