api: Rename 'parameter_types.hostname' -> 'fqdn'

This better reflects its actual meaning.

The 'hostname_or_ip_address' parameter type is removed as it has been
unused since support for support for the 'os-cells' API was removed in
change Iddb519008515f591cf1d884872a5887afbe766f2.

Change-Id: Ia99aeb37785284e129b01d336da17ea907db95b7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2021-01-14 11:39:11 +00:00
parent c7dd853945
commit b543f8226c
8 changed files with 14 additions and 65 deletions

View File

@ -85,7 +85,7 @@ add_host = {
'add_host': {
'type': 'object',
'properties': {
'host': parameter_types.hostname,
'host': parameter_types.fqdn,
},
'required': ['host'],
'additionalProperties': False,
@ -102,7 +102,7 @@ remove_host = {
'remove_host': {
'type': 'object',
'properties': {
'host': parameter_types.hostname,
'host': parameter_types.fqdn,
},
'required': ['host'],
'additionalProperties': False,

View File

@ -23,7 +23,7 @@ evacuate = {
'evacuate': {
'type': 'object',
'properties': {
'host': parameter_types.hostname,
'host': parameter_types.fqdn,
'onSharedStorage': parameter_types.boolean,
'adminPass': parameter_types.admin_password,
},

View File

@ -35,7 +35,7 @@ list_query_schema_v253 = {
# and requesting hosted servers in the GET /os-hypervisors and
# GET /os-hypervisors/detail response.
'hypervisor_hostname_pattern': parameter_types.single_param(
parameter_types.hostname),
parameter_types.fqdn),
'with_servers': parameter_types.single_param(
parameter_types.boolean)
},

View File

@ -17,7 +17,7 @@ import copy
from nova.api.validation import parameter_types
host = copy.deepcopy(parameter_types.hostname)
host = copy.deepcopy(parameter_types.fqdn)
host['type'] = ['string', 'null']
migrate_v2_56 = {

View File

@ -359,9 +359,9 @@ base_create_v267['properties']['server']['properties'][
# Add host and hypervisor_hostname in server
base_create_v274 = copy.deepcopy(base_create_v267)
base_create_v274['properties']['server'][
'properties']['host'] = parameter_types.hostname
'properties']['host'] = parameter_types.fqdn
base_create_v274['properties']['server'][
'properties']['hypervisor_hostname'] = parameter_types.hostname
'properties']['hypervisor_hostname'] = parameter_types.fqdn
base_update = {

View File

@ -19,7 +19,7 @@ from nova.api.validation import parameter_types
service_update = {
'type': 'object',
'properties': {
'host': parameter_types.hostname,
'host': parameter_types.fqdn,
'binary': {
'type': 'string', 'minLength': 1, 'maxLength': 255,
},
@ -34,7 +34,7 @@ service_update = {
service_update_v211 = {
'type': 'object',
'properties': {
'host': parameter_types.hostname,
'host': parameter_types.fqdn,
'binary': {
'type': 'string', 'minLength': 1, 'maxLength': 255,
},

View File

@ -245,7 +245,7 @@ non_negative_integer = {
'pattern': '^[0-9]*$', 'minimum': 0, 'minLength': 1
}
hostname = {
fqdn = {
'type': 'string', 'minLength': 1, 'maxLength': 255,
# NOTE: 'host' is defined in "services" table, and that
# means a hostname. The hostname grammar in RFC952 does
@ -256,13 +256,6 @@ hostname = {
}
hostname_or_ip_address = {
# NOTE: Allow to specify hostname, ipv4 and ipv6.
'type': 'string', 'maxLength': 255,
'pattern': '^[a-zA-Z0-9-_.:]*$'
}
name = {
# NOTE: Nova v2.1 API contains some 'name' parameters such
# as keypair, server, flavor, aggregate and so on. They are

View File

@ -643,16 +643,16 @@ class BooleanTestCase(APIValidationTestCase):
expected_detail=detail)
class HostnameTestCase(APIValidationTestCase):
class FQDNTestCase(APIValidationTestCase):
post_schema = {
'type': 'object',
'properties': {
'foo': parameter_types.hostname,
'foo': parameter_types.fqdn,
},
}
def test_validate_hostname(self):
def test_validate_fqdn(self):
self.assertEqual('Validation succeeded.',
self.post(body={'foo': 'localhost'},
req=FakeRequest()))
@ -664,7 +664,7 @@ class HostnameTestCase(APIValidationTestCase):
self.assertEqual('Validation succeeded.',
self.post(body={'foo': 'my_host'}, req=FakeRequest()))
def test_validate_hostname_fails(self):
def test_validate_fqdn_fails(self):
detail = ("Invalid input for field/attribute foo. Value: True."
" True is not of type 'string'")
self.check_validation_error(self.post, body={'foo': True},
@ -681,50 +681,6 @@ class HostnameTestCase(APIValidationTestCase):
expected_detail=detail)
class HostnameIPaddressTestCase(APIValidationTestCase):
post_schema = {
'type': 'object',
'properties': {
'foo': parameter_types.hostname_or_ip_address,
},
}
def test_validate_hostname_or_ip_address(self):
self.assertEqual('Validation succeeded.',
self.post(body={'foo': 'localhost'},
req=FakeRequest()))
self.assertEqual('Validation succeeded.',
self.post(body={'foo': 'localhost.localdomain.com'},
req=FakeRequest()))
self.assertEqual('Validation succeeded.',
self.post(body={'foo': 'my-host'}, req=FakeRequest()))
self.assertEqual('Validation succeeded.',
self.post(body={'foo': 'my_host'}, req=FakeRequest()))
self.assertEqual('Validation succeeded.',
self.post(body={'foo': '192.168.10.100'},
req=FakeRequest()))
self.assertEqual('Validation succeeded.',
self.post(body={'foo': '2001:db8::9abc'},
req=FakeRequest()))
def test_validate_hostname_or_ip_address_fails(self):
detail = ("Invalid input for field/attribute foo. Value: True."
" True is not of type 'string'")
self.check_validation_error(self.post, body={'foo': True},
expected_detail=detail)
detail = ("Invalid input for field/attribute foo. Value: 1."
" 1 is not of type 'string'")
self.check_validation_error(self.post, body={'foo': 1},
expected_detail=detail)
detail = ("Invalid input for field/attribute foo. Value: my$host."
" 'my$host' does not match '^[a-zA-Z0-9-_.:]*$'")
self.check_validation_error(self.post, body={'foo': 'my$host'},
expected_detail=detail)
class NameTestCase(APIValidationTestCase):
post_schema = {