Commit Graph

51 Commits

Author SHA1 Message Date
Sean Mooney f4852f4c81 [codespell] fix final typos and enable ci
This chnage adds the pre-commit config and
tox targets to run codespell both indepenetly
and via the pep8 target.

This change correct all the final typos in the
codebase as detected by codespell.

Change-Id: Ic4fb5b3a5559bc3c43aca0a39edc0885da58eaa2
2023-12-15 12:32:42 +00:00
Artom Lifshitz 9980b9ad52 Microversion 2.94: FQDN in hostname
Extend microversion 2.90 to allow FQDNs in the hostname parameter.
Multi-create with --hostname continues to be refused, returning error
400 to the user. This simplifies the code by not needing to handle any
sort of suffix or prefix mangling of the FQDN to handle multiple
instances. No other changes are made - not Neutron integration,
metadata API changes (the FQDN will appear as-is in places where the
hostname currently appears), etc.

Change-Id: I47e397dc6da8263762479cc8ae4f8777a6d9d811
Implements: bp/fqdn-in-hostname
2023-01-17 10:59:37 -05:00
Stephen Finucane 5e2c31ab78 api: Add support for 'hostname' parameter
Add microversion 2.90, which allows allows users to configure the
hostname that will be exposed via the nova metadata service when
creating their instance.

Change-Id: I95047c1689ac14fa73eba48e19dc438988b78aad
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-01-14 11:42:43 +00:00
Stephen Finucane e3fa6859f9 api: Remove unnecessary 'base_' prefix from schemas
A base is something that it's inherited by other things. If everything
is a base, nothing is. This is just noise so remove it.

Change-Id: I9e2d3c37650465d0748852f8cdb82fbeba7b3f4c
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2021-08-19 11:16:59 +01:00
Stephen Finucane b543f8226c 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>
2021-08-19 11:16:59 +01:00
Stephen Finucane fadeedcdea nova-net: Remove layer of indirection in 'nova.network'
At some point in the past, there was only nova-network and its code
could be found in 'nova.network'. Neutron was added and eventually found
itself (mostly!) in the 'nova.network.neutronv2' submodule. With
nova-network now gone, we can remove one layer of indirection and move
the code from 'nova.network.neutronv2' back up to 'nova.network',
mirroring what we did with the old nova-volume code way back in 2012
[1]. To ensure people don't get nova-network and 'nova.network'
confused, 'neutron' is retained in filenames.

[1] https://review.opendev.org/#/c/14731/

Change-Id: I329f0fd589a4b2e0426485f09f6782f94275cc07
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2020-01-15 14:57:49 +00:00
Adam Spiers d47f1db49e Switch some GitHub URLs to point to opendev.org
Also update some outdated URLs at the same time, e.g. defcore is now
interop.

Unfortunately unlike GitHub, gitea doesn't yet support URLs with
shortened SHA1s; however this is being worked on:

    https://github.com/go-gitea/gitea/issues/6450

Change-Id: I6e6b63619f1138cc961b61be548453361d01f73c
2019-08-19 21:08:27 +01:00
Ghanshyam Mann b26bc7fd7a Multiple API cleanup changes
This microversion implements below API cleanups:

1. 400 for unknown param for query param and for request body.

2. Making server representation always consistent among all APIs
   returning the complete server representation.

3. Change the default return value of ``swap`` field from the empty string
   to 0 (integer) in flavor APIs.

4. Return ``servers`` field always in the response of GET
   hypervisors API even there are no servers on hypervisor

Details: https://specs.openstack.org/openstack/nova-specs/specs/train/approved/api-consistency-cleanup.html

Partial-Implements: blueprint api-consistency-cleanup

Change-Id: I9d257a003d315b84b937dcef91f3cb41f3e24b53
2019-08-12 08:52:38 -05:00
zhu.boxiang 564290ab14 Add host and hypervisor_hostname flag to create server
Add a new microversion that adds two new params to create
server named 'host' and 'hypervisor_hostname'.

