[ovs-dev] [PATCH 2/2] XenServer: Don't reset on xe-toolstack-restart

Jason Kölker jason at koelker.net
Wed Feb 4 23:12:31 UTC 2015


With XenServer only 1 manager is configured in the pool, which may not
be the first manager returned from `get-manager` as it returns in
lexicographical order.

Signed-off-by: Jason Kölker <jason at koelker.net>
---
 .../etc_xapi.d_plugins_openvswitch-cfg-update      | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
index aeaa1e7..a66becc 100755
--- a/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
+++ b/xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
@@ -59,10 +59,11 @@ def update(session, args):
         raise XenAPIPlugin.Failure('MORE_THAN_ONE_POOL_FOR_HOST', [])
     new_controller = False
     pool = session.xenapi.pool.get_record(pools[0])
-    controller = pool.get('vswitch_controller', '')
+    controller = pool.get('vswitch_controller')
     ret_str = ''
-    currentController = vswitchCurrentController()
-    if controller == '' and currentController != '':
+    currentControllers = vswitchCurrentControllers()
+
+    if not controller and currentControllers:
         delete_cacert()
         try:
             emergency_reset(session, None)
@@ -70,7 +71,7 @@ def update(session, args):
             pass
         removeControllerCfg()
         ret_str += 'Successfully removed controller config.  '
-    elif controller != currentController:
+    elif controller not in currentControllers:
         delete_cacert()
         try:
             emergency_reset(session, None)
@@ -194,14 +195,13 @@ def update(session, args):
         return 'No change to configuration'
 
 
-def vswitchCurrentController():
+def vswitchCurrentControllers():
     controller = vswitchCfgQuery(['get-manager'])
-    if controller == '':
-        return controller
-    if len(controller) < 4 or controller[0:4] != 'ssl:':
-        return controller
-    else:
-        return controller.split(':')[1]
+    if not controller:
+        return
+
+    return [c.lstrip('ssl:').split(':')[0]
+            for c in controller.split('\n')]
 
 
 def removeControllerCfg():
-- 
2.1.0




More information about the dev mailing list