cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
265
Views
0
Helpful
7
Replies

tailf:cli-preformatted issue

atriyant
Cisco Employee
Cisco Employee

In the NCS man-pages it states:
--------------

tailf:cli-preformatted

Suppresses quoting of non-config elements when displaying them. Newlines will be preserved in strings etc.

Used in J-, I- and C-style CLIs.

The cli-preformatted statement can be used in: leaf, tailf:symlink, and refine.
--------------

but when I use it in a leaf like below:
leaf day0 {
  tailf:cli-preformatted;
  type string;
}

when entering data into the leaf it always interprets the "\n" into new line instead of preserve it as a text.
anybody ever have this issue?


7 Replies 7

cohult
Cisco Employee
Cisco Employee

Hi,
Using the tailf:cli-preformatted extension means that the "\n" will be interpreted as a new line instead of preserving it as text.
Let's say I configure the day0 leaf with: 
hello\nworld

Without the tailf:cli-preformatted extension:

# show running-config day0
day0 "hello\nworld"

With the tailf:cli-preformatted extension:

# show running-config day0
day0 hello
     world

atriyant
Cisco Employee
Cisco Employee

Thanks @cohult 
my req is:

EXPECTED
day0 configure terminal
         banner exec sequence 1 "####################\r\n*"
         banner exec sequence 2 "#" "#\r\n*"

ACTUAL
day0 configure terminal
         banner exec sequence 1 "####################\r
         *"
         banner exec sequence 2 "#" "#\r
         *"

is there a way to format it as in EXPECTED?

thanks,
adi

Please clarify what your configuration is and what is expected to be shown.
Although it seems like you are looking for the tailf:cli-multi-value YANG extension

Please find attached the text file which has the content that I want to store in the leaf as it is.

tohagber
Cisco Employee
Cisco Employee
 container banner {
   container exec {
     list sequence {
       tailf:cli-suppress-mode;
       key id;
       leaf id {
         type uint32;
       }
       leaf banner {
         tailf:cli-drop-node-name;
         type string;
       }
     }
   }
 }

I get pretty much what you expect:

TOHAGBER-M-V4W1(config)# no banner 
TOHAGBER-M-V4W1(config)# banner exec sequence 1 "####################\r\n*"        
TOHAGBER-M-V4W1(config)# top
TOHAGBER-M-V4W1(config)# banner exec sequence 2 "\#'        '#\r\n*"       
TOHAGBER-M-V4W1(config)# commit 
TOHAGBER-M-V4W1(config)# do show running-config banner 
banner exec sequence 1 "####################\r\n*"
banner exec sequence 2 "\#'               '#\r\n*"

Note through if you are going to use double quotes inside a string you either need to escape them with \" or you can maybe use singe quote as per above?

 

 

 

atriyant
Cisco Employee
Cisco Employee

thanks for your suggestions cohult and tohagber, but both 'tailf:cli-multi-value' and 'tailf:drop-node-name' don't work for me.
cli-multi-value makes all text to be in one line.
the above drop-node-name need parent and drop the leaf name. I need one leaf like in my EXPECTED above.

The intention with drop-node-name is not to give any instruction to the leafs output value when rendered on show command, it just means that the name of the leaf is not showed in C-style cli. My point was mainly if you just have a leaf with simple string type it will render the value as you want AFAIKT. The only thing that does not match what you stated earlier is the double quote inside the value. As i said, if you want a double quote inside an double quoted string, the only way to render that is if it is escaped with \"