To get metadata from nova-api-metadata, you need to specify the ID of the instance. However, instance does not know its ID when it starts, so there is no instance ID information in the HTTP request, and the ID is added by neutron-metadata-agent. The two scenarios for L3-agent and dhcp-agent differ in implementation details, which are discussed separately below.
L3-agent
The following is the process flowchart for metadata HTTP requests in l3-agent participation.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170328-1490698232601009989.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170328-1490698365262089658.jpg "alt=" 30.png "style=" border:0px; "/>
The large process is: instance, Neutron-ns-metadata-proxy, Neutron-metadata-agent, nova-api-metadata, processing details are as follows:
①neutron-ns-metadata-proxy receives the request and adds the instance IP and router ID to the head of the HTTP request before forwarding to neutron-metadata-agent, both for l3- The agent is easy to get.
②neutron-metadata-agent receives the request, it queries the ID of the instance, as follows:
1) Find all the subnet of the router connection through the router ID and then filter out the subnet where the instance IP is located.
2) Locate the port corresponding to the instance IP in the subnet.
3) Locate the corresponding instance and its ID via port.
③neutron-metadata-agent adds the instance ID to the head of the HTTP request and forwards it to nova-api-metadata so that Nova-api-metadata can return the specified instance It's metadata.
Let's look at the situation of dhcp-agent again.
Dhcp-agent
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170328-1490698232601072527.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170328-1490698365499067662.jpg "alt=" 31.png "style=" BORDER:0PX;FONT-SIZE:14.4PX; Vertical-align:middle;float:none; "/>
①neutron-ns-metadata-proxy adds the instance IP and network ID to the head of the HTTP request before forwarding the request, both of which are readily available to dhcp-agent.
②neutron-metadata-agent receives the request, it queries the ID of the instance, as follows:
1) Locate all network subnet with the network ID and then filter out the subnet that the instance IP is located on.
2) Locate the port corresponding to the instance IP in the subnet.
3) Locate the corresponding instance and its ID via port.
③neutron-metadata-agent adds the instance ID to the head of the HTTP request and forwards it to nova-api-metadata so that Nova-api-metadata can return the specified instance It's metadata.
instance must first be able to obtain the correct DHCP IP , otherwise the request is not sent to However, not all environments will have DHCP enabled, and more extreme, some environments may not even have the Nova-api-metadata service enabled. So can instance still get metadata?
This is the subject we will discuss in the next section:configdrive.
650) this.width=650; "Title=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170312-1489323234694028485.png "src=" http://7xo6kd.com1.z0.glb.clouddn.com/ Upload-ueditor-image-20170328-1490698365890052630.jpg "style=" border:0px;float:none; "/>
Instance how to get their own Metadata-5 minutes a day to play with OpenStack (169)