Methods and problems of modifying virtual machine IP in Linux

Source: Internet
Author: User
Tags message queue sleep

Some time ago, to achieve such a function, interface to provide modify virtual machine IP address operation, background neutron with the port Update method.
The neutron client's port update interface and other resource update methods are not the same, and the parameter is not specified correctly, which results in the presence of two fixed IP on a port.


The next step is to consider the issue of floating IP.

If the virtual machine is bound floating IP, modify the virtual machine fixed IP, in L3 namespace will still save the original iptables rules. Therefore, before the port update to determine the existence of floating IP relationship, the need to unbind and bind the operation.

After the modification is complete, test. The time to discover API requests was incredibly fast 30s. Port update sends a cast RPC message to each compute node, and in the message queue, the colleague changes the code and sleep around 1s in the cast message, so it takes a long time to complete the ML2 plugin port Update method.

After cutting back to the internal environment test, using neutron to look at the state of port, has indeed been updated. But the front end is not timely display, that is, Nova there is no timely access to this state. I thought it was about the sleep of RPC, and I didn't think about it very carefully.

Later, the boss asked the question, and gave the Nova Externaleventapi.
Externaleventapi

I also quickly looked at the next neutron this code, in the Neutron NeutronDbPluginV2 class, the use of SQLAlchemy event monitoring to monitor the changes in the port database, and then send the Nova notifier.

The code is as follows Copy Code
Class NeutronDbPluginV2 (NEUTRON_PLUGIN_BASE_V2. NeutronPluginBaseV2,
Commondbmixin):
"" "V2 Neutron Plugin interface implementation using SQLAlchemy models.

Whenever a non-read call happens the plugin'll call an event handler
class method (e.g., network_created ()). The result was that this class
Can is sub-classed by the other classes this add custom behaviors on certain
Events.
"""


def __init__ (self):
db.configure_db ()
If Cfg. Conf.notify_nova_on_port_status_changes:
# Note (Arosen) These event listners are
# Port status changes and notify Nova about their change.
Self.nova_notifier = Nova. Notifier ()
Event.listen (MODELS_V2. Port, ' After_insert ',
Self.nova_notifier.send_port_status)
Event.listen (MODELS_V2. Port, ' after_update ',
Self.nova_notifier.send_port_status)
Event.listen (MODELS_V2. Port.status, ' Set ',
self.nova_notifier.record_port_status_changed)

It can be seen that you are not familiar with the code, and only focus on their own, do not pay attention to the interaction with other components.

And then with the Nova side of the team debugging, in the log of neutron server has an error:

The code is as follows Copy Code

2014-11-28 10:48:21.137 17163 DEBUG Neutron.notifiers.nova [req-6b23770b-4f0d-4e85-ba21-1c47f191e136 None] Sending Events: [{' Status ': ' Completed ', ' tag ': U ' ddc6cb03-1963-4f7e-bf07-e55acbada573 ', ' name ': ' network-vif-plugged ', ' Server_uuid ': U ' fcb2531c-878c-4934-ac7b-9f792071756d '}] send_events/usr/lib/python2.6/site-packages/neutron/ notifiers/nova.py:218
2014-11-28 10:48:21.138 17163 INFO requests.packages.urllib3.connectionpool [-] resetting dropped: 10.100.100.10
2014-11-28 10:48:21.168 17163 DEBUG requests.packages.urllib3.connectionpool [-] "post/v2/ 6d381a3f7609474d9cb9b5421cf89943/os-server-external-events http/1.1 "403 131 _make_request/usr/lib/python2.6/ site-packages/requests/packages/urllib3/connectionpool.py:362
2014-11-28 10:48:21.169 17163 ERROR Neutron.notifiers.nova [req-6b23770b-4f0d-4e85-ba21-1c47f191e136 None] Failed to Notify Nova on events: [{' Status ': ' Completed ', ' tag ': U ' ddc6cb03-1963-4f7e-bf07-e55acbada573 ', ' name ': ' Network-vif-plugged ', ' Server_uuid ': U ' fcb2531c-878c-4934-ac7b-9f792071756d '}]
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova traceback (most recent call last):
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova File "/usr/lib/python2.6/site-packages/neutron/notifiers/ nova.py ", line 221, in Send_events
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova batched_events)
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova File "/usr/lib/python2.6/site-packages/novaclient/v1_1/ contrib/server_external_events.py ", line A, in Create
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova return_raw=true)
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova File "/usr/lib/python2.6/site-packages/novaclient/base.py ", line 152, in _create
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova _resp, BODY = self.api.client.post (URL, body=body)
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova File "/usr/lib/python2.6/site-packages/novaclient/ client.py ", line 286, in post
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova return self._cs_request (URL, ' POST ', **kwargs)
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova File "/usr/lib/python2.6/site-packages/novaclient/ client.py ", line, _cs_request
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova **kwargs)
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova File "/usr/lib/python2.6/site-packages/novaclient/ client.py ", line 242, in _time_request
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova resp, body = self.request (URL, method, **kwargs)
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova File "/usr/lib/python2.6/site-packages/novaclient/ client.py ", line 236, in Request
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova raise Exceptions.from_response (resp, body, URLs, method)
2014-11-28 10:48:21.169 17163 TRACE Neutron.notifiers.nova forbidden:policy doesn ' t allow Compute_extension:o S-server-external-events:create to be performed. (HTTP 403) (request-id:req-054895f0-fda1-4628-b288-d39d292db381)
Next colleague debugging, Nova over there using Keystone V3 interface, in the Nova policy file, corresponding Os-server-external-events:create need admin API operation:
"Compute_extension:os-server-external-events:create": "Rule:admin_api",
"Compute_extension:v3:os-server-external-events:create": "Rule:admin_api",

For the admin context, admin roles and cloud_admin roles are required.
Context_is_admin ":" Role:admin and Role:cloud_admin ",

It is therefore necessary to add the role of cloud_admin to neutron. Keystone V3 This piece of change, need to see.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.