Part of Blueprint: add-host-and-hypervisor-hostname-flag-to-create-server

Change-Id: I3afea20edaf738da253ede44b4a07414ededafd6
2019-07-09 22:55:16 +08:00
Stephen Finucane dc6fc82c14 hacking: Resolve W605 (invalid escape sequence)
This one's actually important since it will be an error in future
versions of Python.

Change-Id: Ib9f735216773224f91ac7f49fbe2eee119670872
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2019-06-24 14:24:06 -05:00
Surya Seetharaman c541ace518 Microversion 2.73: Support adding the reason behind a server lock
This patch adds a new parameter ``locked_reason`` to
``POST /servers/{server_id}/action`` request where the
action is lock. It enables the user to specify a reason when locking
a server.

The locked_reason will be exposed through ``GET servers/{server_id}``,
``GET /servers/detail``, ``POST /servers/{server_id}/action``  where
the action is rebuild and ``PUT servers/{server_id}`` requests' responses.

The InstanceActionNotification will emit the locked_reason
along with the other instance details. This patch hence changes the
payload object to include the "locked_reason" field.

Note that "locked" will be allowed as a valid filtering/sorting parameter
for ``GET /servers/detail`` and ``GET /servers`` from this new microversion.

Implements blueprint add-locked-reason

Change-Id: I46edd595e7417c584106487123774a73c6dbe65e
2019-05-11 21:48:27 +00:00
zhangbailin c7f4190af2 Add microversion 2.67 to support volume_type
Add a new microversion 2.67 to support specify ``volume_type``
when boot instances.

Part of bp boot-instance-specific-storage-backend
Change-Id: I13102243f7ce36a5d44c1790f3a633703373ebf7
2018-10-12 02:57:58 -04:00
zhangbailin 28c1075b59 Resource retrieving: add changes-before filter
This adds the changes-before filter to the servers,
os-instance-actions and os-migrations APIs for
filtering resources which were last updated before
or equal to the given time. The changes-before filter,
like the changes-since filter, will return deleted
server resources.

Part of bp support-to-query-nova-resources-filter-by-changes-before
Change-Id: If91c179e3823c8b0da744a9363906b0f7b05c326
2018-09-19 09:56:56 -04:00
ghanshyam de03b832ad Merge server create schema for user data extension
As nova extensions has been deprecated already and goal is to
merge all scattered code into main controller side.
Currently schema and request/response extended code are there
among all extensions.

This commit merge the schema part of create server for user data
extensions.

Also this commit removes the logic of appending the extensions
schema as this is the last extensions schema to merge.

Partially implements: blueprint api-extensions-merge-rocky

Change-Id: I692a048b3a8da4e912e000b47da977dda466348b
2018-06-27 18:03:18 +03:00
ghanshyam 1f677061fa Merge server create schema for security group extension
As nova extensions has been deprecated already and goal is to
merge all scattered code into main controller side.
Currently schema and request/response extended code are there
among all extensions.

This commit merge the schema part of create server for security
group extensions.

Partially implements: blueprint api-extensions-merge-rocky

Change-Id: I160028d77e84705106aad5ec8b2d9a54a3c54b18
2018-06-27 17:33:28 +03:00
ghanshyam f4ec8116ae Merge server create schema for scheduler hint extension
As nova extensions has been deprecated already and goal is to
merge all scattered code into main controller side.
Currently schema and request/response extended code are there
among all extensions.

This commit merge the schema part of create server for scheduler
hint extensions.

Partially implements: blueprint api-extensions-merge-rocky

Change-Id: I7d15614051d4a38b74b0fc9e5c751fdc3f64cb1c
2018-06-27 14:09:02 +00:00
ghanshyam 74ee397dbb Merge server create schema for multiple create extension
As nova extensions has been deprecated already and goal is to
merge all scattered code into main controller side.
Currently schema and request/response extended code are there
among all extensions.

