Example #1
0
    def do_startup(self, config, serviceNodeKwargs, cloud):
        self.logger.debug('do_startup: Going to request %d new nodes' %
                          len(serviceNodeKwargs))

        try:
            cloud = self._init_cloud(cloud)
        except Exception:
            self.logger.exception("A cloud named '%s' could not be found" %
                                  cloud)
            self._state_set(self.S_STOPPED, msg='Unknown cloud: %s' % cloud)
            return

        try:
            self._adapting_set_count(len(serviceNodeKwargs))
            node_instances = self.controller.create_nodes(
                len(serviceNodeKwargs), client.check_agent_process, 5555,
                cloud)
        except:
            self.logger.exception(
                'do_startup: Failed to request new nodes. Needed %d' %
                (len(serviceNodeKwargs)))
            self._state_set(self.S_STOPPED, msg='Failed to request new nodes')
            return
        finally:
            self._adapting_set_count(0)

        config.serviceNodes.clear()
        i = 0
        for kwargs in serviceNodeKwargs:
            config.serviceNodes[node_instances[i].id] = WebServiceNode(
                node_instances[i], **kwargs)
            i += 1
        config.update_mappings()

        # issue orders to agents to start PHP inside
        self._start_backend(config, config.getBackendServiceNodes())

        # stage the code files
        # NOTE: Code update is done after starting the backend
        #       because tomcat-create-instance complains if its
        #       directory exists when it is run and placing the
        #       code can only be done after creating the instance
        if config.currentCodeVersion != None:
            self._update_code(config, config.serviceNodes.values())

        # issue orders to agents to start web servers inside
        self._start_web(config, config.getWebServiceNodes())

        # issue orders to agents to start proxy inside
        self._start_proxy(config, config.getProxyServiceNodes())

        self._configuration_set(config)  # update configuration
        self._state_set(self.S_RUNNING)
        self.memcache.set('nodes_additional', [])
Example #2
0
  def do_startup(self, config, serviceNodeKwargs, cloud):
    self.logger.debug('do_startup: Going to request %d new nodes' % len(serviceNodeKwargs))

    try:
      cloud = self._init_cloud(cloud)
    except Exception:
      self.logger.exception("A cloud named '%s' could not be found" % cloud)
      self._state_set(self.S_STOPPED, msg='Unknown cloud: %s' % cloud)
      return 

    try:
      self._adapting_set_count(len(serviceNodeKwargs))
      node_instances = self.controller.create_nodes(len(serviceNodeKwargs),
                                                    client.check_agent_process, 5555, cloud)
    except:
      self.logger.exception('do_startup: Failed to request new nodes. Needed %d' % (len(serviceNodeKwargs)))
      self._state_set(self.S_STOPPED, msg='Failed to request new nodes')
      return
    finally:
      self._adapting_set_count(0)
    
    config.serviceNodes.clear()
    i = 0
    for kwargs in serviceNodeKwargs:
      config.serviceNodes[node_instances[i].id] = WebServiceNode(node_instances[i], **kwargs)
      i += 1
    config.update_mappings()
    
    # issue orders to agents to start PHP inside
    self._start_backend(config, config.getBackendServiceNodes())
    
    # stage the code files
    # NOTE: Code update is done after starting the backend
    #       because tomcat-create-instance complains if its
    #       directory exists when it is run and placing the
    #       code can only be done after creating the instance
    if config.currentCodeVersion != None:
      self._update_code(config, config.serviceNodes.values())
    
    # issue orders to agents to start web servers inside
    self._start_web(config, config.getWebServiceNodes())
    
    # issue orders to agents to start proxy inside
    self._start_proxy(config, config.getProxyServiceNodes())
    
    self._configuration_set(config) # update configuration
    self._state_set(self.S_RUNNING)
    self.memcache.set('nodes_additional', [])
