def set_container_agent_enabled_on_node(node, enabled):
 if enabled:
  d = node.run_script('enable_service', 'flocker-container-agent')
 else:
  d = node.run_script('disable_service', 'flocker-container-agent')
 if (not enabled):
  d.addCallback((lambda _: node.reboot()))
  d.addCallback((lambda _: deferLater(reactor, 20, (lambda : None))))
  d = d.addCallback((lambda _: verify_socket(node.public_address, 22)))
  d.addCallback((lambda _: loop_until(reactor, (lambda : is_process_running(node, 'flocker-dataset-agent')))))
  d.addCallback((lambda _: node.run_script('disable_service', 'flocker-dataset-agent')))
  d.addCallback((lambda _: node.run_script('enable_service', 'flocker-dataset-agent')))
  d.addCallback((lambda _: loop_until(reactor, (lambda : is_process_running(node, 'flocker-dataset-agent')))))
 d.addCallback((lambda _: None))
 return d

def set_container_agent_enabled_on_node ( node , enabled ) : if enabled : d = node . run_script ( 'enable_service' , 'flocker-container-agent' ) else : d = node . run_script ( 'disable_service' , 'flocker-container-agent' ) if ( not enabled ) : d . addCallback ( ( lambda _ : node . reboot ( ) ) ) d . addCallback ( ( lambda _ : deferLater ( reactor , 20 , ( lambda : None ) ) ) ) d = d . addCallback ( ( lambda _ : verify_socket ( node . public_address , 22 ) ) ) d . addCallback ( ( lambda _ : loop_until ( reactor , ( lambda : is_process_running ( node , 'flocker-dataset-agent' ) ) ) ) ) d . addCallback ( ( lambda _ : node . run_script ( 'disable_service' , 'flocker-dataset-agent' ) ) ) d . addCallback ( ( lambda _ : node . run_script ( 'enable_service' , 'flocker-dataset-agent' ) ) ) d . addCallback ( ( lambda _ : loop_until ( reactor , ( lambda : is_process_running ( node , 'flocker-dataset-agent' ) ) ) ) ) d . addCallback ( ( lambda _ : None ) ) return d
ensure the container agent is enabled/disabled as specified .