This commit merge the schema part of create server for multiplex
create extensions.

Partially implements: blueprint api-extensions-merge-rocky

Change-Id: I2b1a7a45ee35d3a7023a27f13e197221868087b2
2018-06-27 14:07:45 +00:00
ghanshyam 07731a6cf2 Merge server create schema for keypair extension
As nova extensions has been deprecated already and goal is to
merge all scattered code into main controller side.
Currently schema and request/response extended code are there
among all extensions.

This commit merge the schema part of create server for keypair extensions.

Partially implements: blueprint api-extensions-merge-rocky

Change-Id: I56b044863a2454601d3f4534bace229a94c4f0e3
2018-06-27 14:06:10 +00:00
ghanshyam 6c731b4423 Merge server create schema for config drive extension
As nova extensions has been deprecated already and goal is to
merge all scattered code into main controller side.
Currently schema and request/response extended code are there
among all extensions.

This commit merge the schema part of create server for config extensions.

Partially implements: blueprint api-extensions-merge-rocky

Change-Id: I0bdb82c1692c547be6edc9729b2fd3e415b35646
2018-06-27 14:05:43 +00:00
ghanshyam 17fcbe9fde Merge server create schema for BDM v2 extension
As nova extensions has been deprecated already and goal is to
merge all scattered code into main controller side.
Currently schema and request/response extended code are there
among all extensions.

This commit merge the schema part of create server for BDM v2 extensions.

Partially implements: blueprint api-extensions-merge-rocky

Change-Id: I49146f5b2e7635aa500054e9506e9bf28f6a2ce5
2018-06-27 10:04:12 +00:00
ghanshyam 627ff16e9d Merge server create schema for legacy BDM extension
As nova extensions has been deprecated already and goal is to
merge all scattered code into main controller side.
Currently schema and request/response extended code are there
among all extensions.

This commit merge the schema part of create server for legacy BDM extensions.

Partially implements: blueprint api-extensions-merge-rocky

Change-Id: I396809b66dd6a9bc704b24072a6325b90244dad7
2018-06-21 13:07:40 +00:00
Brianna Poulos 8c7ca368b1 Add trusted_image_certificates to REST API
This change adds support for the trusted_image_certificates parameter,
which is used to define a list of trusted certificate IDs that can be
used during image signature verification and certificate validation. The
parameter may contain a list of strings, each string representing the ID
of a trusted certificate. The list is restricted to a maximum of 50 IDs.
The list of certificate IDs will be stored in the trusted_certs field of
the instance InstanceExtra and will be used to verify the validity of
the signing certificate of a signed instance image.

The trusted_image_certificates request parameter can be passed to
the server create and rebuild APIs (if allowed by policy):

* POST /servers
* POST /servers/{server_id}/action (rebuild)

The following policy rules were added to restrict the usage of the
``trusted_image_certificates`` request parameter in the server create
and rebuild APIs:

* os_compute_api:servers:create:trusted_certs
* os_compute_api:servers:rebuild:trusted_certs

The trusted_image_certificates parameter will be in the response
body of the following APIs (not restricted by policy):

* GET /servers/detail
* GET /servers/{server_id}
* PUT /servers/{server_id}
* POST /servers/{server_id}/action (rebuild)

APIImpact

Implements blueprint: nova-validate-certificates
Change-Id: Iedd3fea0e86648fae364f075915555dcb2c4f199
2018-06-13 15:52:59 -04:00
jichen 1c3151dd43 [doc] Add soft_deleted flag
soft_deleted is support in query but we didn't mention in the doc

bcb405e871/nova/db/sqlalchemy/api.py (L2127)

Change-Id: I1c5577a501144170e82c96c04cffbf32dcaa5cff
Closes-Bug: 1765575
2018-05-09 14:41:30 +00:00
ghanshyam 43f4755d5e Merge server create schema for availability zone extension
As nova extensions has been deprecated already and goal is to
merge all scattered code into main controller side.
Currently schema and request/response extended code are there
among all extensions.

