Exemple #1
0
    def create_pool(self, session, pool_start, pool_end):
        """Create an allocation pool and availability ranges for the subnet.

        This method does not perform any validation on parameters; it simply
        persist data on the database.

        :param pool_start: string expressing the start of the pool
        :param pool_end: string expressing the end of the pool
        :return: the newly created pool object.
        """
        ip_pool = db_models.IpamAllocationPool(
            ipam_subnet_id=self._ipam_subnet_id,
            first_ip=pool_start,
            last_ip=pool_end)
        session.add(ip_pool)
        ip_range = db_models.IpamAvailabilityRange(allocation_pool=ip_pool,
                                                   first_ip=pool_start,
                                                   last_ip=pool_end)
        session.add(ip_range)
        return ip_pool
Exemple #2
0
    def create_range(self, session, allocation_pool_id, range_start,
                     range_end):
        """Create an availability range for a given pool.

        This method does not perform any validation on parameters; it simply
        persist data on the database.

        :param session: database session
        :param allocation_pool_id: allocation pool identifier
        :param range_start: first ip address in the range
        :param range_end: last ip address in the range
        :return: the newly created availability range as an instance of
            neutron.ipam.drivers.neutrondb_ipam.db_models.IpamAvailabilityRange
        """
        new_ip_range = db_models.IpamAvailabilityRange(
            allocation_pool_id=allocation_pool_id,
            first_ip=range_start,
            last_ip=range_end)
        session.add(new_ip_range)
        return new_ip_range