Add more notifications for server create/delete
- Add notification for server.create.end event - Add notification for server.create.error event - Add notification for server.delete.start event - Add notification for server.delete.end event Change-Id: I9732e139fc9767a27647ff6aa65a9a9e0ceff0d3
This commit is contained in:
parent
d3d72d4b19
commit
f6165ada3e
43
doc/notification_samples/create-server-error.json
Normal file
43
doc/notification_samples/create-server-error.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"event_type": "server.create.error",
|
||||
"payload": {
|
||||
"mogan_object.name": "ServerActionPayload",
|
||||
"mogan_object.namespace": "mogan",
|
||||
"mogan_object.version": "1.0",
|
||||
"mogan_object.data": {
|
||||
"status": "error",
|
||||
"node": "node-0",
|
||||
"locked": false,
|
||||
"uuid": "c6e12c34-8917-4b95-938e-e146faf1de97",
|
||||
"availability_zone": null,
|
||||
"fault": {
|
||||
"mogan_object.name": "ExceptionPayload",
|
||||
"mogan_object.namespace": "mogan",
|
||||
"mogan_object.version": "1.0",
|
||||
"mogan_object.data": {
|
||||
"module_name": "mogan.engine.manager",
|
||||
"exception": "ServerDeployAborted",
|
||||
"exception_message": "Server c6e12c34-8917-4b95-938e-e146faf1de97 provisioning was aborted",
|
||||
"function_name": "_create_server"
|
||||
}
|
||||
},
|
||||
"created_at": "2017-09-14T01:31:48Z",
|
||||
"locked_by": null,
|
||||
"updated_at": null,
|
||||
"description": null,
|
||||
"metadata": {},
|
||||
"user_id": "9851baf53c75452dad7951bca7b3dbac",
|
||||
"affinity_zone": null,
|
||||
"power_state": null,
|
||||
"flavor_uuid": "737ea130-153b-4599-b7b2-dc4c82480a31",
|
||||
"image_uuid": "91d3f6fd-012d-4d19-8140-abfe39d1c332",
|
||||
"project_id": "b5f8b7e5429449a8a1366088abede8d1",
|
||||
"partitions": {},
|
||||
"launched_at": null,
|
||||
"key_name": null,
|
||||
"name": "test"
|
||||
}
|
||||
},
|
||||
"priority": "ERROR",
|
||||
"publisher_id": "mogan-engine:localhost"
|
||||
}
|
53
doc/notification_samples/server-create-end.json
Normal file
53
doc/notification_samples/server-create-end.json
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"event_type": "server.create.end",
|
||||
"payload": {
|
||||
"mogan_object.name": "ServerActionPayload",
|
||||
"mogan_object.namespace": "mogan",
|
||||
"mogan_object.version": "1.0",
|
||||
"mogan_object.data": {
|
||||
"node": "node-0",
|
||||
"addresses": [{
|
||||
"mogan_object.name": "ServerAddressesPayload",
|
||||
"mogan_object.namespace": "mogan",
|
||||
"mogan_object.version": "1.0",
|
||||
"mogan_object.data": {
|
||||
"preserve_on_delete": false,
|
||||
"network_id": "dc7f826c-c11a-4f6c-99c5-b755184666b9",
|
||||
"fixed_ips": [{
|
||||
"subnet_id": "b102f49a-c602-4626-b605-03f1401e2ffb",
|
||||
"ip_address": "11.0.0.3"
|
||||
},
|
||||
{
|
||||
"subnet_id": "56d77d46-6ff2-4d2e-9400-35f7cb2760ea",
|
||||
"ip_address": "fdfd:dac2:5dc9:0:f816:3eff:fe78:f889"
|
||||
}],
|
||||
"floating_ip": null,
|
||||
"mac_address": "52:54:00:bc:f0:fe",
|
||||
"port_id": "55edcf52-6423-49e6-909c-20459fd5cba2"
|
||||
}
|
||||
}],
|
||||
"availability_zone": null,
|
||||
"updated_at": "2017-09-13T08:36:07Z",
|
||||
"image_uuid": "91d3f6fd-012d-4d19-8140-abfe39d1c332",
|
||||
"user_id": "9851baf53c75452dad7951bca7b3dbac",
|
||||
"uuid": "692ee038-a963-4308-b596-60b0338649fd",
|
||||
"affinity_zone": null,
|
||||
"power_state": "power on",
|
||||
"flavor_uuid": "737ea130-153b-4599-b7b2-dc4c82480a31",
|
||||
"project_id": "b5f8b7e5429449a8a1366088abede8d1",
|
||||
"launched_at": "2017-09-13T08:38:42Z",
|
||||
"metadata": {},
|
||||
"status": "active",
|
||||
"description": null,
|
||||
"key_name": null,
|
||||
"partitions": {},
|
||||
"locked": false,
|
||||
"name": "test",
|
||||
"fault": null,
|
||||
"created_at": "2017-09-13T08:36:06Z",
|
||||
"locked_by": null
|
||||
}
|
||||
},
|
||||
"priority": "INFO",
|
||||
"publisher_id": "mogan-engine:localhost"
|
||||
}
|
@ -5,21 +5,30 @@
|
||||
"mogan_object.namespace": "mogan",
|
||||
"mogan_object.version": "1.0",
|
||||
"mogan_object.data": {
|
||||
"flavor_uuid": "6ce9904f-c61f-4ee8-afbe-c852c05258f6",
|
||||
"status": "building",
|
||||
"user_id": "dfc14a6e939646d1929362de1758d7b2",
|
||||
"uuid": "e1a7b5b7-c76c-4459-8328-10deda95819f",
|
||||
"node": "node-0",
|
||||
"addresses": [],
|
||||
"availability_zone": null,
|
||||
"fault": null,
|
||||
"created_at": "2017-01-06T08:26:18Z",
|
||||
"description": null,
|
||||
"updated_at": null,
|
||||
"image_uuid": "300fc139-73d3-46fd-86ef-267cb6c13341",
|
||||
"project_id": "216162836cb340a7946dad1c0c7aa650",
|
||||
"image_uuid": "91d3f6fd-012d-4d19-8140-abfe39d1c332",
|
||||
"user_id": "9851baf53c75452dad7951bca7b3dbac",
|
||||
"uuid": "692ee038-a963-4308-b596-60b0338649fd",
|
||||
"affinity_zone": null,
|
||||
"power_state": null,
|
||||
"flavor_uuid": "737ea130-153b-4599-b7b2-dc4c82480a31",
|
||||
"project_id": "b5f8b7e5429449a8a1366088abede8d1",
|
||||
"launched_at": null,
|
||||
"name": "test1"
|
||||
"metadata": {},
|
||||
"status": "building",
|
||||
"description": null,
|
||||
"key_name": null,
|
||||
"partitions": {},
|
||||
"locked": false,
|
||||
"name": "test",
|
||||
"fault": null,
|
||||
"created_at": "2017-09-13T08:36:06Z",
|
||||
"locked_by": null
|
||||
}
|
||||
},
|
||||
"priority": "INFO",
|
||||
"publisher_id": "mogan-engine:localhost"
|
||||
}
|
||||
}
|
||||
|
53
doc/notification_samples/server-delete-end.json
Normal file
53
doc/notification_samples/server-delete-end.json
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"event_type": "server.delete.end",
|
||||
"payload": {
|
||||
"mogan_object.name": "ServerActionPayload",
|
||||
"mogan_object.namespace": "mogan",
|
||||
"mogan_object.version": "1.0",
|
||||
"mogan_object.data": {
|
||||
"node": "node-0",
|
||||
"addresses": [{
|
||||
"mogan_object.name": "ServerAddressesPayload",
|
||||
"mogan_object.namespace": "mogan",
|
||||
"mogan_object.version": "1.0",
|
||||
"mogan_object.data": {
|
||||
"preserve_on_delete": false,
|
||||
"network_id": "dc7f826c-c11a-4f6c-99c5-b755184666b9",
|
||||
"fixed_ips": [{
|
||||
"subnet_id": "b102f49a-c602-4626-b605-03f1401e2ffb",
|
||||
"ip_address": "11.0.0.7"
|
||||
},
|
||||
{
|
||||
"subnet_id": "56d77d46-6ff2-4d2e-9400-35f7cb2760ea",
|
||||
"ip_address": "fdfd:dac2:5dc9:0:f816:3eff:fe8c:c903"
|
||||
}],
|
||||
"floating_ip": null,
|
||||
"mac_address": "52:54:00:bc:f0:fe",
|
||||
"port_id": "3931233a-cf89-4282-9726-1fb98e417f4d"
|
||||
}
|
||||
}],
|
||||
"availability_zone": null,
|
||||
"updated_at": "2017-09-13T08:18:00Z",
|
||||
"image_uuid": "91d3f6fd-012d-4d19-8140-abfe39d1c332",
|
||||
"user_id": "9851baf53c75452dad7951bca7b3dbac",
|
||||
"uuid": "e3cf7edd-8b24-4022-8567-ef2d779458c1",
|
||||
"affinity_zone": null,
|
||||
"power_state": null,
|
||||
"flavor_uuid": "737ea130-153b-4599-b7b2-dc4c82480a31",
|
||||
"project_id": "b5f8b7e5429449a8a1366088abede8d1",
|
||||
"launched_at": "2017-09-13T08:18:00Z",
|
||||
"metadata": {},
|
||||
"status": "deleted",
|
||||
"description": null,
|
||||
"key_name": null,
|
||||
"partitions": {},
|
||||
"locked": false,
|
||||
"name": "test",
|
||||
"fault": null,
|
||||
"created_at": "2017-09-13T08:15:21Z",
|
||||
"locked_by": null
|
||||
}
|
||||
},
|
||||
"priority": "INFO",
|
||||
"publisher_id": "mogan-engine:localhost"
|
||||
}
|
53
doc/notification_samples/server-delete-start.json
Normal file
53
doc/notification_samples/server-delete-start.json
Normal file
@ -0,0 +1,53 @@
|
||||
{
|
||||
"event_type": "server.delete.start",
|
||||
"payload": {
|
||||
"mogan_object.name": "ServerActionPayload",
|
||||
"mogan_object.namespace": "mogan",
|
||||
"mogan_object.version": "1.0",
|
||||
"mogan_object.data": {
|
||||
"node": "node-0",
|
||||
"addresses": [{
|
||||
"mogan_object.name": "ServerAddressesPayload",
|
||||
"mogan_object.namespace": "mogan",
|
||||
"mogan_object.version": "1.0",
|
||||
"mogan_object.data": {
|
||||
"preserve_on_delete": false,
|
||||
"network_id": "dc7f826c-c11a-4f6c-99c5-b755184666b9",
|
||||
"fixed_ips": [{
|
||||
"subnet_id": "b102f49a-c602-4626-b605-03f1401e2ffb",
|
||||
"ip_address": "11.0.0.7"
|
||||
},
|
||||
{
|
||||
"subnet_id": "56d77d46-6ff2-4d2e-9400-35f7cb2760ea",
|
||||
"ip_address": "fdfd:dac2:5dc9:0:f816:3eff:fe8c:c903"
|
||||
}],
|
||||
"floating_ip": null,
|
||||
"mac_address": "52:54:00:bc:f0:fe",
|
||||
"port_id": "3931233a-cf89-4282-9726-1fb98e417f4d"
|
||||
}
|
||||
}],
|
||||
"availability_zone": null,
|
||||
"updated_at": "2017-09-13T08:18:00Z",
|
||||
"image_uuid": "91d3f6fd-012d-4d19-8140-abfe39d1c332",
|
||||
"user_id": "9851baf53c75452dad7951bca7b3dbac",
|
||||
"uuid": "e3cf7edd-8b24-4022-8567-ef2d779458c1",
|
||||
"affinity_zone": null,
|
||||
"power_state": "power on",
|
||||
"flavor_uuid": "737ea130-153b-4599-b7b2-dc4c82480a31",
|
||||
"project_id": "b5f8b7e5429449a8a1366088abede8d1",
|
||||
"launched_at": "2017-09-13T08:18:00Z",
|
||||
"metadata": {},
|
||||
"status": "deleting",
|
||||
"description": null,
|
||||
"key_name": null,
|
||||
"partitions": {},
|
||||
"locked": false,
|
||||
"name": "test",
|
||||
"fault": null,
|
||||
"created_at": "2017-09-13T08:15:21Z",
|
||||
"locked_by": null
|
||||
}
|
||||
},
|
||||
"priority": "INFO",
|
||||
"publisher_id": "mogan-engine:localhost"
|
||||
}
|
@ -389,10 +389,14 @@ class EngineManager(base_manager.BaseEngineManager):
|
||||
request_spec,
|
||||
filter_properties,
|
||||
)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
with excutils.save_and_reraise_exception():
|
||||
utils.process_event(fsm, server, event='error')
|
||||
self._rollback_servers_quota(context, -1)
|
||||
notifications.notify_about_server_action(
|
||||
context, server, self.host,
|
||||
action=fields.NotificationAction.CREATE,
|
||||
phase=fields.NotificationPhase.ERROR, exception=e)
|
||||
msg = _("Create manager server flow failed.")
|
||||
LOG.exception(msg)
|
||||
|
||||
@ -411,19 +415,26 @@ class EngineManager(base_manager.BaseEngineManager):
|
||||
server.power_state = states.NOSTATE
|
||||
utils.process_event(fsm, server, event='error')
|
||||
self._rollback_servers_quota(context, -1)
|
||||
notifications.notify_about_server_action(
|
||||
context, server, self.host,
|
||||
action=fields.NotificationAction.CREATE,
|
||||
phase=fields.NotificationPhase.ERROR, exception=e)
|
||||
LOG.error("Created server %(uuid)s failed."
|
||||
"Exception: %(exception)s",
|
||||
{"uuid": server.uuid,
|
||||
"exception": e})
|
||||
else:
|
||||
# Advance the state model for the given event. Note that this
|
||||
# doesn't alter the server in any way. This may raise
|
||||
# InvalidState, if this event is not allowed in the current state.
|
||||
server.power_state = self.driver.get_power_state(context,
|
||||
server.uuid)
|
||||
server.launched_at = timeutils.utcnow()
|
||||
utils.process_event(fsm, server, event='done')
|
||||
LOG.info("Created server %s successfully.", server.uuid)
|
||||
# Advance the state model for the given event. Note that this
|
||||
# doesn't alter the server in any way. This may raise
|
||||
# InvalidState, if this event is not allowed in the current state.
|
||||
server.power_state = self.driver.get_power_state(context,
|
||||
server.uuid)
|
||||
server.launched_at = timeutils.utcnow()
|
||||
utils.process_event(fsm, server, event='done')
|
||||
notifications.notify_about_server_action(
|
||||
context, server, self.host,
|
||||
action=fields.NotificationAction.CREATE,
|
||||
phase=fields.NotificationPhase.END)
|
||||
LOG.info("Created server %s successfully.", server.uuid)
|
||||
|
||||
def _delete_server(self, context, server):
|
||||
"""Delete a server
|
||||
@ -431,8 +442,6 @@ class EngineManager(base_manager.BaseEngineManager):
|
||||
:param context: mogan request context
|
||||
:param server: server object
|
||||
"""
|
||||
# TODO(zhenguo): Add delete notification
|
||||
|
||||
try:
|
||||
self.destroy_networks(context, server)
|
||||
except Exception as e:
|
||||
@ -446,7 +455,10 @@ class EngineManager(base_manager.BaseEngineManager):
|
||||
def delete_server(self, context, server):
|
||||
"""Delete a server."""
|
||||
LOG.debug("Deleting server: %s.", server.uuid)
|
||||
|
||||
notifications.notify_about_server_action(
|
||||
context, server, self.host,
|
||||
action=fields.NotificationAction.DELETE,
|
||||
phase=fields.NotificationPhase.START)
|
||||
fsm = utils.get_state_machine(start_state=server.status,
|
||||
target_state=states.DELETED)
|
||||
|
||||
@ -475,6 +487,10 @@ class EngineManager(base_manager.BaseEngineManager):
|
||||
server.power_state = states.NOSTATE
|
||||
utils.process_event(fsm, server, event='done')
|
||||
server.destroy()
|
||||
notifications.notify_about_server_action(
|
||||
context, server, self.host,
|
||||
action=fields.NotificationAction.DELETE,
|
||||
phase=fields.NotificationPhase.END)
|
||||
LOG.info("Deleted server successfully.")
|
||||
|
||||
@wrap_server_fault
|
||||
|
Loading…
Reference in New Issue
Block a user