国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

linux中修改虛機IP的方法與問題

2024-08-27 23:59:17
字體:
來源:轉載
供稿:網友

前段時間,實現這么一個功能,界面上提供修改虛機IP地址的操作,后臺neutron用port update方法,neutron client的port update接口和其他資源的update方法不太一樣,參數沒指定正確,會導致一個port上出現兩個fixed ip.

接下來就是考慮floating ip的問題:

如果虛機綁定了浮動ip,修改虛機的fixed ip,在l3 namespace里還是會保存原來的iptables規則,因此,在port update之前要判斷floating ip的存在關系,需要解綁和綁定的操作.

修改完成后,測試,發現api請求的時間居然快30s,port update會給每個計算節點發送cast的rpc消息,而在消息隊列那邊,同事改了代碼,在cast消息中sleep了1s左右,因此到ml2 plugin的port update方法完成,耗費了很長的時間.

切回到內部環境測試后,使用neutron來看port的狀態,確實已經更新,但是前端并沒有及時的顯示,也就是說nova那邊并沒有及時的獲取這種狀態,當時以為和rpc的sleep有關,就沒仔細想這個問題.

后來老大問了這個問題,并且給出了nova的ExternalEventAPI.

ExternalEventAPI,我也趕緊看了下neutron這邊的代碼,在neutron的NeutronDbPluginV2類中,使用SQLAlchemy的事件監聽來監聽Port數據庫的變化,然后給nova發送notifier,代碼如下:

  1. class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2, 
  2.                         CommonDbMixin): 
  3.     """V2 Neutron plugin interface implementation using SQLAlchemy models. 
  4.  
  5.     Whenever a non-read call happens the plugin will call an event handler 
  6.     class method (e.g., network_created()).  The result is that this class 
  7.     can be sub-classed by other classes that add custom behaviors on certain 
  8.     events. 
  9.     ""
  10.  
  11.    
  12.     def __init__(self): 
  13.         db.configure_db() 
  14.         if cfg.CONF.notify_nova_on_port_status_changes: 
  15.             # NOTE(arosen) These event listners are here to hook into when  //Vevb.com 
  16.             # port status changes and notify nova about their change. 
  17.             self.nova_notifier = nova.Notifier() 
  18.             event.listen(models_v2.Port, 'after_insert'
  19.                          self.nova_notifier.send_port_status) 
  20.             event.listen(models_v2.Port, 'after_update'
  21.                          self.nova_notifier.send_port_status) 
  22.             event.listen(models_v2.Port.status, 'set'
  23.                          self.nova_notifier.record_port_status_changed) 

可見自己對代碼還沒有很熟悉,而且只關注自己這塊,不注意和其他組件的交互,接著和nova這邊的同事一起調試,在neutron server的日志中有報錯,代碼如下:

  1. 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 
  2. 2014-11-28 10:48:21.138 17163 INFO requests.packages.urllib3.connectionpool [-] Resetting dropped connection: 10.100.100.10 
  3. 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 
  4. 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'}] 
  5. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova Traceback (most recent call last): 
  6. 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 
  7. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova     batched_events) 
  8. 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 39, in create 
  9. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova     return_raw=True) 
  10. 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 
  11. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova     _resp, body = self.api.client.post(url, body=body) 
  12. 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 
  13. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova     return self._cs_request(url, 'POST', **kwargs) 
  14. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova   File "/usr/lib/python2.6/site-packages/novaclient/client.py", line 260, in _cs_request 
  15. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova     **kwargs) 
  16. 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 
  17. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova     resp, body = self.request(url, method, **kwargs) 
  18. 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 
  19. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova     raise exceptions.from_response(resp, body, url, method) 
  20. 2014-11-28 10:48:21.169 17163 TRACE neutron.notifiers.nova Forbidden: Policy doesn't allow compute_extension:os-server-external-events:create to be performed. (HTTP 403) (Request-ID: req-054895f0-fda1-4628-b288-d39d292db381) 

接下來同事調試,nova那邊使用keystone v3的接口,在nova的policy文件中,對應os-server-external-events:create需要admin的api操作:

  1. “compute_extension:os-server-external-events:create”: “rule:admin_api”, 
  2. “compute_extension:v3:os-server-external-events:create”: “rule:admin_api”, 

對于admin的context,需要admin的角色和cloud_admin的角色.

context_is_admin”:“role:admin and role:cloud_admin”,

因此需要給neutron加入cloud_admin的角色,keystone v3這塊的變化,需要去看看.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鄯善县| 林芝县| 罗源县| 固安县| 布尔津县| 上林县| 稻城县| 宝鸡市| 中江县| 霍邱县| 手游| 遵义县| 苏州市| 洮南市| 巩义市| 噶尔县| 旌德县| 德昌县| 砀山县| 华宁县| 和硕县| 靖江市| 通江县| 牡丹江市| 罗平县| 资讯 | 阿瓦提县| 微博| 汉川市| 泸溪县| 台山市| 板桥市| 镇雄县| 禹州市| 西峡县| 沙洋县| 东源县| 安溪县| 绥阳县| 布拖县| 沈阳市|