def change_node_state(deployer, desired_configuration):
 state_persister = InMemoryStatePersister()
 def converge():
  d = deployer.discover_state(DeploymentState(nodes={NodeState(hostname=deployer.hostname, uuid=deployer.node_uuid, applications=[], manifestations={}, paths={}, devices={})}), persistent_state=state_persister.get_state())
  def got_changes(local_state):
   changes = local_state.shared_state_changes()
   cluster_state = DeploymentState()
   for change in changes:
    cluster_state = change.update_cluster_state(cluster_state)
   return deployer.calculate_changes(desired_configuration, cluster_state, local_state)
  d.addCallback(got_changes)
  d.addCallback((lambda change: run_state_change(change, deployer=deployer, state_persister=state_persister)))
  return d
 result = converge()
 result.addCallback((lambda _: converge()))
 result.addCallback((lambda _: converge()))
 return result

def change_node_state ( deployer , desired_configuration ) : state_persister = InMemoryStatePersister ( ) def converge ( ) : d = deployer . discover_state ( DeploymentState ( nodes = { NodeState ( hostname = deployer . hostname , uuid = deployer . node_uuid , applications = [ ] , manifestations = { } , paths = { } , devices = { } ) } ) , persistent_state = state_persister . get_state ( ) ) def got_changes ( local_state ) : changes = local_state . shared_state_changes ( ) cluster_state = DeploymentState ( ) for change in changes : cluster_state = change . update_cluster_state ( cluster_state ) return deployer . calculate_changes ( desired_configuration , cluster_state , local_state ) d . addCallback ( got_changes ) d . addCallback ( ( lambda change : run_state_change ( change , deployer = deployer , state_persister = state_persister ) ) ) return d result = converge ( ) result . addCallback ( ( lambda _ : converge ( ) ) ) result . addCallback ( ( lambda _ : converge ( ) ) ) return result
change the local state to match the given desired state .