# What is the difference between Validation Points and CDB two-phase subscriptions from the refusing/accepting config point of view?

**URL:** https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415
**Category:** CDB and CDB API
**Created:** [March 12, 2016, 7:11am UTC](https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415 "2016-03-12T07:11:17Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![lynn](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@lynn](https://dmap-community.ductus.global/u/lynn)
#### Post date: [March 12, 2016, 7:11am UTC](https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415/1 "2016-03-12T07:11:17Z")

</div>

I think we could refuse the invalid configuration in the prepare phase in cdb subscriber, and also do this in validation callback. I don’t know why confd bring in validation callpoint, is there any benefit?

These folloing two differences I’ve known:

1. validation callpoint can accept config with warning, while cdb subscriber not.
2. validation callpoint must explicit writen in yang and implement callback functions which can only validate the certain scope, while cdb subscriber seems much easier to validate any config without any modification in yang.

Do I misunderstand the configuration validation?

---

<div class="post-metadata">

### Author: ![jjohansson](https://avatars.discourse-cdn.com/v4/letter/j/b782af/32.png) [@jjohansson](https://dmap-community.ductus.global/u/jjohansson)
#### Post date: [March 12, 2016, 12:11pm UTC](https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415/2 "2016-03-12T12:11:58Z")

</div>

If you do validation in the prepare phase you have already updated the data base with the new config and will have to undo everything if validation fails.

Also, to support the :validate NETCONF capability or the validate CLI command you must ru all validation, be it must statements or C validation callbacks in the validation phase.

---

<div class="post-metadata">

### Author: ![lynn](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@lynn](https://dmap-community.ductus.global/u/lynn)
#### Post date: [March 14, 2016, 2:50am UTC](https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415/3 "2016-03-14T02:50:32Z")

</div>

> [@jjohansson](#):
>
> If you do validation in the prepare phase you have already updated the data base with the new config and will have to undo everything if validation fails.

Yes, the prepare phase is after the write phase. If validation fails in prepare phase confd will undo everything, is that true?

The reason we have to validate the config in prepare phase is that, we don’t know whether the config is ok until we call the actually operation function, and check it’s return value.

---

<div class="post-metadata">

### Author: ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)
#### Post date: [March 14, 2016, 6:22am UTC](https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415/4 "2016-03-14T06:22:36Z")

</div>

Hi Lynn,

> [@lynn](#):
>
> If validation fails in prepare phase confd will undo everything, is that true?

Correct, nothing will be set if you abort the transaction in the prepare phase.  
As noted earlier above, the manager can abort the transaction in the prepare phase too, so if you do any changes in your system already at this phase outside of the scope of the transaction you must be able to undo them if you or the manager (initator of the transaction) decides to abort.

I highly recommend the ConfD example that show you a simple but very good implementation of an abort in the prepare phase:  
`examples.confd/cdb_subscription/twophase`

See also confd\_lib\_cdb man pages:  
`cdb_sub_abort_trans() and cdb_sub_abort_trans_info()`

---

<div class="post-metadata">

### Author: ![lynn](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@lynn](https://dmap-community.ductus.global/u/lynn)
#### Post date: [March 14, 2016, 8:57am UTC](https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415/5 "2016-03-14T08:57:36Z")

</div>

Hi cohult, thank you very much.

---

<div class="post-metadata">

### Author: ![lynn](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@lynn](https://dmap-community.ductus.global/u/lynn)
#### Post date: [March 14, 2016, 9:22am UTC](https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415/6 "2016-03-14T09:22:46Z")

</div>

If i’m planning to process all the config in prepare phase, is that safe?  
the following pseudo code supposes each transaction enter prepare phase must be enter the commit phase without calling cdb\_sub\_abort\_trans().

```auto
switch (type)
{
case CDB_SUB_PREPARE:
    task_ok = false;
    do {
        if(!do_task(cfg1)) break;
        if(!do_task(cfg2)) break;
        ...
        if(!do_task(cfgN))break;
        task_ok = true;
    }while(0);
    if(task_ok == true) 
    {
        cdb_sync_subscription_socket(ss, CDB_DONE_PRIORITY);
    }
    else
    {
        rollback_each_task_before_the_failed_one();
        cdb_sub_abort_trans();
    }
    break;
case CDB_SUB_COMMIT:
     cdb_sync_subscription_socket(ss, CDB_DONE_PRIORITY);
     break;
}

```

---

<div class="post-metadata">

### Author: ![waitai](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/waitai/32/436_2.png) [@waitai](https://dmap-community.ductus.global/u/waitai)
#### Post date: [March 14, 2016, 5:22pm UTC](https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415/7 "2016-03-14T17:22:26Z")

</div>

> [@lynn](#):
>
> If i’m planning to process all the config in prepare phase, is that safe?

Not knowing the details of your do\_task( ) implementation, your pseudo code looks fine to me.

---

<div class="post-metadata">

### Author: ![lynn](https://avatars.discourse-cdn.com/v4/letter/l/e274bd/32.png) [@lynn](https://dmap-community.ductus.global/u/lynn)
#### Post date: [March 15, 2016, 1:55am UTC](https://dmap-community.ductus.global/t/what-is-the-difference-between-validation-points-and-cdb-two-phase-subscriptions-from-the-refusing-accepting-config-point-of-view/415/8 "2016-03-15T01:55:47Z")

</div>

The do\_task() perform the actually action on some resources such as enables a router, dispatches acl rules to data plane, allocates ip address pool, creates interfaces and so on.