Example #3
0
  def update_nodes_weight(self, kwargs):
    config = self._configuration_get()
    dstate = self._state_get()
    if dstate != self.S_RUNNING:
      self.logger.critical('update_nodes_weight function: STATE_ERROR')
      return HttpErrorResponse(ManagerException(ManagerException.E_STATE_ERROR).message)
    
    self.logger.debug('Received request to update nodes weight...')
    
    backend_weights = {}
    web_weights = {}

    if 'web' in kwargs:
      if not isinstance(kwargs['web'], dict):
        return HttpErrorResponse(ManagerException(ManagerException.E_ARGS_INVALID, detail='Expected a dictionary value for "web"').message)
      web_weights = kwargs.pop('web')
          
    if 'backend' in kwargs:
      if not isinstance(kwargs['backend'], dict):
        return HttpErrorResponse(ManagerException(ManagerException.E_ARGS_INVALID, detail='Expected a dictionary value for "backend"').message)
      backend_weights = kwargs.pop('backend')
      
    for web_id in web_weights:
      if web_id not in config.serviceNodes:
        return HttpErrorResponse(ManagerException(ManagerException.E_ARGS_INVALID, detail='The web node ID does not exist').message)
      self.logger.debug('Updating web weight for node: %s to: %s ' % (str(web_id), str(web_weights[web_id])))
      config.serviceNodes[web_id].weightWeb = int(web_weights[web_id])
      
    for backend_id in backend_weights:
      if backend_id not in config.serviceNodes:
        return HttpErrorResponse(ManagerException(ManagerException.E_ARGS_INVALID, detail='The backend node ID does not exist').message)
      self.logger.debug('Updating backend weight for node: %s to: %s ' % (str(backend_id), str(backend_weights[backend_id])))
      config.serviceNodes[backend_id].weightBackend = int(backend_weights[backend_id])
     
    self.logger.debug("Result of updating node weights: %s" % str(config.serviceNodes))
    
    for web_id in web_weights:
      if web_id not in config.serviceNodes:
        return HttpErrorResponse(ManagerException(ManagerException.E_ARGS_INVALID, detail='The web node ID does not exist').message)
      config.serviceNodes[web_id].webWeight = int(web_weights[web_id])
    
    config.update_mappings()  
    self._update_proxy(config, [ i for i in config.serviceNodes.values() if i.isRunningProxy ])
    self._configuration_set(config)

    return HttpJsonResponse()
Example #4
0
    def do_remove_nodes(self, config, proxy, web, backend):
        packBackend = False
        packWeb = False
        packingNode = None

        backendNodesKill = []
        webNodesKill = []
        proxyNodesKill = []

        if web > 0:
            webNodesKill += config.getWebServiceNodes()[-web:]
            if config.web_count - web == 0:
                packWeb = True

        if backend > 0:
            backendNodesKill += config.getBackendServiceNodes()[-backend:]
            if config.backend_count - backend == 0:
                packBackend = True

        if proxy > 0:
            proxyNodesKill += config.getProxyServiceNodes()[-proxy:]

        packingNode = config.getProxyServiceNodes()[0]
        for i in webNodesKill:
            i.isRunningWeb = False
        for i in backendNodesKill:
            i.isRunningBackend = False
        for i in proxyNodesKill:
            i.isRunningProxy = False
        if packBackend: packingNode.isRunningBackend = True
        if packWeb: packingNode.isRunningWeb = True

        config.update_mappings()

        # new nodes
        if packBackend:
            # NOTE: Code update is done after starting the backend
            #       because tomcat-create-instance complains if its
            #       directory exists when it is run and placing the
            #       code can only be done after creating the instance
            self._start_backend(config, [packingNode])
            self._update_code(config, [packingNode])
        if packWeb: self._start_web(config, [packingNode])

        if webNodesKill or backendNodesKill:
            self._update_proxy(config, [
                i for i in config.serviceNodes.values()
                if i.isRunningProxy and i not in proxyNodesKill
            ])

        # remove_nodes nodes
        self._stop_backend(config, backendNodesKill)
        self._stop_web(config, webNodesKill)
        self._stop_proxy(config, proxyNodesKill)

        for i in config.serviceNodes.values():
            if not i.isRunningBackend and not i.isRunningWeb and not i.isRunningProxy:
                del config.serviceNodes[i.id]
                self.controller.delete_nodes([i])

        config.proxy_count = len(config.getProxyServiceNodes())
        config.backend_count = len(config.getBackendServiceNodes())
        if config.backend_count == 1 and config.getBackendServiceNodes(
        )[0] in config.getProxyServiceNodes():
            config.backend_count = 0
        config.web_count = len(config.getWebServiceNodes())
        if config.web_count == 1 and config.getWebServiceNodes(
        )[0] in config.getProxyServiceNodes():
            config.web_count = 0

        self._state_set(self.S_RUNNING)
        self._configuration_set(config)