This commit merge the schema part of create server for AZ extensions.

Partially implements: blueprint api-extensions-merge-queens
Change-Id: I3671e63187b79cb7a80594d4d7a948565a9003bb
2018-01-25 03:12:06 +00:00
Matt Riedemann 126c3d4c78 Deprecate file injection
This microversion makes the following changes:

1. Deprecates personality files from POST /servers and the rebuild
   server action APIs.
2. Adds the ability to pass new user_data to the rebuild server
   action API.
3. Personality / file injection related limits and quota resources
   are removed from the limits, os-quota-sets and os-quota-class-sets
   APIs.

Implements blueprint deprecate-file-injection

Change-Id: Ia89eeb6725459c35369e8f790f68ad9180bd3aba
2017-12-12 09:22:21 -05:00
LIU Yulong 751f5dec11 Enable reset keypair while rebuilding instance
This patch adds `key_name` param to instance rebuild
API. Then the user could reset the instance keypair
when rebuilding. If set key_name to None, the API
will unset the keypair of the instance.

APIImpact

Implements blueprint: rebuild-keypair-reset

Change-Id: I23886a89c25f811cfbe7e2500ce7ff52f9162966
2017-11-13 10:49:02 +08:00
jichenjc ceabc1753c Move common definition into common layer
move common definition into common layer, as dependency patches
like I64ad387ec7b532e9dbc791f683a005587825ff61 plan to use the
definitions of the schema, this patch moves these definitions
as common ones

Change-Id: I17c2937e6b8ac3d09fabe273c50c81dd9b0babb6
2017-08-18 02:00:33 +08:00
Kevin_Zheng b50b5a660e Support tag instances when boot(4/4)
This is the 4th patch of the series,
this patch adds a new microversion
in API to support adding tags when
booting instances.

Implemetes: blueprint support-tag-instance-when-boot

Change-Id: Ifcaaf285c8f98a1d0e8bbbc87b2f57fbce057346
2017-07-17 15:59:42 -04:00
ghanshyam 16032ceeca Explicitly define enum type as string in schema
Many attribute in the request schema are defined with
allowed enum values. But schema does not specify those
enum as string type.

enum in json schema is defined in such a way that it
allows any type not just string so defining each enum type
as string explicitly makes schema more readable and consistent
with other API schema.

Note- this does not change any behavior or does not fix any issue.
This is just for consistency with other schema definition and readability.

Change-Id: I4f6fe5e418c624e0dcbcfb3b6bca64ab3e5c96fe
2017-04-21 03:09:28 +00:00
Ken'ichi Ohmichi 4d3d98be29 Remove json-schema extension variable for resize
schema_servers.base_xxx was for extending json-schema for API extensions,
however the json-schema of resize is not extended at all since the first
commit I3651da8c1d23ee1b5d4710b1b323ecf9337ca70d
So this patch removes the variable for easy code.

Partial-implement-blueprint api-no-more-extensions-pike

Change-Id: I2b9c31d177943d728fa51848f6f824b9918744a6
2017-04-17 19:08:18 -07:00
ghanshyam cd29a4e6c5 Fix access_ip_v4/6 filters params for servers filter
While adding the json schema for servers filter query,
we added 'accessIPv4' and 'accessIPv6' as allowed params
but they do not match with what DB has. It is 'access_ip_v4'
and 'access_ip_v6' in DB.
This makes  'access_ip_v4' and 'access_ip_v6' filter stop working.

The schema should be fixed accordingly to allow the 'access_ip_v4'
and 'access_ip_v6' as valid filter.

'accessIPv4' and 'accessIPv6' are something the API accepts
and returns and internally API layer translate those param
to their respective field('access_ip_v4' and 'access_ip_v6')
present in DB.
So user does not know anything about 'access_ip_v4' and
'access_ip_v6'. They are not in API representation actually.

