def _attach(self, tenant_id, network_id, port_id, interface_id):
        LOG.debug("_attach(): called")
        ofn_tenant_id = self._get_ofn_tenant_id(tenant_id)
        ofn_network_id = self._get_ofn_network_id(network_id)
        vifinfo = ndb.get_vifinfo(interface_id)

        if self.conf.auto_id_port:
            """id include response."""
            res = self.ofn.ofn_create_port(ofn_tenant_id,
                                           ofn_network_id,
                                           vifinfo.datapath_id,
                                           str(vifinfo.port_no),
                                           str(vifinfo.vlan_id))
            ofn_port_id = res['id']
        else:
            """use uuid for ofn_network."""
            ofn_port_id = port_id
            res = self.ofn.ofn_create_port(ofn_tenant_id,
                                           ofn_network_id,
                                           vifinfo.datapath_id,
                                           str(vifinfo.port_no),
                                           str(vifinfo.vlan_id),
                                           ofn_port_id)
        LOG.debug("_attach(): ofn_create_port() return '%s'" % res)
        LOG.debug("_attach(): ofn_port_id = %s" % ofn_port_id)
        ndb.add_ofn_port(ofn_port_id, port_id)
 def test_del_ofn_port(self):
     port_id = "port_del"
     ofn_port_id = "ofn_port_del"
     ret = ndb.add_ofn_port(ofn_port_id, port_id)
     ret = ndb.get_ofn_port(port_id)
     self.assertTrue(ret.port_id == port_id)
     self.assertTrue(ret.ofn_port_id == ofn_port_id)
     ndb.del_ofn_port(port_id)
     ret = ndb.get_ofn_port(port_id)
     self.assertTrue(ret == None)