Example #5
0
    def do_add_nodes(self, config, proxy, web, backend, cloud):
        webNodesNew = []
        proxyNodesNew = []
        backendNodesNew = []

        webNodesKill = []
        backendNodesKill = []

        try:
            cloud = self._init_cloud(cloud)
        except Exception:
            self.logger.exception("A cloud named '%s' could not be found" %
                                  cloud)
            self._state_set(self.S_RUNNING, msg='Unknown cloud: %s' % cloud)
            return

        if backend > 0 and config.backend_count == 0:
            backendNodesKill.append(config.getBackendServiceNodes()[0])
        if web > 0 and config.web_count == 0:
            webNodesKill.append(config.getWebServiceNodes()[0])

        for _ in range(backend):
            backendNodesNew.append({'runBackend': True})
        for _ in range(web):
            webNodesNew.append({'runWeb': True})
        for _ in range(proxy):
            proxyNodesNew.append({'runProxy': True})

        for i in webNodesKill:
            i.isRunningWeb = False
        for i in backendNodesKill:
            i.isRunningBackend = False

        newNodes = []
        try:
            self._adapting_set_count(
                len(proxyNodesNew) + len(webNodesNew) + len(backendNodesNew))
            node_instances = self.controller.create_nodes(
                len(proxyNodesNew) + len(webNodesNew) + len(backendNodesNew),
                client.check_agent_process, 5555, cloud)
        except:
            self.logger.exception(
                'do_add_nodes: Failed to request new nodes. Needed %d' %
                (len(proxyNodesNew + webNodesNew + backendNodesNew)))
            self._state_set(
                self.S_RUNNING,
                msg=
                'Failed to request new nodes. Reverting to old configuration')
            return
        finally:
            self._adapting_set_count(0)

        i = 0
        for kwargs in proxyNodesNew + webNodesNew + backendNodesNew:
            config.serviceNodes[node_instances[i].id] = WebServiceNode(
                node_instances[i], **kwargs)
            newNodes += [config.serviceNodes[node_instances[i].id]]
            i += 1
        config.update_mappings()

        # create new service nodes
        self._start_backend(
            config, [node for node in newNodes if node.isRunningBackend])
        # stage code files in all new VMs
        # NOTE: Code update is done after starting the backend
        #       because tomcat-create-instance complains if its
        #       directory exists when it is run and placing the
        #       code can only be done after creating the instance
        if config.currentCodeVersion != None:
            self._update_code(
                config,
                [node for node in newNodes if node not in config.serviceNodes])

        self._start_web(config,
                        [node for node in newNodes if node.isRunningWeb])
        self._start_proxy(config,
                          [node for node in newNodes if node.isRunningProxy])

        # update services
        if webNodesNew or backendNodesNew:
            self._update_proxy(config, [
                i for i in config.serviceNodes.values()
                if i.isRunningProxy and i not in newNodes
            ])
        # remove_nodes old ones
        self._stop_backend(config, backendNodesKill)
        self._stop_web(config, webNodesKill)

        config.proxy_count = len(config.getProxyServiceNodes())
        config.backend_count = len(config.getBackendServiceNodes())
        if config.backend_count == 1 and config.getBackendServiceNodes(
        )[0] in config.getProxyServiceNodes():
            config.backend_count = 0
        config.web_count = len(config.getWebServiceNodes())
        if config.web_count == 1 and config.getWebServiceNodes(
        )[0] in config.getProxyServiceNodes():
            config.web_count = 0

        self._state_set(self.S_RUNNING)
        self._configuration_set(config)
        self.memcache.set('nodes_additional', [])
