def obtain_port_correspondence(self):
        '''Obtain the correspondence between physical and openflow port names
        return:
             0, dictionary: with physical name as key, openflow name as value
            -1, error_text: 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("obtain_port_correspondence " + error_text)
                return -1 , error_text
            self.logger.debug("obtain_port_correspondence " + error_text)
            info = of_response.json()
            
            if type(info) != dict:
                self.logger.error("obtain_port_correspondence. Unexpected response not a dict: %s", str(info))
                return -1, "Unexpected openflow response, not a dict. Wrong version?"

            nodes = info.get('nodes')
            if type(nodes) is not dict:
                self.logger.error("obtain_port_correspondence. Unexpected response at 'nodes', not found or not a dict: %s", str(type(nodes)))
                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("obtain_port_correspondence. 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?"

            for node in node_list:
                node_id = node.get('id')
                if node_id is None:
                    self.logger.error("obtain_port_correspondence. 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

                # Figure out if this is the appropriate switch. The 'id' is 'openflow:' plus the decimal value
                # of the dpid
                #  In case this is not the desired switch, continue
                if self.id != node_id:
                    continue

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

                for node_connector in node_connector_list:
                    self.pp2ofi[ str(node_connector['flow-node-inventory:name']) ] = str(node_connector['id'] )
                    self.ofi2pp[ node_connector['id'] ] =  str(node_connector['flow-node-inventory:name'])


                node_ip_address = node.get('flow-node-inventory:ip-address')
                if node_ip_address is None:
                    self.logger.error("obtain_port_correspondence. 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?"
                self.ip_address = node_ip_address

                #If we found the appropriate dpid no need to continue in the for loop
                break

            #print self.name, ": obtain_port_correspondence ports:", self.pp2ofi
            return 0, self.pp2ofi
        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("obtain_port_correspondence " + error_text)
            return -1, error_text
dataset/ETHPy150Open nfvlabs/openmano/openvim/ODL.py/OF_conn.obtain_port_correspondence