diff --git a/doc/source/cli/command-objects/floating-ip.rst b/doc/source/cli/command-objects/floating-ip.rst index c0ba7ebf35..aaa6c7a19d 100644 --- a/doc/source/cli/command-objects/floating-ip.rst +++ b/doc/source/cli/command-objects/floating-ip.rst @@ -21,6 +21,8 @@ Create floating IP [--qos-policy ] [--project [--project-domain ]] [--tag | --no-tag] + [--dns-domain ] + [--dns-name ] .. option:: --subnet @@ -79,6 +81,14 @@ Create floating IP *Network version 2 only* +.. option:: --dns-domain + + Set DNS domain for this floating IP (requires DNS integration extension). + +.. option:: --dns-name + + Set DNS name for this floating IP (requires DNS integration extension). + .. describe:: Network to allocate floating IP from (name or ID) diff --git a/openstackclient/network/v2/floating_ip.py b/openstackclient/network/v2/floating_ip.py index f51baed578..5e6c331ab6 100644 --- a/openstackclient/network/v2/floating_ip.py +++ b/openstackclient/network/v2/floating_ip.py @@ -82,6 +82,12 @@ def _get_attrs(client_manager, parsed_args): ).id attrs['tenant_id'] = project_id + if parsed_args.dns_domain: + attrs['dns_domain'] = parsed_args.dns_domain + + if parsed_args.dns_name: + attrs['dns_name'] = parsed_args.dns_name + return attrs @@ -139,15 +145,32 @@ class CreateFloatingIP(common.NetworkAndComputeShowOne): metavar='', help=_("Owner's project (name or ID)") ) + parser.add_argument( + '--dns-domain', + metavar='', + dest='dns_domain', + help=_("Set DNS domain for this floating IP") + ) + parser.add_argument( + '--dns-name', + metavar='', + dest='dns_name', + help=_("Set DNS name for this floating IP") + ) + identity_common.add_project_domain_option_to_parser(parser) _tag.add_tag_option_to_parser_for_create(parser, _('floating IP')) return parser def take_action_network(self, client, parsed_args): attrs = _get_attrs(self.app.client_manager, parsed_args) - obj = client.create_ip(**attrs) + with common.check_missing_extension_if_error( + self.app.client_manager.network, attrs): + obj = client.create_ip(**attrs) + # tags cannot be set when created, so tags need to be set later. _tag.update_tags_for_set(client, obj, parsed_args) + display_columns, columns = _get_network_columns(obj) data = utils.get_item_properties(obj, columns) return (display_columns, data) @@ -314,12 +337,16 @@ class ListFloatingIP(common.NetworkAndComputeLister): 'status', 'description', 'tags', + 'dns_name', + 'dns_domain', ) headers = headers + ( 'Router', 'Status', 'Description', 'Tags', + 'DNS Name', + 'DNS Domain', ) query = {} diff --git a/openstackclient/tests/unit/network/v2/test_floating_ip_network.py b/openstackclient/tests/unit/network/v2/test_floating_ip_network.py index 65d873770a..d71121a760 100644 --- a/openstackclient/tests/unit/network/v2/test_floating_ip_network.py +++ b/openstackclient/tests/unit/network/v2/test_floating_ip_network.py @@ -49,6 +49,8 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork): attrs={ 'floating_network_id': floating_network.id, 'port_id': port.id, + 'dns_domain': 'example.org.', + 'dns_name': 'fip1', } ) @@ -129,6 +131,8 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork): '--floating-ip-address', self.floating_ip.floating_ip_address, '--fixed-ip-address', self.floating_ip.fixed_ip_address, '--description', self.floating_ip.description, + '--dns-domain', self.floating_ip.dns_domain, + '--dns-name', self.floating_ip.dns_name, self.floating_ip.floating_network_id, ] verifylist = [ @@ -137,6 +141,8 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork): ('fixed_ip_address', self.floating_ip.fixed_ip_address), ('network', self.floating_ip.floating_network_id), ('description', self.floating_ip.description), + ('dns_domain', self.floating_ip.dns_domain), + ('dns_name', self.floating_ip.dns_name), ('floating_ip_address', self.floating_ip.floating_ip_address), ] parsed_args = self.check_parser(self.cmd, arglist, verifylist) @@ -150,6 +156,8 @@ class TestCreateFloatingIPNetwork(TestFloatingIPNetwork): 'fixed_ip_address': self.floating_ip.fixed_ip_address, 'floating_network_id': self.floating_ip.floating_network_id, 'description': self.floating_ip.description, + 'dns_domain': self.floating_ip.dns_domain, + 'dns_name': self.floating_ip.dns_name, }) self.assertEqual(self.columns, columns) self.assertEqual(self.data, data) @@ -393,6 +401,8 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork): 'Status', 'Description', 'Tags', + 'DNS Name', + 'DNS Domain', ) data = [] @@ -417,6 +427,8 @@ class TestListFloatingIPNetwork(TestFloatingIPNetwork): ip.status, ip.description, ip.tags, + ip.dns_domain, + ip.dns_name, )) def setUp(self): diff --git a/releasenotes/notes/floatingip_dns_integration-f26c7575694d098d.yaml b/releasenotes/notes/floatingip_dns_integration-f26c7575694d098d.yaml new file mode 100644 index 0000000000..9c1d4cf5d2 --- /dev/null +++ b/releasenotes/notes/floatingip_dns_integration-f26c7575694d098d.yaml @@ -0,0 +1,14 @@ +--- +features: + - | + Add ``--dns-domain`` and ``--dns-name`` options to the + ``floating ip create`` commands. These options + set the DNS domain and name for the floating IP. + + Check backend available extension and return an error + message if it is missing (instead of a Bad Request HTTP 400). + [Bug `1547736 `_] + - | + Add ``--long`` option to the ``floating ip list`` command. This adds + ``DNS Name`` and ``DNS Domain`` columns to the floating IP list. + [Bug `1547736 `_]