Fix nova instance_action schema

There is case (at least on one cloud) where user_id attribute of the
instance_action is null (explicit null and not unset).

Change-Id: Ic8ac6416a4d48d13a62b37b4b08c25b425ecc2b7
This commit is contained in:
Artem Goncharov
2025-04-17 12:57:43 +02:00
parent 1ae47e0b0e
commit 2c638bbf44

View File

@@ -1903,57 +1903,56 @@ SERVER_METADATA_ITEM_SCHEMA: dict[str, Any] = {
"properties": {"meta": {"maxProperties": 1, **parameter_types.metadata}},
}
SERVER_INSTANCE_ACTION_SCHEMA: dict[str, Any] = {
SERVER_INSTANCE_ACTION_EVENT_SCHEMA: dict[str, Any] = {
"description": "Event",
"type": "object",
"properties": {
"event": {"type": "string", "description": "The name of the event."},
"start_time": {
"type": "string",
"format": "date-time",
"description": "The date and time when the event was started.",
},
"finish_time": {
"type": "string",
"format": "date-time",
"description": "The date and time when the event was finished.",
},
"result": {
"type": "string",
"description": "The result of the event.",
},
"traceback": {
"type": ["string", "null"],
"description": "he traceback stack if an error occurred in this event. Policy defaults enable only users with the administrative role to see an instance action event traceback. Cloud providers can change these permissions through the policy.json file.",
},
"hostId": {
"type": "string",
"description": "An obfuscated hashed host ID string, or the empty string if there is no host for the event. This is a hashed value so will not actually look like a hostname, and is hashed with data from the project_id, so the same physical host as seen by two different project_ids will be different. This is useful when within the same project you need to determine if two events occurred on the same or different physical hosts.",
"x-openstack": {"min-ver": "2.62"},
},
"host": {
"type": "string",
"description": "The name of the host on which the event occurred. Policy defaults enable only users with the administrative role to see an instance action event host. Cloud providers can change these permissions through the policy.json file.",
"x-openstack": {"min-ver": "2.62"},
},
"details": {
"type": ["string", "null"],
"description": "Details of the event. May be null.",
"x-openstack": {"min-ver": "2.84"},
},
},
"required": ["event", "start-time"],
}
SERVER_INSTANCE_ACTION_SHORT_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "The instance action object.",
"properties": {
"action": {"type": "string", "description": "The name of the action."},
"events": {
"type": "array",
"items": {
"type": "object",
"properties": {
"event": {
"type": "string",
"description": "The name of the event.",
},
"start_time": {
"type": "string",
"format": "date-time",
"description": "The date and time when the event was started.",
},
"finish_time": {
"type": "string",
"format": "date-time",
"description": "The date and time when the event was finished.",
},
"result": {
"type": "string",
"description": "The result of the event.",
},
"traceback": {
"type": ["string", "null"],
"description": "he traceback stack if an error occurred in this event. Policy defaults enable only users with the administrative role to see an instance action event traceback. Cloud providers can change these permissions through the policy.json file.",
},
"hostId": {
"type": "string",
"description": "An obfuscated hashed host ID string, or the empty string if there is no host for the event. This is a hashed value so will not actually look like a hostname, and is hashed with data from the project_id, so the same physical host as seen by two different project_ids will be different. This is useful when within the same project you need to determine if two events occurred on the same or different physical hosts.",
"x-openstack": {"min-ver": "2.62"},
},
"host": {
"type": "string",
"description": "The name of the host on which the event occurred. Policy defaults enable only users with the administrative role to see an instance action event host. Cloud providers can change these permissions through the policy.json file.",
"x-openstack": {"min-ver": "2.62"},
},
"details": {
"type": ["string", "null"],
"description": "Details of the event. May be null.",
"x-openstack": {"min-ver": "2.84"},
},
},
"required": ["event", "start-time"],
},
"description": "Events",
"items": SERVER_INSTANCE_ACTION_EVENT_SCHEMA,
},
"message": {
"type": ["string", "null"],
@@ -1973,11 +1972,11 @@ SERVER_INSTANCE_ACTION_SCHEMA: dict[str, Any] = {
"description": "The date and time when the action was started.",
},
"user_id": {
"type": "string",
"type": ["string", "null"],
"description": "The ID of the user which initiated the server action.",
},
"updated_at": {
"type": "string",
"type": ["string", "null"],
"format": "date-time",
"description": "The date and time when the instance action or the action event of instance action was updated.",
"x-openstack": {"min-ver": "2.58"},
@@ -1985,17 +1984,32 @@ SERVER_INSTANCE_ACTION_SCHEMA: dict[str, Any] = {
},
"required": ["action", "events", "request_id", "user_id", "project_id"],
}
SERVER_INSTANCE_ACTION_SCHEMA: dict[str, Any] = {
"type": "object",
"description": "The instance action object.",
"properties": {
"events": {
"type": "array",
"items": SERVER_INSTANCE_ACTION_EVENT_SCHEMA,
},
**SERVER_INSTANCE_ACTION_SHORT_SCHEMA["properties"],
},
"required": ["action", "events", "request_id", "user_id", "project_id"],
}
SERVER_INSTANCE_ACTION_CONTAINER_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {"instanceAction": SERVER_INSTANCE_ACTION_SCHEMA},
"required": ["instanceAction"],
}
SERVER_INSTANCE_ACTION_LIST_SCHEMA: dict[str, Any] = {
"type": "object",
"properties": {
"instanceActions": {
"type": "array",
"items": SERVER_INSTANCE_ACTION_SCHEMA,
"items": SERVER_INSTANCE_ACTION_SHORT_SCHEMA,
"description": "List of the actions for the given instance in descending order of creation.",
},
"links": LINKS_SCHEMA,