Later list filter and sort param should be same as field return
in GET or accepted in POST/PUT which are 'accessIPv4' and 'accessIPv6'.
But that is something new attribute support in filter and can be
done later after more discussion.

Change-Id: Idc12de0062d298259e25c8b4c0dde889054a9ae5
Closes-Bug: #1661195
2017-02-02 11:30:02 -05:00
Jenkins d92e56a99d Merge "Fix the terminated_at field in the server query params schema" 2017-02-02 13:17:12 +00:00
Matt Riedemann 1bbecbd98f Fix the terminated_at field in the server query params schema
The field is 'terminated_at', not 'terminate_at', which was
probably just a typo. This fixes the field name in the server
query parameter schema and adds a test to show it working.

Change-Id: I279fa7b40da1d1057a9774e2dc380425454f11dd
Closes-Bug: #1661113
2017-02-01 18:59:46 -05:00
Artom Lifshitz e80e2511cf Fix tag attribute disappearing in 2.33 and 2.37
In the context of device tagging, bugs have caused the tag attribute
to disappear starting with version 2.33 for block_devices and starting
with version 2.37 for network interfaces. In other words, block
devices could only be tagged in 2.32 and network interfaces between
2.32 and 2.36 inclusively.

This patch documents this behaviour in api-ref and introduces
microversion 2.42, which re-adds the tag in all the right places.

Change-Id: Ia0869dc6f7f5bd347ccbd0930d1d668d37695a22
Closes-bug: 1658571
Implements: blueprint fix-tag-attribute-disappearing
2017-01-30 19:38:46 -05:00
Kevin_Zheng 3421ddea29 Add sort_key white list for server list/detail
Currently all the DB columns exposed in the sort_key parameter. That means
the supported sort keys will be changed when the DB schema changed. This
patch will strict the supported sort keys in a limited list.

Only the keys which are in the API representation will be supported. For
avoid to break the user hardly, the keys which aren't supported from now
will be ignored when in the request. For other invalid sort keys, the
400 will be returned, which matches the behavior as before.

The sort_key in the JSON-Schema will be enum. But due to there is no
way to describe ignore few of enum values in the schema. So we put all
ignored keys in the enum also. Then we will filter those keys out in the
python code. For readability, we put all the ignored sort keys in the
variable 'SERVER_LIST_IGNORE_SORT_KEY'.

partial implement of bp add-whitelist-for-server-list-filter-sort-parameters

Change-Id: I4af9b0eb2166ce14bde4ef4f8a1f9e9707f2c5cf
2017-01-25 14:05:02 +08:00
Kevin_Zheng 841916daf7 Strict pattern match query parameters
We have a lot of filters are pattern match.

There is list for exact match
df2fd4a252/nova/db/sqlalchemy/api.py (L2221)

Out of that list will be pattern match
df2fd4a252/nova/db/sqlalchemy/api.py (L2231)

HTTP 500 raises if invalid regex provided for
those filters, strict there format to be regex
in JSON schema to avoid this.

partial implement of bp add-whitelist-for-server-list-filter-sort-parameters
Closes-Bug: #1653899

Change-Id: I4cf38407c20284dee7127edfe312da81caac9272
2017-01-18 23:06:19 +00:00
He Jie Xu 134c19faeb Add query parameters white list for server list/detail
This patch enables a white list for query parameter.
The parameters, which are out of white list, will be ignored.

The sort_key still accepts open value. The later patch will add white
list to it.

Co-Authored-By: Zhenyu Zheng <zhengzhenyu@huawei.com>

partial implement of bp add-whitelist-for-server-list-filter-sort-parameters

Change-Id: I7141eef6a1c85ec6d6e8ee170911572535652978
2017-01-17 15:54:15 +00:00
ghanshyam af673dbb0b Move tag schema to parameter_types.py
tag schema is being used in multiple place like server tags
and device tags and may be in future it will be used in many
other schema also.

