def create_network(self, context, network):
        (network_type, physical_network,
         segmentation_id) = self._process_provider_create(context,
                                                          network['network'])

        session = context.session
        with session.begin(subtransactions=True):
            if not network_type:
                try:
                    (physical_network,
                     segmentation_id) = ovs_db_v2.reserve_vlan(session)
                    network_type = constants.TYPE_VLAN
                except q_exc.NoNetworkAvailable:
                    segmentation_id = ovs_db_v2.reserve_tunnel(session)
                    network_type = constants.TYPE_GRE
            else:
                ovs_db_v2.reserve_specific_vlan(session, physical_network,
                                                segmentation_id)
            net = super(OVSQuantumPluginV2, self).create_network(context,
                                                                 network)
            ovs_db_v2.add_network_binding(session, net['id'], network_type,
                                          physical_network, segmentation_id)

            self._process_l3_create(context, network['network'], net['id'])
            self._extend_network_dict_provider(context, net)
            self._extend_network_dict_l3(context, net)
            # note - exception will rollback entire transaction
        LOG.debug("Created network: %s" % net['id'])
        return net
Пример #2
0
    def create_network(self, context, network):
        (network_type, physical_network, segmentation_id) = self._process_provider_create(context, network["network"])

        session = context.session
        with session.begin(subtransactions=True):
            if not network_type:
                # tenant network
                network_type = self.tenant_network_type
                if network_type == constants.TYPE_NONE:
                    raise q_exc.TenantNetworksDisabled()
                elif network_type == constants.TYPE_VLAN:
                    (physical_network, segmentation_id) = ovs_db_v2.reserve_vlan(session)
                elif network_type == constants.TYPE_GRE:
                    segmentation_id = ovs_db_v2.reserve_tunnel(session)
                # no reservation needed for TYPE_LOCAL
            else:
                # provider network
                if network_type in [constants.TYPE_VLAN, constants.TYPE_FLAT]:
                    ovs_db_v2.reserve_specific_vlan(session, physical_network, segmentation_id)
                elif network_type == constants.TYPE_GRE:
                    ovs_db_v2.reserve_specific_tunnel(session, segmentation_id)
                # no reservation needed for TYPE_LOCAL
            net = super(OVSQuantumPluginV2, self).create_network(context, network)
            ovs_db_v2.add_network_binding(session, net["id"], network_type, physical_network, segmentation_id)

            self._process_l3_create(context, network["network"], net["id"])
            self._extend_network_dict_provider(context, net)
            self._extend_network_dict_l3(context, net)
            # note - exception will rollback entire transaction
        LOG.debug(_("Created network: %s"), net["id"])
        return net
Пример #3
0
    def create_network(self, context, network):
        (network_type, physical_network,
         segmentation_id) = self._process_provider_create(
             context, network['network'])

        session = context.session
        with session.begin(subtransactions=True):
            if not network_type:
                try:
                    (physical_network,
                     segmentation_id) = ovs_db_v2.reserve_vlan(session)
                    network_type = constants.TYPE_VLAN
                except q_exc.NoNetworkAvailable:
                    segmentation_id = ovs_db_v2.reserve_tunnel(session)
                    network_type = constants.TYPE_GRE
            else:
                ovs_db_v2.reserve_specific_vlan(session, physical_network,
                                                segmentation_id)
            net = super(OVSQuantumPluginV2,
                        self).create_network(context, network)
            ovs_db_v2.add_network_binding(session, net['id'], network_type,
                                          physical_network, segmentation_id)

            self._process_l3_create(context, network['network'], net['id'])
            self._extend_network_dict_provider(context, net)
            self._extend_network_dict_l3(context, net)
            # note - exception will rollback entire transaction
        LOG.debug("Created network: %s" % net['id'])
        return net
Пример #4
0
    def test_tunnel_pool(self):
        tunnel_ids = set()
        for x in xrange(TUN_MIN, TUN_MAX + 1):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
            self.assertGreaterEqual(tunnel_id, TUN_MIN)
            self.assertLessEqual(tunnel_id, TUN_MAX)
            tunnel_ids.add(tunnel_id)

        with self.assertRaises(q_exc.NoNetworkAvailable):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)

        ovs_db_v2.release_tunnel(self.session, tunnel_ids.pop(), TUNNEL_RANGES)
        tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
        self.assertGreaterEqual(tunnel_id, TUN_MIN)
        self.assertLessEqual(tunnel_id, TUN_MAX)
        tunnel_ids.add(tunnel_id)

        for tunnel_id in tunnel_ids:
            ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)
