def add_switch(self, queue, ip, snmp_community):
        status, resp = self._client.add_switch(ip,
                                               version="2c",
                                               community=snmp_community)
        if status > 409:
            queue.put((ip, (False,
                            "Failed to add the switch (status=%d)" % status)))
            return

        if status == 409:
            # This is the case where the switch with the same IP already
            # exists in the system. We now try to update the switch
            # with the given credential.
            switch_id = resp['failedSwitch']
            status, resp = self._client.update_switch(switch_id,
                                                      version="2c",
                                                      community=snmp_community)
            if status > 202:
                queue.put((ip, (False,
                                "Failed to update the switch (status=%d)" %
                                status)))
                return

        switch = resp['switch']
        state = switch['state']
        switch_id = switch['id']

        # if the switch state is not in under_monitoring,
        # wait for the poll switch task
        while True:
            status, resp = self._client.get_switch(switch_id)
            if status > 400:
                queue.put((ip, (False, "Failed to get switch status")))
                return

            switch = resp['switch']

            state = switch['state']
            if state == 'initialized' or state == 'repolling':
                time.sleep(5)
            else:
                break

        if state == 'under_monitoring':
            # get machines connected to the switch.
            status, response = self._client.get_machines(switch_id=switch_id)
            if status == 200:
                for machine in response['machines']:
                    queue.put((ip, "mac=%s, vlan=%s, port=%s dbid=%d" % (
                        machine['mac'],
                        machine['vlan'],
                        machine['port'],
                        machine['id'])))
            else:
                queue.put((ip, (False,
                                "Failed to get machines %s" %
                                response['status'])))
        else:
            queue.put((ip, (False, "Switch state is %s" % state)))
:rtype: `DependNode`
dataset/ETHPy150Open openstack/compass-core/bin/query_switch.py/AddSwitch.add_switch--crossover with--dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.3/pymel/core/nodetypes.py/DependNode.rename