Include project_id only where needed

Currently project_id is allowed in request body
for all request, however, its not honered since project_id
is pulled from headers.

This commit separates the need for project_id only where
its needed. For instance, in users we expect project_id
to allow creating users for different projects or we
expect project_id in response body.

Partial-Bug: 1666695

Change-Id: Ie5fac9ef4c305ff7e67fe32855ca8100a8adfa82
This commit is contained in:
Sulochan Acharya 2017-03-17 10:12:49 +00:00
parent ce1311ecfc
commit 9ddf2c4cd5
3 changed files with 12 additions and 9 deletions

View File

@ -61,6 +61,9 @@ DefinitionLinks = {
# such that a resource can not be created with these in request body.
blacklisted_create_properties = ["id", "created_at", "updated_at"]
# Blacklisted create properties with project_id addition
blacklisted_with_project_id = blacklisted_create_properties + ["project_id"]
def _remove_properties(properties, remove_list):
props = copy.copy(properties)
@ -181,7 +184,7 @@ DefinitionHostCreate = {
"type": "object",
"additionalProperties": False,
"properties": _remove_properties(HostProperties,
blacklisted_create_properties),
blacklisted_with_project_id),
}
CellProperties = {
@ -239,7 +242,7 @@ DefinitionsCellCreate = {
"type": "object",
"additionalProperties": False,
"properties": _remove_properties(CellProperties,
blacklisted_create_properties),
blacklisted_with_project_id),
}
RegionProperties = {
@ -299,7 +302,7 @@ DefinitionsRegionCreate = {
"type": "object",
"additionalProperties": False,
"properties": _remove_properties(RegionProperties,
blacklisted_create_properties),
blacklisted_with_project_id),
}
CloudProperties = {
@ -354,7 +357,7 @@ DefinitionsCloudCreate = {
"type": "object",
"additionalProperties": False,
"properties": _remove_properties(CloudProperties,
blacklisted_create_properties),
blacklisted_with_project_id),
}
UserProperties = {
@ -510,7 +513,7 @@ DefinitionNetworkCreate = {
"type": "object",
"additionalProperties": False,
"properties": _remove_properties(NetworkProperties,
blacklisted_create_properties),
blacklisted_with_project_id),
}
@ -600,7 +603,7 @@ DefinitionNetworkInterfaceCreate = {
"type": "object",
"additionalProperties": False,
"properties": _remove_properties(NetworkInterfaceProperties,
blacklisted_create_properties),
blacklisted_with_project_id),
}
NetworkDeviceProperties = {
@ -692,7 +695,7 @@ DefinitionNetworkDeviceCreate = {
"type": "object",
"additionalProperties": False,
"properties": _remove_properties(NetworkDeviceProperties,
blacklisted_create_properties),
blacklisted_with_project_id),
}
DefinitionNoParams = {

View File

@ -182,7 +182,7 @@ Create a Region
* To create region, execute the following command::
# curl -i "http://${MY_IP}:7780/v1/regions" \
-d '{"name": "DFW", "project_id": "717e9a216e2d44e0bc848398563bda06", "cloud_id": 1}' \
-d '{"name": "DFW", "cloud_id": 1}' \
-H "Content-Type: application/json" \
-H "X-Auth-Token: demo" \
-H "X-Auth-User: demo" \

View File

@ -58,7 +58,7 @@ Example Host Create
.. code-block:: bash
curl -i "http://${MY_IP}:7780/v1/hosts" \
-d '{"name": "fooHost", "region_id": 1, "ip_address": "11.11.11.14", "device_type": "Phone", "project_id": "717e9a216e2d44e0bc848398563bda06"}' \
-d '{"name": "fooHost", "region_id": 1, "ip_address": "11.11.11.14", "device_type": "Phone"}' \
-H "Content-Type: application/json" \
-H "X-Auth-Token: demo" \
-H "X-Auth-User: demo" \