def test_add_ofn_network(self):
     network_id = "network_add"
     ofn_network_id = "ofn_network_add"
     ret = ndb.add_ofn_network(ofn_network_id, network_id)
     self.assertTrue(ret.network_id == network_id)
     self.assertTrue(ret.ofn_network_id == ofn_network_id)
     ret = ndb.get_ofn_network(network_id)
     self.assertTrue(ret.network_id == network_id)
     self.assertTrue(ret.ofn_network_id == ofn_network_id)
     ndb.del_ofn_network(network_id)
    def create_network(self, tenant_id, network_name):
        """
        Creates a new Virtual Network, and assigns it
        a symbolic name.
        """
        LOG.debug("create_network() called")
        ofn_tenant_id = self._create_ofn_tenant(tenant_id)
        new_network = db.network_create(tenant_id, network_name)

        if self.conf.auto_id_network:
            """Auto ID is ture. id include response."""
            res = self.ofn.ofn_create_network(ofn_tenant_id, network_name)
            ofn_network_id = res['id']
        else:
            """Auto ID is false. use uuid for ofn_network."""
            ofn_network_id = new_network.uuid
            res = self.ofn.ofn_create_network(ofn_tenant_id,
                                              network_name,
                                              ofn_network_id)

        LOG.debug("create_network(): ofn_create_network() return '%s'" % res)
        LOG.debug("create_network(): ofn_network_id = %s" % ofn_network_id)
        ndb.add_ofn_network(ofn_network_id, new_network.uuid)
        return {'net-id': new_network.uuid, 'net-name': new_network.name}