Skip to content

Commit a051bda

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Add DNS support to floating IP commands"
2 parents c387f83 + ed09f28 commit a051bda

4 files changed

Lines changed: 64 additions & 1 deletion

File tree

doc/source/cli/command-objects/floating-ip.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Create floating IP
2121
[--qos-policy <qos-policy>]
2222
[--project <project> [--project-domain <project-domain>]]
2323
[--tag <tag> | --no-tag]
24+
[--dns-domain <dns-domain>]
25+
[--dns-name <dns-name>]
2426
<network>
2527
2628
.. option:: --subnet <subnet>
@@ -79,6 +81,14 @@ Create floating IP
7981
8082
*Network version 2 only*
8183
84+
.. option:: --dns-domain <dns-domain>
85+
86+
Set DNS domain for this floating IP (requires DNS integration extension).
87+
88+
.. option:: --dns-name <dns-name>
89+
90+
Set DNS name for this floating IP (requires DNS integration extension).
91+
8292
.. describe:: <network>
8393
8494
Network to allocate floating IP from (name or ID)

openstackclient/network/v2/floating_ip.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ def _get_attrs(client_manager, parsed_args):
8585
).id
8686
attrs['tenant_id'] = project_id
8787

88+
if parsed_args.dns_domain:
89+
attrs['dns_domain'] = parsed_args.dns_domain
90+
91+
if parsed_args.dns_name:
92+
attrs['dns_name'] = parsed_args.dns_name
93+
8894
return attrs
8995

9096

@@ -142,15 +148,32 @@ def update_parser_network(self, parser):
142148
metavar='<project>',
143149
help=_("Owner's project (name or ID)")
144150
)
151+
parser.add_argument(
152+
'--dns-domain',
153+
metavar='<dns-domain>',
154+
dest='dns_domain',
155+
help=_("Set DNS domain for this floating IP")
156+
)
157+
parser.add_argument(
158+
'--dns-name',
159+
metavar='<dns-name>',
160+
dest='dns_name',
161+
help=_("Set DNS name for this floating IP")
162+
)
163+
145164
identity_common.add_project_domain_option_to_parser(parser)
146165
_tag.add_tag_option_to_parser_for_create(parser, _('floating IP'))
147166
return parser
148167

149168
def take_action_network(self, client, parsed_args):
150169
attrs = _get_attrs(self.app.client_manager, parsed_args)
151-
obj = client.create_ip(**attrs)
170+
with common.check_missing_extension_if_error(
171+
self.app.client_manager.network, attrs):
172+
obj = client.create_ip(**attrs)
173+
152174
# tags cannot be set when created, so tags need to be set later.
153175
_tag.update_tags_for_set(client, obj, parsed_args)
176+
154177
display_columns, columns = _get_network_columns(obj)
155178
data = utils.get_item_properties(obj, columns)
156179
return (display_columns, data)
@@ -269,12 +292,16 @@ def take_action_network(self, client, parsed_args):
269292
'status',
270293
'description',
271294
'tags',
295+
'dns_name',
296+
'dns_domain',
272297
)
273298
headers = headers + (
274299
'Router',
275300
'Status',
276301
'Description',
277302
'Tags',
303+
'DNS Name',
304+
'DNS Domain',
278305
)
279306

280307
query = {}

openstackclient/tests/unit/network/v2/test_floating_ip_network.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork):
4949
attrs={
5050
'floating_network_id': floating_network.id,
5151
'port_id': port.id,
52+
'dns_domain': 'example.org.',
53+
'dns_name': 'fip1',
5254
}
5355
)
5456

@@ -129,6 +131,8 @@ def test_create_all_options(self):
129131
'--floating-ip-address', self.floating_ip.floating_ip_address,
130132
'--fixed-ip-address', self.floating_ip.fixed_ip_address,
131133
'--description', self.floating_ip.description,
134+
'--dns-domain', self.floating_ip.dns_domain,
135+
'--dns-name', self.floating_ip.dns_name,
132136
self.floating_ip.floating_network_id,
133137
]
134138
verifylist = [
@@ -137,6 +141,8 @@ def test_create_all_options(self):
137141
('fixed_ip_address', self.floating_ip.fixed_ip_address),
138142
('network', self.floating_ip.floating_network_id),
139143
('description', self.floating_ip.description),
144+
('dns_domain', self.floating_ip.dns_domain),
145+
('dns_name', self.floating_ip.dns_name),
140146
('floating_ip_address', self.floating_ip.floating_ip_address),
141147
]
142148
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -150,6 +156,8 @@ def test_create_all_options(self):
150156
'fixed_ip_address': self.floating_ip.fixed_ip_address,
151157
'floating_network_id': self.floating_ip.floating_network_id,
152158
'description': self.floating_ip.description,
159+
'dns_domain': self.floating_ip.dns_domain,
160+
'dns_name': self.floating_ip.dns_name,
153161
})
154162
self.assertEqual(self.columns, columns)
155163
self.assertEqual(self.data, data)
@@ -393,6 +401,8 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork):
393401
'Status',
394402
'Description',
395403
'Tags',
404+
'DNS Name',
405+
'DNS Domain',
396406
)
397407

398408
data = []
@@ -417,6 +427,8 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork):
417427
ip.status,
418428
ip.description,
419429
ip.tags,
430+
ip.dns_domain,
431+
ip.dns_name,
420432
))
421433

422434
def setUp(self):
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
features:
3+
- |
4+
Add ``--dns-domain`` and ``--dns-name`` options to the
5+
``floating ip create`` commands. These options
6+
set the DNS domain and name for the floating IP.
7+
8+
Check backend available extension and return an error
9+
message if it is missing (instead of a Bad Request HTTP 400).
10+
[Bug `1547736 <https://storyboard.openstack.org/#!/story/1547736>`_]
11+
- |
12+
Add ``--long`` option to the ``floating ip list`` command. This adds
13+
``DNS Name`` and ``DNS Domain`` columns to the floating IP list.
14+
[Bug `1547736 <https://storyboard.openstack.org/#!/story/1547736>`_]

0 commit comments

Comments
 (0)