Skip to content

Commit

Permalink
XenServer: Don't reset on xe-toolstack-restart
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
jkoelker authored and blp committed Feb 7, 2015
1 parent 9ba4f3c commit 032c09d
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,19 @@ 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)
except:
pass
removeControllerCfg()
ret_str += 'Successfully removed controller config. '
elif controller != currentController:
elif controller not in currentControllers:
delete_cacert()
try:
emergency_reset(session, None)
Expand Down Expand Up @@ -194,14 +195,18 @@ def update(session, args):
return 'No change to configuration'


def vswitchCurrentController():
controller = vswitchCfgQuery(['get-manager'])
if controller == '':
return controller
if len(controller) < 4 or controller[0:4] != 'ssl:':
return controller
else:
return controller.split(':')[1]
def vswitchCurrentControllers():
controllers = vswitchCfgQuery(['get-manager'])

def parse_controller(controller):
if controller.startswith('ssl:'):
return controller.split(':')[1]

return controller.split(':')[0]

return [parse_controller(controller)
for controller in controllers.split('\n')
if controller]


def removeControllerCfg():
Expand Down

0 comments on commit 032c09d

Please sign in to comment.