Add "dns-name" option to "os port create" and "os port set"
This patch added a "dns-name" option to "os port create" and "os port set" command. Change-Id: I360e2c9a1970e64fe17e4561d7618f860b937373 Co-Authored-By: Ha Van Tu <tuhv@vn.fujitsu.com> Partial-Bug: #1612136 Partially-Implements: blueprint network-commands-options
This commit is contained in:
parent
c0dd8086e5
commit
df5f12b135
@ -28,6 +28,7 @@ Create new port
|
||||
[--enable | --disable]
|
||||
[--mac-address <mac-address>]
|
||||
[--security-group <security-group> | --no-security-group]
|
||||
[--dns-name <dns-name>]
|
||||
[--project <project> [--project-domain <project-domain>]]
|
||||
[--enable-port-security | --disable-port-security]
|
||||
<name>
|
||||
@ -91,6 +92,11 @@ Create new port
|
||||
|
||||
Associate no security groups with this port
|
||||
|
||||
.. option:: --dns-name <dns-name>
|
||||
|
||||
Set DNS name to this port
|
||||
(requires DNS integration extension)
|
||||
|
||||
.. option:: --project <project>
|
||||
|
||||
Owner's project (name or ID)
|
||||
@ -192,6 +198,7 @@ Set port properties
|
||||
[--security-group <security-group>]
|
||||
[--no-security-group]
|
||||
[--enable-port-security | --disable-port-security]
|
||||
[--dns-name <dns-name>]
|
||||
<port>
|
||||
|
||||
.. option:: --description <description>
|
||||
@ -269,6 +276,11 @@ Set port properties
|
||||
|
||||
Disable port security for this port
|
||||
|
||||
.. option:: --dns-name <dns-name>
|
||||
|
||||
Set DNS name to this port
|
||||
(requires DNS integration extension)
|
||||
|
||||
.. _port_set-port:
|
||||
.. describe:: <port>
|
||||
|
||||
|
@ -128,6 +128,8 @@ def _get_attrs(client_manager, parsed_args):
|
||||
if parsed_args.host:
|
||||
attrs['binding:host_id'] = parsed_args.host
|
||||
|
||||
if parsed_args.dns_name is not None:
|
||||
attrs['dns_name'] = parsed_args.dns_name
|
||||
# It is possible that name is not updated during 'port set'
|
||||
if parsed_args.name is not None:
|
||||
attrs['name'] = str(parsed_args.name)
|
||||
@ -233,6 +235,12 @@ def _add_updatable_args(parser):
|
||||
metavar='<host-id>',
|
||||
help=argparse.SUPPRESS,
|
||||
)
|
||||
parser.add_argument(
|
||||
'--dns-name',
|
||||
metavar='dns-name',
|
||||
help=_("Set DNS name to this port "
|
||||
"(requires DNS integration extension)")
|
||||
)
|
||||
|
||||
|
||||
class CreatePort(command.ShowOne):
|
||||
|
@ -140,6 +140,7 @@ class TestCreatePort(TestPort):
|
||||
'--binding-profile', 'foo=bar',
|
||||
'--binding-profile', 'foo2=bar2',
|
||||
'--network', self._port.network_id,
|
||||
'--dns-name', '8.8.8.8',
|
||||
'test-port',
|
||||
|
||||
]
|
||||
@ -156,6 +157,7 @@ class TestCreatePort(TestPort):
|
||||
('vnic_type', 'macvtap'),
|
||||
('binding_profile', {'foo': 'bar', 'foo2': 'bar2'}),
|
||||
('network', self._port.network_id),
|
||||
('dns_name', '8.8.8.8'),
|
||||
('name', 'test-port'),
|
||||
|
||||
]
|
||||
@ -174,6 +176,7 @@ class TestCreatePort(TestPort):
|
||||
'binding:vnic_type': 'macvtap',
|
||||
'binding:profile': {'foo': 'bar', 'foo2': 'bar2'},
|
||||
'network_id': self._port.network_id,
|
||||
'dns_name': '8.8.8.8',
|
||||
'name': 'test-port',
|
||||
})
|
||||
|
||||
@ -241,6 +244,7 @@ class TestCreatePort(TestPort):
|
||||
'--security-group', secgroup.id,
|
||||
'test-port',
|
||||
]
|
||||
|
||||
verifylist = [
|
||||
('network', self._port.network_id,),
|
||||
('enable', True),
|
||||
@ -262,6 +266,33 @@ class TestCreatePort(TestPort):
|
||||
self.assertEqual(ref_columns, columns)
|
||||
self.assertEqual(ref_data, data)
|
||||
|
||||
def test_create_port_with_dns_name(self):
|
||||
arglist = [
|
||||
'--network', self._port.network_id,
|
||||
'--dns-name', '8.8.8.8',
|
||||
'test-port',
|
||||
]
|
||||
verifylist = [
|
||||
('network', self._port.network_id,),
|
||||
('enable', True),
|
||||
('dns_name', '8.8.8.8'),
|
||||
('name', 'test-port'),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
columns, data = (self.cmd.take_action(parsed_args))
|
||||
|
||||
self.network.create_port.assert_called_once_with(**{
|
||||
'admin_state_up': True,
|
||||
'network_id': self._port.network_id,
|
||||
'dns_name': '8.8.8.8',
|
||||
'name': 'test-port',
|
||||
})
|
||||
|
||||
ref_columns, ref_data = self._get_common_cols_data(self._port)
|
||||
self.assertEqual(ref_columns, columns)
|
||||
self.assertEqual(ref_data, data)
|
||||
|
||||
def test_create_with_security_groups(self):
|
||||
sg_1 = network_fakes.FakeSecurityGroup.create_one_security_group()
|
||||
sg_2 = network_fakes.FakeSecurityGroup.create_one_security_group()
|
||||
@ -676,6 +707,25 @@ class TestSetPort(TestPort):
|
||||
self.network.update_port.assert_called_once_with(self._port, **attrs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_set_dns_name(self):
|
||||
arglist = [
|
||||
'--dns-name', '8.8.8.8',
|
||||
self._port.name,
|
||||
]
|
||||
verifylist = [
|
||||
('dns_name', '8.8.8.8'),
|
||||
('port', self._port.name),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
result = self.cmd.take_action(parsed_args)
|
||||
|
||||
attrs = {
|
||||
'dns_name': '8.8.8.8',
|
||||
}
|
||||
self.network.update_port.assert_called_once_with(self._port, **attrs)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_append_fixed_ip(self):
|
||||
_testport = network_fakes.FakePort.create_one_port(
|
||||
{'fixed_ips': [{'ip_address': '0.0.0.1'}]})
|
||||
|
5
releasenotes/notes/bug-1612136-63aac6377209db38.yaml
Normal file
5
releasenotes/notes/bug-1612136-63aac6377209db38.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``--dns-name`` option to ``os port create`` and ``os port set`` commands.
|
||||
[Bug `1612136 <https://bugs.launchpad.net/python-openstackclient/+bug/1612136>`_]
|
Loading…
Reference in New Issue
Block a user