Example #6
0
    def update_nodes_weight(self, kwargs):
        config = self._configuration_get()
        dstate = self._state_get()
        if dstate != self.S_RUNNING:
            self.logger.critical('update_nodes_weight function: STATE_ERROR')
            return HttpErrorResponse(
                ManagerException(ManagerException.E_STATE_ERROR).message)

        self.logger.debug('Received request to update nodes weight...')

        backend_weights = {}
        web_weights = {}

        if 'web' in kwargs:
            if not isinstance(kwargs['web'], dict):
                return HttpErrorResponse(
                    ManagerException(
                        ManagerException.E_ARGS_INVALID,
                        detail='Expected a dictionary value for "web"').message
                )
            web_weights = kwargs.pop('web')

        if 'backend' in kwargs:
            if not isinstance(kwargs['backend'], dict):
                return HttpErrorResponse(
                    ManagerException(
                        ManagerException.E_ARGS_INVALID,
                        detail='Expected a dictionary value for "backend"').
                    message)
            backend_weights = kwargs.pop('backend')

        for web_id in web_weights:
            if web_id not in config.serviceNodes:
                return HttpErrorResponse(
                    ManagerException(
                        ManagerException.E_ARGS_INVALID,
                        detail='The web node ID does not exist').message)
            self.logger.debug('Updating web weight for node: %s to: %s ' %
                              (str(web_id), str(web_weights[web_id])))
            config.serviceNodes[web_id].weightWeb = int(web_weights[web_id])

        for backend_id in backend_weights:
            if backend_id not in config.serviceNodes:
                return HttpErrorResponse(
                    ManagerException(
                        ManagerException.E_ARGS_INVALID,
                        detail='The backend node ID does not exist').message)
            self.logger.debug(
                'Updating backend weight for node: %s to: %s ' %
                (str(backend_id), str(backend_weights[backend_id])))
            config.serviceNodes[backend_id].weightBackend = int(
                backend_weights[backend_id])

        self.logger.debug("Result of updating node weights: %s" %
                          str(config.serviceNodes))

        for web_id in web_weights:
            if web_id not in config.serviceNodes:
                return HttpErrorResponse(
                    ManagerException(
                        ManagerException.E_ARGS_INVALID,
                        detail='The web node ID does not exist').message)
            config.serviceNodes[web_id].webWeight = int(web_weights[web_id])

        config.update_mappings()
        self._update_proxy(
            config,
            [i for i in config.serviceNodes.values() if i.isRunningProxy])
        self._configuration_set(config)

        return HttpJsonResponse()
