def get_of_switches(self):
        ''' Obtain a a list of switches or DPID detected by this controller
            Return
                >=0, list:      list length, and a list where each element a tuple pair (DPID, IP address)
                <0, text_error: if fails
        '''  
        try:
            of_response = requests.get(self.url+"/restconf/operational/opendaylight-inventory:nodes",
                                       headers=self.headers)
            error_text = "Openflow response %d: %s" % (of_response.status_code, of_response.text)
            if of_response.status_code != 200:
                self.logger.warning("get_of_switches " + error_text)
                return -1 , error_text
            self.logger.debug("get_of_switches " + error_text)
            info = of_response.json()
            
            if type(info) != dict:
                self.logger.error("get_of_switches. Unexpected response, not a dict: %s", str(info))
                return -1, "Unexpected response, not a dict. Wrong version?"

            nodes = info.get('nodes')
            if type(nodes) is not dict:
                self.logger.error("get_of_switches. Unexpected response at 'nodes', not found or not a dict: %s", str(type(info)))
                return -1, "Unexpected response at 'nodes', not found or not a dict. Wrong version?"

            node_list = nodes.get('node')
            if type(node_list) is not list:
                self.logger.error("get_of_switches. Unexpected response, at 'nodes':'node', not found or not a list: %s", str(type(node_list)))
                return -1, "Unexpected response, at 'nodes':'node', not found or not a list. Wrong version?"

            switch_list=[]
            for node in node_list:
                node_id = node.get('id')
                if node_id is None:
                    self.logger.error("get_of_switches. Unexpected response at 'nodes':'node'[]:'id', not found: %s", str(node))
                    return -1, "Unexpected response at 'nodes':'node'[]:'id', not found . Wrong version?"

                if node_id == 'controller-config':
                    continue

                node_ip_address = node.get('flow-node-inventory:ip-address')
                if node_ip_address is None:
                    self.logger.error("get_of_switches. Unexpected response at 'nodes':'node'[]:'flow-node-inventory:ip-address', not found: %s", str(node))
                    return -1, "Unexpected response at 'nodes':'node'[]:'flow-node-inventory:ip-address', not found. Wrong version?"

                node_id_hex=hex(int(node_id.split(':')[1])).split('x')[1].zfill(16)
                switch_list.append( (':'.join(a+b for a,b in zip(node_id_hex[::2], node_id_hex[1::2])), node_ip_address))

            return len(switch_list), switch_list
        except (requests.exceptions.RequestException, __HOLE__) as e:
            #ValueError in the case that JSON can not be decoded
            error_text = type(e).__name__ + ": " + str(e)
            self.logger.error("get_of_switches " + error_text)
            return -1, error_text
dataset/ETHPy150Open nfvlabs/openmano/openvim/ODL.py/OF_conn.get_of_switches