Beispiel #1
0
    def update_subnet_cidr(self, old_stack, new_stack):
        """
        Updates the subnet IP addresses. If the new stack contains subnets from the old stack it will take those
        IP addresses. Otherwise it will create new IP addresses for the subnet.

        :param old_stack: The currently running stack
        :type old_stack: :class:`heat.resources.stack`
        :param new_stack: The new created stack
        :type new_stack: :class:`heat.resources.stack`
        """
        for old_subnet in old_stack.nets.values():
            IP.free_cidr(old_subnet.get_cidr(), old_subnet.subnet_id)

        for subnet in new_stack.nets.values():
            subnet.clear_cidr()
            for old_subnet in old_stack.nets.values():
                if subnet.subnet_name == old_subnet.subnet_name:
                    if IP.assign_cidr(old_subnet.get_cidr(), subnet.subnet_id):
                        subnet.set_cidr(old_subnet.get_cidr())

        for subnet in new_stack.nets.values():
            if IP.is_cidr_issued(subnet.get_cidr()):
                continue

            cird = IP.get_new_cidr(subnet.subnet_id)
            subnet.set_cidr(cird)
        return
Beispiel #2
0
    def update_subnet_cidr(self, old_stack, new_stack):
        """
        Updates the subnet IP addresses. If the new stack contains subnets from the old stack it will take those
        IP addresses. Otherwise it will create new IP addresses for the subnet.

        :param old_stack: The currently running stack
        :type old_stack: :class:`heat.resources.stack`
        :param new_stack: The new created stack
        :type new_stack: :class:`heat.resources.stack`
        """
        for old_subnet in old_stack.nets.values():
            IP.free_cidr(old_subnet.get_cidr(), old_subnet.subnet_id)

        for subnet in new_stack.nets.values():
            subnet.clear_cidr()
            for old_subnet in old_stack.nets.values():
                if subnet.subnet_name == old_subnet.subnet_name:
                    if IP.assign_cidr(old_subnet.get_cidr(), subnet.subnet_id):
                        subnet.set_cidr(old_subnet.get_cidr())

        for subnet in new_stack.nets.values():
            if IP.is_cidr_issued(subnet.get_cidr()):
                continue

            cird = IP.get_new_cidr(subnet.subnet_id)
            subnet.set_cidr(cird)
        return