Below Yang module is designed for operational data.
container files {
config false;
list file {
key file-number;
leaf file-number {
description "Number of the file";
type uint32;
}
container file-information {
description "Information about the file";
leaf file-state {
description "State of the file";
type base:file-state-read;
}
leaf filling-time {
description "The filling timestamp showing when the file is opened";
type yang:date-and-time;
}
leaf transfer-time {
description "the transfer date and time"
type yang:date-and-time;
}
leaf is-stored-file {
description "Set if the file is stored on disk.";
type empty;
}
leaf is-compressed-file {
description "Set if the file is compressed.";
type empty;
}
leaf file-warning {
description "Mutually exclusive warnings set for file
type enumeration {
enum skipped
enum overwritten
}
}
}
}
}
We would like to use confd_cli command “show files file xxx file-information file-state” to display the file xxx’s status. The file list has a maximum of 65535 elements and find_next() is design to traverse the list. However, it takes much time to traverse all the elements in the list. (Note: the files are always on a fixed position like this: the file-number=1 is on the position 0; the file-number=2 is on the position 1; the file-number=N is on the position N-1)
int find_next_nested (struct confd_trans_ctx* tctx,
confd_hkeypath_t* keypath,
enum confd_find_next_type /*type*/,
confd_value_t* keys,
int nkeys)
{
confd_value_t v;
int pos = -1;
std::vector<FileInfo> current_file_info = findFileInfoList(keypath->v[2][0]);
switch (nkeys) {
case 0:
selected_fileInfo.file_number = UINT_MAX;
if (current_file_info.size() > 0)
pos = 0;
else
pos = -1;
break;
case 1:
pos = CONFD_GET_UINT32(&keys[0]);
if (static_cast<int>(current_file_info.size())<=pos)
pos = -1;
break;
default:
confd_trans_seterr(tctx, "invalid number of keys: %d", nkeys);
return CONFD_ERR;
}
if (pos >= 0) {
CONFD_SET_UINT32(&v, current_file_info[pos].file_number);
confd_data_reply_next_key(tctx, &v, 1, (long)(pos + 1));
} else {
confd_data_reply_next_key(tctx, NULL, -1, -1);
}
return CONFD_OK;
}
I tried to change find_next() to make a “jump” in a list traversal, it seems the result doesn’t satisfy our needs.
xxx@netconf-server- 02:52:56> show files file 1
Possible completions:
100 - Number (running counter) of the file
1000 - Number (running counter) of the file
1100 - Number (running counter) of the file
1200 - Number (running counter) of the file
1300 - Number (running counter) of the file
1400 - Number (running counter) of the file
1500 - Number (running counter) of the file
1600 - Number (running counter) of the file
1700 - Number (running counter) of the file
1800 - Number (running counter) of the file
Could you please give some suggestion how to change find_next() to show any file’s status quickly? Or could I use “tailf:display-when” to forbidden the input of " file-information file-state" in confd-cli? We are using ConfD 6.2.