Example #7
0
    def do_remove_nodes(self, config, proxy, web, backend, node_ip=None):
        packBackend = False
        packWeb = False
        packingNode = None

        backendNodesKill = []
        webNodesKill = []
        proxyNodesKill = []

        if web > 0:
            if node_ip != None:
                for serviceNode in config.getWebServiceNodes():
                    if (serviceNode.ip == node_ip):
                        webNodesKill.append(serviceNode)
            else:
                webNodesKill += config.getWebServiceNodes()[-web:]
            if config.web_count - web == 0:
                packWeb = True

        if backend > 0:
            if node_ip != None:
                for serviceNode in config.getBackendServiceNodes():
                    if (serviceNode.ip == node_ip):
                        backendNodesKill.append(serviceNode)
            else:
                backendNodesKill += config.getBackendServiceNodes()[-backend:]
            if config.backend_count - backend == 0:
                packBackend = True

        if proxy > 0:
            proxyNodesKill += config.getProxyServiceNodes()[-proxy:]

        packingNode = config.getProxyServiceNodes()[0]
        for i in webNodesKill:
            i.isRunningWeb = False
        for i in backendNodesKill:
            i.isRunningBackend = False
        for i in proxyNodesKill:
            i.isRunningProxy = False
        if packBackend: packingNode.isRunningBackend = True
        if packWeb: packingNode.isRunningWeb = True

        config.update_mappings()
        self.logger.info("Remove_nodes " + str(config.serviceNodes))
        # new nodes
        if packBackend:
            # NOTE: Code update is done after starting the backend
            #       because tomcat-create-instance complains if its
            #       directory exists when it is run and placing the
            #       code can only be done after creating the instance
            self._start_backend(config, [packingNode])
            self._update_code(config, [packingNode])
        if packWeb: self._start_web(config, [packingNode])

        if webNodesKill or backendNodesKill:
            self._update_proxy(config, [
                i for i in config.serviceNodes.values()
                if i.isRunningProxy and i not in proxyNodesKill
            ])

        try:
            # remove_nodes nodes
            self._stop_backend(config, backendNodesKill)
            self._stop_web(config, webNodesKill)
            self._stop_proxy(config, proxyNodesKill)

            #   self.logger.info("Internal php: service nodes "+str(config.serviceNodes.values()))
            for i in config.serviceNodes.values():
                if not i.isRunningBackend and not i.isRunningWeb and not i.isRunningProxy:
                    del config.serviceNodes[i.id]
                    self.controller.delete_nodes([i])
        #    self.logger.info("Internal php: Removing_node "+str(i.id))

            config.proxy_count = len(config.getProxyServiceNodes())
            config.backend_count = len(config.getBackendServiceNodes())
            if config.backend_count == 1 and config.getBackendServiceNodes(
            )[0] in config.getProxyServiceNodes():
                config.backend_count = 0
            config.web_count = len(config.getWebServiceNodes())
            if config.web_count == 1 and config.getWebServiceNodes(
            )[0] in config.getProxyServiceNodes():
                config.web_count = 0

            #  config.update_mappings()
            self.logger.info("Remove_nodes " + str(config.serviceNodes))

        except Exception:
            self.logger.critical('Error when trying to remove ')

        self._state_set(self.S_RUNNING)
        self._configuration_set(config)
Example #8
0
 def do_remove_nodes(self, config, proxy, web, backend):
   packBackend = False
   packWeb = False
   packingNode = None
   
   backendNodesKill = []
   webNodesKill = []
   proxyNodesKill = []
   
   if web > 0:
     webNodesKill += config.getWebServiceNodes()[-web:]
     if config.web_count - web == 0:
       packWeb = True
   
   if backend > 0:
     backendNodesKill += config.getBackendServiceNodes()[-backend:]
     if config.backend_count - backend == 0:
       packBackend = True
   
   if proxy > 0:
     proxyNodesKill += config.getProxyServiceNodes()[-proxy:]
   
   packingNode = config.getProxyServiceNodes()[0]
   for i in webNodesKill: i.isRunningWeb = False
   for i in backendNodesKill: i.isRunningBackend = False
   for i in proxyNodesKill: i.isRunningProxy = False
   if packBackend: packingNode.isRunningBackend = True
   if packWeb: packingNode.isRunningWeb = True
   
   config.update_mappings()
   
   # new nodes
   if packBackend:
     # NOTE: Code update is done after starting the backend
     #       because tomcat-create-instance complains if its
     #       directory exists when it is run and placing the
     #       code can only be done after creating the instance
     self._start_backend(config, [packingNode])
     self._update_code(config, [packingNode])
   if packWeb: self._start_web(config, [packingNode])
   
   if webNodesKill or backendNodesKill:
     self._update_proxy(config, [ i for i in config.serviceNodes.values() if i.isRunningProxy and i not in proxyNodesKill ])
   
   # remove_nodes nodes
   self._stop_backend(config, backendNodesKill)
   self._stop_web(config, webNodesKill)
   self._stop_proxy(config, proxyNodesKill)
   
   for i in config.serviceNodes.values():
     if not i.isRunningBackend and not i.isRunningWeb and not i.isRunningProxy:
       del config.serviceNodes[i.id]
       self.controller.delete_nodes([i])
   
   
   config.proxy_count = len(config.getProxyServiceNodes())
   config.backend_count = len(config.getBackendServiceNodes())
   if config.backend_count == 1 and config.getBackendServiceNodes()[0] in config.getProxyServiceNodes():
     config.backend_count = 0
   config.web_count = len(config.getWebServiceNodes())
   if config.web_count == 1 and config.getWebServiceNodes()[0] in config.getProxyServiceNodes():
     config.web_count = 0
   
   self._state_set(self.S_RUNNING)
   self._configuration_set(config)