Пример #5
0
    def test_tunnel_pool(self):
        tunnel_ids = set()
        for x in xrange(TUN_MIN, TUN_MAX + 1):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
            self.assertThat(tunnel_id, matchers.GreaterThan(TUN_MIN - 1))
            self.assertThat(tunnel_id, matchers.LessThan(TUN_MAX + 1))
            tunnel_ids.add(tunnel_id)

        with testtools.ExpectedException(q_exc.NoNetworkAvailable):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)

        ovs_db_v2.release_tunnel(self.session, tunnel_ids.pop(), TUNNEL_RANGES)
        tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
        self.assertThat(tunnel_id, matchers.GreaterThan(TUN_MIN - 1))
        self.assertThat(tunnel_id, matchers.LessThan(TUN_MAX + 1))
        tunnel_ids.add(tunnel_id)

        for tunnel_id in tunnel_ids:
            ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)
Пример #6
0
    def test_tunnel_pool(self):
        tunnel_ids = set()
        for x in xrange(TUN_MIN, TUN_MAX + 1):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
            self.assertGreaterEqual(tunnel_id, TUN_MIN)
            self.assertLessEqual(tunnel_id, TUN_MAX)
            tunnel_ids.add(tunnel_id)

        with self.assertRaises(q_exc.NoNetworkAvailable):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)

        ovs_db_v2.release_tunnel(self.session, tunnel_ids.pop(), TUNNEL_RANGES)
        tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
        self.assertGreaterEqual(tunnel_id, TUN_MIN)
        self.assertLessEqual(tunnel_id, TUN_MAX)
        tunnel_ids.add(tunnel_id)

        for tunnel_id in tunnel_ids:
            ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)
Пример #7
0
    def test_tunnel_pool(self):
        tunnel_ids = set()
        for x in xrange(TUN_MIN, TUN_MAX + 1):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
            self.assertThat(tunnel_id, matchers.GreaterThan(TUN_MIN - 1))
            self.assertThat(tunnel_id, matchers.LessThan(TUN_MAX + 1))
            tunnel_ids.add(tunnel_id)

        with testtools.ExpectedException(q_exc.NoNetworkAvailable):
            tunnel_id = ovs_db_v2.reserve_tunnel(self.session)

        ovs_db_v2.release_tunnel(self.session, tunnel_ids.pop(), TUNNEL_RANGES)
        tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
        self.assertThat(tunnel_id, matchers.GreaterThan(TUN_MIN - 1))
        self.assertThat(tunnel_id, matchers.LessThan(TUN_MAX + 1))
        tunnel_ids.add(tunnel_id)

        for tunnel_id in tunnel_ids:
            ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)
Пример #8
0
    def create_network(self, context, network):
        (network_type, physical_network,
         segmentation_id) = self._process_provider_create(context,
                                                          network['network'])

        session = context.session
        #set up default security groups
        tenant_id = self._get_tenant_id_for_create(
            context, network['network'])
        self._ensure_default_security_group(context, tenant_id)

        with session.begin(subtransactions=True):
            if not network_type:
                # tenant network
                network_type = self.tenant_network_type
                if network_type == constants.TYPE_NONE:
                    raise q_exc.TenantNetworksDisabled()
                elif network_type == constants.TYPE_VLAN:
                    (physical_network,
                     segmentation_id) = ovs_db_v2.reserve_vlan(session)
                elif network_type == constants.TYPE_GRE:
                    segmentation_id = ovs_db_v2.reserve_tunnel(session)
                # no reservation needed for TYPE_LOCAL
            else:
                # provider network
                if network_type in [constants.TYPE_VLAN, constants.TYPE_FLAT]:
                    ovs_db_v2.reserve_specific_vlan(session, physical_network,
                                                    segmentation_id)
                elif network_type == constants.TYPE_GRE:
                    ovs_db_v2.reserve_specific_tunnel(session, segmentation_id)
                # no reservation needed for TYPE_LOCAL
            net = super(OVSQuantumPluginV2, self).create_network(context,
                                                                 network)
            ovs_db_v2.add_network_binding(session, net['id'], network_type,
                                          physical_network, segmentation_id)

            self._process_l3_create(context, network['network'], net['id'])
            self._extend_network_dict_provider(context, net)
            self._extend_network_dict_l3(context, net)
            # note - exception will rollback entire transaction
        LOG.debug(_("Created network: %s"), net['id'])
        return net