Skip to content

Commit

Permalink
Merge pull request #3384 from opsmill/pog-reconcile-after-pool-assign…
Browse files Browse the repository at this point in the history
…ment

Run IPAM reconcilement after assignment from pool
  • Loading branch information
ogenstad authored May 21, 2024
2 parents 5493efe + d0d2a8f commit 23198a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import TYPE_CHECKING, Any, Optional

from infrahub.core import registry
from infrahub.core.ipam.reconciler import IpamReconciler
from infrahub.core.query.ipam import get_ip_addresses
from infrahub.core.query.resource_manager import (
IPAddressPoolGetReserved,
Expand Down Expand Up @@ -65,6 +66,8 @@ async def get_resource(
node = await Node.init(db=db, schema=target_schema, branch=branch)
await node.new(db=db, address=str(next_prefix), ip_namespace=ip_namespace, **data)
await node.save(db=db)
reconciler = IpamReconciler(db=db, branch=branch)
await reconciler.reconcile(ip_value=next_prefix, namespace=ip_namespace.id, node_uuid=node.get_id())

if identifier:
query_set = await IPAddressPoolSetReserved.init(
Expand Down
3 changes: 3 additions & 0 deletions backend/infrahub/core/node/resource_manager/ip_prefix_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import TYPE_CHECKING, Any, Optional

from infrahub.core import registry
from infrahub.core.ipam.reconciler import IpamReconciler
from infrahub.core.query.ipam import get_subnets
from infrahub.core.query.resource_manager import (
PrefixPoolGetReserved,
Expand Down Expand Up @@ -69,6 +70,8 @@ async def get_resource(
node = await Node.init(db=db, schema=target_schema, branch=branch)
await node.new(db=db, prefix=str(next_prefix), member_type=member_type, ip_namespace=ip_namespace, **data)
await node.save(db=db)
reconciler = IpamReconciler(db=db, branch=branch)
await reconciler.reconcile(ip_value=next_prefix, namespace=ip_namespace.id, node_uuid=node.get_id())

if identifier:
query_set = await PrefixPoolSetReserved.init(
Expand Down

0 comments on commit 23198a1

Please sign in to comment.