Example #9
0
  def do_add_nodes(self, config, proxy, web, backend, cloud):
    webNodesNew = []
    proxyNodesNew = []
    backendNodesNew = []
    
    webNodesKill = []
    backendNodesKill = []
    
    try:
      cloud = self._init_cloud(cloud)
    except Exception:
      self.logger.exception("A cloud named '%s' could not be found" % cloud)
      self._state_set(self.S_RUNNING, msg='Unknown cloud: %s' % cloud)
      return 

    if backend > 0 and config.backend_count == 0:
      backendNodesKill.append(config.getBackendServiceNodes()[0])
    if web > 0 and config.web_count == 0:
      webNodesKill.append(config.getWebServiceNodes()[0])
    
    for _ in range(backend): backendNodesNew.append({'runBackend':True})
    for _ in range(web): webNodesNew.append({'runWeb':True})
    for _ in range(proxy): proxyNodesNew.append({'runProxy':True})
    
    for i in webNodesKill: i.isRunningWeb = False
    for i in backendNodesKill: i.isRunningBackend = False
    
    newNodes = []
    try:
      self._adapting_set_count(len(proxyNodesNew) + len(webNodesNew) + len(backendNodesNew))
      node_instances = self.controller.create_nodes(len(proxyNodesNew) + len(webNodesNew) + len(backendNodesNew),
                                                    client.check_agent_process, 5555, cloud)
    except:
      self.logger.exception('do_add_nodes: Failed to request new nodes. Needed %d' % (len(proxyNodesNew + webNodesNew + backendNodesNew)))
      self._state_set(self.S_RUNNING, msg='Failed to request new nodes. Reverting to old configuration')
      return
    finally:
      self._adapting_set_count(0)
    
    i = 0
    for kwargs in proxyNodesNew + webNodesNew + backendNodesNew:
      config.serviceNodes[node_instances[i].id] = WebServiceNode(node_instances[i], **kwargs)
      newNodes += [ config.serviceNodes[node_instances[i].id] ]
      i += 1
    config.update_mappings()
    
    # create new service nodes
    self._start_backend(config, [ node for node in newNodes if node.isRunningBackend ])
    # stage code files in all new VMs
    # NOTE: Code update is done after starting the backend
    #       because tomcat-create-instance complains if its
    #       directory exists when it is run and placing the
    #       code can only be done after creating the instance
    if config.currentCodeVersion != None:
      self._update_code(config, [ node for node in newNodes if node not in config.serviceNodes ])
    
    self._start_web(config, [ node for node in newNodes if node.isRunningWeb ])
    self._start_proxy(config, [ node for node in newNodes if node.isRunningProxy ])
    
    # update services
    if webNodesNew or backendNodesNew:
      self._update_proxy(config, [ i for i in config.serviceNodes.values() if i.isRunningProxy and i not in newNodes ])
    # remove_nodes old ones
    self._stop_backend(config, backendNodesKill)
    self._stop_web(config, webNodesKill)
    
    config.proxy_count = len(config.getProxyServiceNodes())
    config.backend_count = len(config.getBackendServiceNodes())
    if config.backend_count == 1 and config.getBackendServiceNodes()[0] in config.getProxyServiceNodes():
      config.backend_count = 0
    config.web_count = len(config.getWebServiceNodes())
    if config.web_count == 1 and config.getWebServiceNodes()[0] in config.getProxyServiceNodes():
      config.web_count = 0
    
    self._state_set(self.S_RUNNING)
    self._configuration_set(config)
    self.memcache.set('nodes_additional', [])
