def get_netscaler_removeboundservices_tasks(self, loadBalancerId, loadBalancer):

       """I need first to get the list of service names"""

       task_list = []

       task = self.get_netscaler_getservicebindings_task(loadBalancerId, loadBalancer) 
       task_list.append(task)  

       completed_tasks = self.nitrowrapper.process_netscaler_task_list(task_list)

       servicebindings = NitroTasks.extract_servicebindings_from_task_list(completed_tasks)

       if not servicebindings:
           return task_list

       """ We form a new task list to remove the service bindings and the services """

       nodeIds = []

       for binding in servicebindings:
           servicename = self._get_netscaler_servicename_from_servicebinding(loadBalancerId, loadBalancer, binding) 
           nodeId = NitroUtils.get_nodeid_from_servicename(loadBalancerId, servicename)
           nodeIds.append(nodeId)

 
       task_list = []

       tasks = self._get_netscaler_removeservicebindings_tasks(loadBalancerId, loadBalancer, nodeIds)
       task_list.extend(tasks)

       tasks = self._get_netscaler_removeservices_tasks(loadBalancerId, loadBalancer, nodeIds)
       task_list.extend(tasks)
 
       return task_list
    def _get_netscaler_node_from_service_and_servicebinding(self, loadBalancerId, loadBalancer, service, servicebinding):

        node = LBNodeState(self.lbresource)

        service_name = service["name"] 

        node.id = NitroUtils.get_nodeid_from_servicename(loadBalancerId, service_name)

        if "ipaddress" in service and service["ipaddress"]:
            ipaddress = service["ipaddress"]
            ipaddress = ipaddress.encode('ascii', 'ignore')
            node.address = ipaddress


        if "port" in service and service["port"]:
            port = service["port"]
            port = str(port)
            node.port = port 

                     
        if "svrstate" in service and service["svrstate"]:
            svrstate =  service["svrstate"]
            
            node.condition = NitroUtils.get_condition_from_svrstate(svrstate)
            node.status = NitroUtils.get_nodestatus_from_svrstate(svrstate)


        if "weight" in servicebinding and servicebinding["weight"]:
            weight = servicebinding["weight"]
            node.weight = str(weight)


        self.logger.debug("returned node is: %s" % node)

        return node
    def get_netscaler_getservices_tasks(self, loadBalancerId, loadBalancer, servicebindings):
                                                           
        task_list = []

        for binding in servicebindings:
            servicename = binding["servicename"]
            nodeId = NitroUtils.get_nodeid_from_servicename(loadBalancerId, servicename)
            task = self._get_netscaler_getservice_task(loadBalancerId, loadBalancer, nodeId)
            task_list.append(task)
                              
        return task_list