ConfD User Community

When statement is not working

Hi ,i have added this when statement but this statment is not making any sense could any one help here please??
to configure vrf services should be in shutdown
leaf vrf {
description
“Voice VRF”;
when "/ios:native/voice/service[type=‘voip’]/shutdown"
tailf:cli-full-command;
tailf:cli-diff-create-after “/ios:native/ios:ip/ios:vrf”;
tailf:cli-diff-delete-before “/ios:native/ios:ip/ios:vrf”;
tailf:cli-diff-create-after “/ios:native/ios:vrf/ios:definition”;
tailf:cli-diff-delete-before “/ios:native/ios:vrf/ios:definition”;
must “/ios:native/ios:vrf/ios:definition[ios:name=current()] or /ios:native/ios:ip/ios:vrf[ios:name=current()]” {
error-message “VRF must be created 1st, deleted last”;
}

below are confd results the when condition is not getting invoke

voice service voip
no shutdown
no cpa
no supplementary-service sip handle-replaces
no supplementary-service sip moved-temporarily
no supplementary-service sip refer
sip
!
!
bgl-ads-3590# config t
Entering configuration mode terminal
bgl-ads-3590(config)# voice ?
Possible completions:
cause-code class error-passthru header-passing iec register service translation-profile translation-rule uc vrf
bgl-ads-3590(config)# voice vrf ?
Possible completions:
<string, min: 1 chars, max: 32 chars>[vrf12]
bgl-ads-3590(config)# voice vrf vrf10
bgl-ads-3590(config)# commit
Commit complete.

You did not include the YANG for the shutdown leaf, so I am speculating that it looks something like this:

  leaf shutdown {
    tailf:cli-full-command;
    tailf:cli-boolean-no;
    type boolean;
    default false;
  }

Such a leaf will not be deleted as it has a default value. You need to check if the leaf is set to “true” with your when statement XPath expression. Example:

when "/ios:native/voice/service[type=‘voip’]/shutdown = 'true'"

i have used this statement but if we use this the vrf node wont be visible if we do no shutdown as shown below

bgl-ads-3590(config)# voice service voip     
bgl-ads-3590(conf-voi-serv)# no shutdown** 
bgl-ads-3590(conf-voi-serv)# show configuration diff
 voice service voip
- shutdown
+ no shutdown
 !
bgl-ads-3590(conf-voi-serv)# commit
Commit complete.
bgl-ads-3590(conf-voi-serv)# exit                   
bgl-ads-3590(config)# voice ?                
Possible completions:
   cause-code  class  error-passthru  header-passing  iec  register  service  translation-profile  translation-rule  uc
bgl-ads-3590(config)# voice 

but my requirment is node should be visible but when we try to commit it should show below error

"Cannot configure/unconfigure the CLI when VoIP services are running or when active VoIP calls are present"

please help me with this??

See Mastering Markdown · GitHub Guides on how to format your text. Especially note the guide on Quoting code.

Then perhaps you need a must statement, not a when statement.

    must "/ios:native/voice/service[type=‘voip’]/shutdown = 'true'" {
      error-message "Cannot configure/unconfigure the CLI when VoIP"
                    + " services are running or when active VoIP calls are"
                    + " present";
    }

…although your error message text suggests that you are validating the state change, not the data. If so, must or when statements will not help. You will need a tailf:validate statement and callback application code for that.

Hi conny!
As you suggested to go through this tailf:validate
i have gone through can you please confirm is it correct to add tailf:validate as below??
leaf vrf {
description
“Voice VRF”;

when "/ios:native/voice/service[type='voip']/shutdown = 'true'"{
       tailf:dependency "/ios:native/voice/service[type='voip']/shutdown";
    }
    tailf:cli-full-command;
    tailf:cli-diff-create-after "/ios:native/ios:ip/ios:vrf";
    tailf:cli-diff-delete-before "/ios:native/ios:ip/ios:vrf";
    tailf:cli-diff-create-after "/ios:native/ios:vrf/ios:definition";
    tailf:cli-diff-delete-before "/ios:native/ios:vrf/ios:definition";
    must "/ios:native/ios:vrf/ios:definition[ios:name=current()] or /ios:native/ios:ip/ios:vrf[ios:name=current()]" {
      error-message "VRF must be created 1st, deleted last";
    }
    type string {
      length "1..32";
    }
tailf:validate vp1{
tailf:dependency "/ios:native/voice/service[type=‘voip’]/shutdown";
}

in annotation like voice-ann.yang file do i need to add like below

tailf:annotate "/ios:native/ios-voice:voice/ios-voice:vrf" {
tailf:validate vp1;
tailf:dependency '.';
}

Hi conny,

I have changed yang model as below

container voice {
description
"Global voice configuration";
tailf:cli-incomplete-no;
leaf vrf {
description
"Voice VRF";
tailf:cli-full-command;
tailf:cli-diff-create-after "/ios:native/ios:ip/ios:vrf";
tailf:cli-diff-delete-before "/ios:native/ios:ip/ios:vrf";
tailf:cli-diff-create-after "/ios:native/ios:vrf/ios:definition";
tailf:cli-diff-delete-before "/ios:native/ios:vrf/ios:definition";
must "/ios:native/ios:vrf/ios:definition[ios:name=current()] or /ios:native/ios:ip/ios:vrf[ios:name=current()]" {
error-message "VRF must be created 1st, deleted last";
}
> must "(/ios:native/voice/service[type='voip']/shutdown= 'true') and (/ios:native/voice/service[type='voip']/sip/call/service/stop)"{
> error-message "Cannot configure/unconfigure the CLI when VoIP services are running or when active VoIP calls are present";
> }
> tailf:cli-diff-dependency "/ios:native/voice/service[type='voip']/shutdown";
> tailf:cli-diff-dependency "/ios:native/voice/service[type='voip']/sip/call/service/stop";

type string {
length "1..32";
}
}

issue is when i try to do no call service stop after configuring voice vrf i am facing below error

rr4-utah_RP_0(config)# voice service voip
rr4-utah_RP_0(conf-voi-serv)#
rr4-utah_RP_0(conf-voi-serv)# no shutdown
rr4-utah_RP_0(conf-voi-serv)# show configuration diff
rr4-utah_RP_0(conf-voi-serv)# commit
Commit complete.
rr4-utah_RP_0(conf-voi-serv)# sip
rr4-utah_RP_0(conf-serv-sip)# no call service stop
> rr4-utah_RP_0(conf-serv-sip)# commit
> Aborted: 'voice vrf' (value "vrf1"): Cannot configure/unconfigure the CLI when VoIP services are running or when active VoIP calls are present

Please help me with this??

Can you share the YANG implementation of the “stop” and “shutdown” nodes? Is this it?