Example #10
0
  def do_remove_nodes(self, config, proxy, web, backend, node_ip=None):
    packBackend = False
    packWeb = False
    packingNode = None
    
    backendNodesKill = []
    webNodesKill = []
    proxyNodesKill = []
    
    if web > 0:
      if node_ip != None:
          for serviceNode in config.getWebServiceNodes():
              if( serviceNode.ip == node_ip):
                webNodesKill.append(serviceNode)
      else:     
          webNodesKill += config.getWebServiceNodes()[-web:]
      if config.web_count - web == 0:
        packWeb = True
    
    if backend > 0:
      if node_ip != None:  
          for serviceNode in config.getBackendServiceNodes():
              if( serviceNode.ip == node_ip):
                backendNodesKill.append(serviceNode)             
      else:
          backendNodesKill += config.getBackendServiceNodes()[-backend:]
      if config.backend_count - backend == 0:
        packBackend = True
    
    if proxy > 0:
      proxyNodesKill += config.getProxyServiceNodes()[-proxy:]
    
    packingNode = config.getProxyServiceNodes()[0]
    for i in webNodesKill: i.isRunningWeb = False
    for i in backendNodesKill: i.isRunningBackend = False
    for i in proxyNodesKill: i.isRunningProxy = False
    if packBackend: packingNode.isRunningBackend = True
    if packWeb: packingNode.isRunningWeb = True
    
    config.update_mappings()
    self.logger.info("Remove_nodes "+str(config.serviceNodes))
    # new nodes
    if packBackend:
      # NOTE: Code update is done after starting the backend
      #       because tomcat-create-instance complains if its
      #       directory exists when it is run and placing the
      #       code can only be done after creating the instance
      self._start_backend(config, [packingNode])
      self._update_code(config, [packingNode])
    if packWeb: self._start_web(config, [packingNode])
    
    if webNodesKill or backendNodesKill:
      self._update_proxy(config, [ i for i in config.serviceNodes.values() if i.isRunningProxy and i not in proxyNodesKill ])
    
    try:
        # remove_nodes nodes
        self._stop_backend(config, backendNodesKill)
        self._stop_web(config, webNodesKill)
        self._stop_proxy(config, proxyNodesKill)
    
 #   self.logger.info("Internal php: service nodes "+str(config.serviceNodes.values()))
        for i in config.serviceNodes.values():
          if not i.isRunningBackend and not i.isRunningWeb and not i.isRunningProxy:
            del config.serviceNodes[i.id]
            self.controller.delete_nodes([i])
    #    self.logger.info("Internal php: Removing_node "+str(i.id))   

    
        config.proxy_count = len(config.getProxyServiceNodes())
        config.backend_count = len(config.getBackendServiceNodes())
        if config.backend_count == 1 and config.getBackendServiceNodes()[0] in config.getProxyServiceNodes():
            config.backend_count = 0
        config.web_count = len(config.getWebServiceNodes())
        if config.web_count == 1 and config.getWebServiceNodes()[0] in config.getProxyServiceNodes():
            config.web_count = 0
      
        #  config.update_mappings()
        self.logger.info("Remove_nodes "+str(config.serviceNodes))
    
    except Exception:
       self.logger.critical('Error when trying to remove ')    
    
    self._state_set(self.S_RUNNING)
    self._configuration_set(config)