So this patch moves tag schema from server_tags.py to common
place (parameter_types.py).

Change-Id: I9385c436c48c881dc5fab475ed35eb0e10010637
2016-11-25 14:11:35 +09:00
pangliye 90f3959842 Typo error servers.py
Change-Id: I0f19039e099cbfb70cc69a9d10d8f5978e5f727b
2016-11-16 19:01:14 +08:00
Matt Riedemann d727795d66 Add REST API support for get me a network
This adds the 2.37 microversion to the REST API for automatically
allocating a network, i.e. get me a network.

The majority of the changes to the REST API concern request
validation. 'networks' is now required in the server POST body
after this microversion. The 'auto' or 'none' special network
uuid values are used, but if specified, can not be specified
with any other requested network values.

The other special case that is checked is when the minimum
compute service version is not new enough to support this change,
i.e. a Mitaka compute will not have the network API code that
knows how to deal with the special auto/none network IDs. Because
the REST API is checking the service version, the service caches
the service version after the first check. Once all computes are
updated to Newton then a restart of the nova-api service(s) will
be required to flush the cache. A release note is provided for
this situation.

The api-ref docs are also updated for this microversion including
an example API sample request.

The matching Tempest change to test this is here:

I89b18709e0cfbbcbf9be96a91a13a1356cdf85b0

The matching python-novaclient change is here:

I6636ddcd3be7bf393d2d69cc6c1ba5c7d65ff674

Implements blueprint get-me-a-network

Change-Id: I89b18709e0cfbbcbf9be96a91a13a1356cdf85b0
2016-08-15 14:10:42 -04:00
ghanshyam cbd3ec476f Strict ImageRef validation to UUID only
Currently imageRef in server create, rebuild and rescue
operation can be accepted as random url which contains image
UUID and fetch the UUID from that.

As /images proxy APIs are deprecated, and ImageRef in
server creation etc are UUID only and valid against glance.

This patch makes imageRef handling as UUID only and
return 400 if non UUID are requested.

NOTE- Previously nova use to allow the empty string which was
      ok in case of boot from volume.
      We will keep the same behavior of allowing empty string in case of
      boot from volume only and 400 in all other case.

Closes-Bug: #1607229

Change-Id: I49f4da62c1b5b3fd8c5f67039ae113f76722b26c
2016-08-04 02:22:15 +00:00
Artom Lifshitz e83e114e1b Device tagging API support
This patch allows the user to specify a tag for a virtual network
interface and/or block device mapping when booting an instance.

Implements: blueprint bp/virt-device-role-tagging
Change-Id: I89247200f4cf1f644daf476727b4a6acb22b0cf6
2016-06-29 20:55:16 -07:00
Sean Dague 76b58b8f89 remove personality extension
This removes personality extension, as well as the rebuild extension
point for servers.

We add an operation flag to translate extension because personality
extension uses different kwarg names depending on the operation. This
is done with a set of constants which should prevent typos silently
causing failures.

A few variables are renamed in servers.py to avoid multiline
statements.

Part of bp:api-no-more-extensions

Change-Id: I47deae0279f85d9a355d1248b6e90af732406514
2016-06-24 14:44:53 -04:00
Sean Dague 600480e59d remove access_ips extension
Part of bp:api-no-more-extensions

Change-Id: Id48dfdf29bb6b250ad505428bd034074cb611cc1
2016-06-24 14:32:23 -04:00
Sean Dague 56dce766d8 Tear down of os-disk-config part 2
This removes the portions of the os-disk-config extension that handles
additional attributes being passed in during
create/update/resize/rebuild. These are folded directly into
servers.py with a new module wide function for translating REST in =>
attr dict data structures.

Tests which use disk_config as the example for loading and using these
extensions are removed.

