Jump to: navigation, search

Difference between revisions of "Nova/ExternalEventAPI"

 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
  
 
# Neutron needs to notify Nova that a new floating IP has been allocated to an instance. Neutron sends an event of "network-changed" to Nova for the affected instance. Nova then refreshes the Instance's info_cache from neutron.
 
# Neutron needs to notify Nova that a new floating IP has been allocated to an instance. Neutron sends an event of "network-changed" to Nova for the affected instance. Nova then refreshes the Instance's info_cache from neutron.
# Nova is booting a guest and asks Neutron to plumb the VIFs. It makes that request and then blocks the boot while waiting for the callback from Neutron. When Neutron has completed, it sends an event of type "vif-plugged" with the tag set to the port_id of the relevant VIF for the affected instance. When all of the vif-plugged events have been received, Nova continues the boot process.
+
# Nova is booting a guest and asks Neutron to plumb the VIFs. It makes that request and then blocks the boot while waiting for the callback from Neutron. When Neutron has completed, it sends an event of type "network-vif-plugged" with the tag set to the port_id of the relevant VIF for the affected instance. When all of the vif-plugged events have been received, Nova continues the boot process.
 
# Nova needs Cinder to do a coordinated snapshot of a volume. Nova asks Cinder to do this and then blocks. When Cinder has completed, it sends an event of volume-snapshotted with the tag set to the volume_id for the affected Instance. Nova then unblocks the snapshotting process and continues.
 
# Nova needs Cinder to do a coordinated snapshot of a volume. Nova asks Cinder to do this and then blocks. When Cinder has completed, it sends an event of volume-snapshotted with the tag set to the volume_id for the affected Instance. Nova then unblocks the snapshotting process and continues.
  
 
== API Sample ==
 
== API Sample ==
  
 +
=== Request ===
 
To send the "test-event" with tag "foo" to a server, POST to /os-server-external-events something like:
 
To send the "test-event" with tag "foo" to a server, POST to /os-server-external-events something like:
  
Line 14: Line 15:
 
       "name": "test-event",
 
       "name": "test-event",
 
       "tag": "foo",
 
       "tag": "foo",
       "server_uuid": "71b20737-7f90-4513-abde-4a2dfd8ae97e"
+
       "server_uuid": "71b20737-7f90-4513-abde-4a2dfd8ae97e",
 +
      "status": "completed"
 
     },
 
     },
 
     {
 
     {
 
       "name": "other-event",
 
       "name": "other-event",
       "server_uuid": "0239e1f3-2603-4426-b1e4-786e0eaee2c3"
+
       "server_uuid": "0239e1f3-2603-4426-b1e4-786e0eaee2c3",
 +
      "status": "failed"
 
     }
 
     }
 
   ]
 
   ]
 +
}
 +
 +
Where:
 +
* "name" is one of the events defined in nova/objects/external_event.py
 +
* "status" is one of the statuses defined in nova/objects/external_event.py
 +
* "server_uuid" is the uuid of the server that the event is for
 +
* "tag" is an optional unique tag that identifies the event. In the case of network-vif-plugged it is the port_id, for example.
 +
 +
=== Response ===
 +
 +
The response returns the events that were provided in the request. Each event gains a "code" element which is an HTTP status code that pertains to the individual event. This allows multiple events to be delivered and status reported on them. If all the events are accepted, the response code for the overall response is 200. If none of them can be delivered (none pertain to a non-deleted instance) then 404 is returned. If some events are accepted and others are not, then 207 is returned, indicating a mixed response.
 +
 +
{
 +
    "events": [
 +
        {
 +
            "code": 200,
 +
            "name": "network-changed",
 +
            "server_uuid": "b376b585-848e-4fc3-a000-56635d645194",
 +
            "status": "completed",
 +
            "tag": "foo"
 +
        },
 +
        {
 +
            "code": 404,
 +
            "name": "network-changed",
 +
            "server_uuid": "4b25580b-1eb0-4ff4-90d8-eca3a4ee60c7",
 +
            "status": "failed",
 +
            "tag": "bar"
 +
        }
 +
    ]
 
  }
 
  }

Latest revision as of 18:35, 21 March 2014

Use-cases

  1. Neutron needs to notify Nova that a new floating IP has been allocated to an instance. Neutron sends an event of "network-changed" to Nova for the affected instance. Nova then refreshes the Instance's info_cache from neutron.
  2. Nova is booting a guest and asks Neutron to plumb the VIFs. It makes that request and then blocks the boot while waiting for the callback from Neutron. When Neutron has completed, it sends an event of type "network-vif-plugged" with the tag set to the port_id of the relevant VIF for the affected instance. When all of the vif-plugged events have been received, Nova continues the boot process.
  3. Nova needs Cinder to do a coordinated snapshot of a volume. Nova asks Cinder to do this and then blocks. When Cinder has completed, it sends an event of volume-snapshotted with the tag set to the volume_id for the affected Instance. Nova then unblocks the snapshotting process and continues.

API Sample

Request

To send the "test-event" with tag "foo" to a server, POST to /os-server-external-events something like:

{
 "events": [
   {
     "name": "test-event",
     "tag": "foo",
     "server_uuid": "71b20737-7f90-4513-abde-4a2dfd8ae97e",
     "status": "completed"
   },
   {
     "name": "other-event",
     "server_uuid": "0239e1f3-2603-4426-b1e4-786e0eaee2c3",
     "status": "failed"
   }
  ]
}

Where:

  • "name" is one of the events defined in nova/objects/external_event.py
  • "status" is one of the statuses defined in nova/objects/external_event.py
  • "server_uuid" is the uuid of the server that the event is for
  • "tag" is an optional unique tag that identifies the event. In the case of network-vif-plugged it is the port_id, for example.

Response

The response returns the events that were provided in the request. Each event gains a "code" element which is an HTTP status code that pertains to the individual event. This allows multiple events to be delivered and status reported on them. If all the events are accepted, the response code for the overall response is 200. If none of them can be delivered (none pertain to a non-deleted instance) then 404 is returned. If some events are accepted and others are not, then 207 is returned, indicating a mixed response.

{
   "events": [
       {
           "code": 200,
           "name": "network-changed",
           "server_uuid": "b376b585-848e-4fc3-a000-56635d645194",
           "status": "completed",
           "tag": "foo"
       },
       {
           "code": 404,
           "name": "network-changed",
           "server_uuid": "4b25580b-1eb0-4ff4-90d8-eca3a4ee60c7",
           "status": "failed",
           "tag": "bar"
       }
   ]
}