def update_network(self, context, id, network):
        self._check_provider_update(context, network["network"])
        segmentation_id = network["network"]["segmentation_id"]
        LOG.debug("update_network: segmentation id = %s", segmentation_id)
        session = context.session
        with session.begin(subtransactions=True):
            binding = rgos_vlanmgr.get_network_binding(session, id)
            if binding.network_type == constants.TYPE_VLAN:
                rgos_vlanmgr.release_vlan(
                    session, binding.physical_network, binding.segmentation_id, self.network_vlan_ranges
                )
                rgos_vlanmgr.reserve_specific_vlan(session, binding.physical_network, segmentation_id)
                session.delete(binding)
                session.flush()
                rgos_vlanmgr.add_network_binding(
                    session, id, binding.network_type, binding.physical_network, segmentation_id
                )

        session = context.session
        with session.begin(subtransactions=True):
            net = super(RgosQuantumPlugin, self).update_network(context, id, network)
            self._process_l3_update(context, network["network"], id)
            self._extend_network_dict_provider(context, net)
            self._extend_network_dict_l3(context, net)
        return net
    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) = rgos_vlanmgr.reserve_vlan(session)

                # no reservation needed for TYPE_LOCAL
            else:
                # provider network
                if network_type == constants.TYPE_VLAN:
                    rgos_vlanmgr.reserve_specific_vlan(session, physical_network, segmentation_id)

                # no reservation needed for TYPE_LOCAL
            net = super(RgosQuantumPlugin, self).create_network(context, network)
            rgos_vlanmgr.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