As this is the only in tree extension that hooks the resize entry
point, that is fully removed from setup.cfg and well as any extension
manager processing.

Part of bp:api-no-more-extensions

Change-Id: I691a3a917a3dbaa86072d689e9ebf42ba356ca60
2016-06-14 12:07:59 -04:00
He Jie Xu a9691bfb92 Correct the wrong usage of 'format' jsonschema keyword in servers API
'format' keyword works for any types. That means for 'port' field,
'null' value never passed the format checks. We should use 'oneOf'
keyword instead of it.

Change-Id: Ic51e9e1c6efadce0a0b4d20a114ca75799fb36a5
Partial-Bug: #1552888
2016-03-08 09:24:45 +08:00
Chuck Carmack 4841cab03e REST API changes for user settable server description
This patches adds changes to the Nova REST API to allow
users to create a server with a description, rebuild
a server with a description, update the description,
and get the description in the server details.

Note: Future commits will be done to support the server
description in python-novaclient and openstack-client.

APIImpact

Implements blueprint: user-settable-server-description

Change-Id: I74b1a340c5ab98fdea2186e87dd13f42ce7c7661
2016-01-25 21:33:30 +00:00
Tang Chen 30c6f49817 Add a REST API to trigger crash dump in an instance.
Change I9b649aafba011d537e3fe4eebef7a678ff6733e4 has added a
compute API to trigger crash dump in instance. This patch adds
the REST API to nova. It enables users to trigger crash dump in
an instance through REST API.

Change-Id: I6ed777ff637254b4b79417008f9055dd19fc7405
Implements: blueprint instance-crash-dump
Co-Authored-By: Hironori Shiina <shiina.hironori@jp.fujitsu.com>
Co-Authored-By: Tang Chen <tangchen@cn.fujitsu.com>
2016-01-20 09:42:50 +08:00
He Jie Xu 4354163c1e Filter leading/trailing spaces for name field in v2.1 compat mode
In the V2 API, there are three cases for the name field:

1. disallow any space in the name: server_groups.

2. allow leading/trailing whitespaces, strip spaces and disallow
all characters are spaces: flavor_manage, servers.

3. allow leading/trailing whitespacess, no strip spaces and allow
all characters are spaces: aggregates, cells, create_backup,
security_groups, create_image, rebuild

But currently in the V2.1 API and V2.1 API compat mode disallows
leading/trailing in the name field.

For the V2.1 compat mode, we should relax the validation to avoid
breaking the user, although leading/trailing is unclear usecase. This
patch allows leading/trailing spaces but will strip them, and still
disallows that all characters are spaces in the name fields for
flavor_mange, servers, aggregates(and availability_zones),
create_backup, create_image, rebuild.

Due to the server_groups and security_groups(no jsons-schema in v2.1)
have consistent behavior between v2 and v2.1. So this patch won't
change server_groups.

But when creating servers, the name of security_groups, availability_zone
and keyapir isn't stripped the leading/trailing spaces. This is for
backward compatible with users who already use legacy V2 API created
security_group, availabilit_zone and keypair with leading/trailing
in the name, otherwise the users can't use those resource anymore.

For supporting servers schema extension point returns legacy v2 schema,
this patch adds version parameter to the schema extension point. Then
extension point can return different schema based on the version
parameter.

Change-Id: I9442891272284d395ea0dd8cfa302d3f74bf13ec
Partial-Bug: #1498075
2015-09-23 10:27:54 +01:00
Sean Dague a0aeaa0e5b Relax restrictions on server name
The server name is designed to be anything the user would like it to
be, so should be validated against name, not hostname. This is how
v2.0 worked, and v2.1 schema validation accidentally went over the top
here. v2.1 regressed at  f40b6a1d5c

Change-Id: Ia32a452ab3a5d7cd5a5289e8e8bf9f8e5e404780
Partial-Bug: #1491511
2015-09-06 15:16:59 +08:00