Skip to content

Commit

Permalink
Revert and obsolete the creators attribute feature introduced in 6.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Jan 21, 2024
1 parent 465a599 commit 88b60da
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 534 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Expected: February 2024
* Added reference count for shared yang-specs (schema mounts)
* Allowed for sharing yspec+modules between several mountpoints

### API changes on existing protocol/config features
Users may have to change how they access the system

* Revert the creators attribute feature introduced in 6.2. It is now obsoleted.
It is replaced with a configured `creators` and user/application semantics

### C/CLI-API changes on existing features
Developers may need to change their code

Expand Down
8 changes: 0 additions & 8 deletions lib/clixon/clixon_xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,6 @@ uint16_t xml_flag(cxobj *xn, uint16_t flag);
int xml_flag_set(cxobj *xn, uint16_t flag);
int xml_flag_reset(cxobj *xn, uint16_t flag);

int xml_creator_add(cxobj *xn, char *name);
int xml_creator_rm(cxobj *xn, char *name);
int xml_creator_find(cxobj *xn, char *name);
size_t xml_creator_len(cxobj *xn);
cvec *xml_creator_get(cxobj *xn);
int xml_creator_copy_one(cxobj *x0, cxobj *x1);
int xml_creator_copy_all(cxobj *x0, cxobj *x1);

char *xml_value(cxobj *xn);
int xml_value_set(cxobj *xn, char *val);
int xml_value_append(cxobj *xn, char *val);
Expand Down
1 change: 0 additions & 1 deletion lib/clixon/clixon_xml_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,5 @@ int xml_rpc_isaction(cxobj *xn);
int xml_find_action(cxobj *xn, int top, cxobj **xap);
int purge_tagged_nodes(cxobj *xn, char *ns, char *name, char *value, int keepnode);
int clixon_compare_xmls(cxobj *xc1, cxobj *xc2, enum format_enum format);
int xml_creator_tree(cxobj *xt, cxobj **xcreator);

#endif /* _CLIXON_XML_MAP_H_ */
63 changes: 0 additions & 63 deletions lib/src/clixon_datastore_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,56 +442,6 @@ disable_nacm_on_empty(cxobj *xt,
return retval;
}

/*! Read creator data from meta-data and add to xml internal annotation
*
* Iterate creator meta-data using xpaths and create internal creator annotations
* @param[in] h Clixon handle
* @param[in] xt XML top node
* @param[in] xn XML creators node
* On the form:
* <creator>
* <name>testA[name='foo']</name>
* <xpath>...</xpath>
* ...
* </creator>
* @see xml_creator_metadata_write
*/
static int
xml_creator_metadata_read(clixon_handle h,
cxobj *xn)
{
int retval = -1;
cxobj *xt;
cxobj *xc;
cxobj *xp;
cxobj *x;
char *name;
char *xpath;

xt = xml_root(xn);
xc = NULL;
while ((xc = xml_child_each(xn, xc, CX_ELMNT)) != NULL) {
if (strcmp(xml_name(xc), "creator"))
continue;
if ((name = xml_find_body(xc, "name")) == NULL)
continue;
xp = NULL;
while ((xp = xml_child_each(xc, xp, CX_ELMNT)) != NULL) {
if (strcmp(xml_name(xp), "path"))
continue;
if ((xpath = xml_body(xp)) == NULL)
continue;
if ((x = xpath_first(xt, NULL, "%s", xpath)) == NULL)
continue;
if (xml_creator_add(x, name) < 0)
goto done;
}
}
retval = 0;
done:
return retval;
}

/*! Common read function that reads an XML tree from file
*
* @param[in] th Datastore text handle
Expand Down Expand Up @@ -593,19 +543,6 @@ xmldb_readfile(clixon_handle h,
xml_flag_set(x0, XML_FLAG_TOP);
if (xml_child_nr(x0) == 0 && de)
de->de_empty = 1;
/* Check if creator attributes are supported*/
if (clicon_option_bool(h, "CLICON_NETCONF_CREATOR_ATTR")){
if ((x = xpath_first(x0, NULL, "creators")) != NULL){
ns = NULL;
if (xml2ns(x, NULL, &ns) < 0)
goto done;
if (strcmp(ns, CLIXON_LIB_NS) == 0){
if (xml_creator_metadata_read(h, x) < 0)
goto done;
xml_purge(x);
}
}
}
/* Check if we support modstate */
if (clicon_option_bool(h, "CLICON_XMLDB_MODSTATE"))
if ((msdiff = modstate_diff_new()) == NULL)
Expand Down
44 changes: 0 additions & 44 deletions lib/src/clixon_datastore_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ text_modify(clixon_handle h,
char *restype;
int ismount = 0;
yang_stmt *mount_yspec = NULL;
char *creator = NULL;

if (x1 == NULL){
clixon_err(OE_XML, EINVAL, "x1 is missing");
Expand Down Expand Up @@ -534,13 +533,6 @@ text_modify(clixon_handle h,
clicon_data_set(h, "objectexisted", "true");
}
}
if (clicon_option_bool(h, "CLICON_NETCONF_CREATOR_ATTR")){
/* Special clixon-lib attribute for keeping track of creator of objects */
if ((ret = attr_ns_value(x1, "creator", CLIXON_LIB_NS, cbret, &creator)) < 0)
goto done;
if (ret == 0)
goto fail;
}
x1name = xml_name(x1);

if (yang_keyword_get(y0) == Y_LEAF_LIST ||
Expand Down Expand Up @@ -703,10 +695,6 @@ text_modify(clixon_handle h,
xml_flag_reset(x0, XML_FLAG_DEFAULT);
}
} /* x1bstr */
if (creator){
if (xml_creator_add(x0, creator) < 0)
goto done;
}
if (changed){
if (xml_insert(x0p, x0, insert, valstr, NULL) < 0)
goto done;
Expand Down Expand Up @@ -807,11 +795,6 @@ text_modify(clixon_handle h,
* original object is not reverted.
*/
if (x0){
if (clicon_option_bool(h, "CLICON_NETCONF_CREATOR_ATTR")){
/* Recursively copy creator attributes from existing tree */
if (xml_creator_copy_all(x0, x1) < 0)
goto done;
}
xml_purge(x0);
x0 = NULL;
}
Expand Down Expand Up @@ -862,10 +845,6 @@ text_modify(clixon_handle h,
#ifdef XML_PARENT_CANDIDATE
xml_parent_candidate_set(x0, x0p);
#endif
if (clicon_option_bool(h, "CLICON_NETCONF_CREATOR_ATTR")){
if (xml_creator_copy_one(x1, x0) < 0)
goto done;
}
changed++;
/* Get namespace from x1
* Check if namespace exists in x0 parent
Expand Down Expand Up @@ -962,10 +941,6 @@ text_modify(clixon_handle h,
if (ret == 0)
goto fail;
}
if (creator){
if (xml_creator_add(x0, creator) < 0)
goto done;
}
if (changed){
#ifdef XML_PARENT_CANDIDATE
xml_parent_candidate_set(x0, NULL);
Expand Down Expand Up @@ -1007,8 +982,6 @@ text_modify(clixon_handle h,
free(instr);
if (opstr)
free(opstr);
if (creator)
free(creator);
if (createstr)
free(createstr);
if (nscx1)
Expand Down Expand Up @@ -1239,7 +1212,6 @@ xmldb_put(clixon_handle h,
int firsttime = 0;
int pretty;
cxobj *xerr = NULL;
cxobj *xmeta = NULL;

if (cbret == NULL){
clixon_err(OE_XML, EINVAL, "cbret is NULL");
Expand Down Expand Up @@ -1355,18 +1327,6 @@ xmldb_put(clixon_handle h,
goto done;
}
pretty = clicon_option_bool(h, "CLICON_XMLDB_PRETTY");
/* Add creator attributes to datastore */
if (clicon_option_bool(h, "CLICON_NETCONF_CREATOR_ATTR")){
/* @see xml_creator_metadata_read */
if (xml_creator_tree(x0, &xmeta) < 0)
goto done;
if (xml_addsub(x0, xmeta) < 0)
goto done;
if (xml_child_nr_type(xmeta, CX_ELMNT) == 0){
xml_purge(xmeta);
xmeta = NULL;
}
}
if (strcmp(format,"json")==0){
if (clixon_json2file(f, x0, pretty, fprintf, 0, 0) < 0)
goto done;
Expand All @@ -1377,10 +1337,6 @@ xmldb_put(clixon_handle h,
*/
if (xmodst && xml_purge(xmodst) < 0)
goto done;
if (clicon_option_bool(h, "CLICON_NETCONF_CREATOR_ATTR") && xmeta){
if (xml_purge(xmeta) < 0)
goto done;
}
retval = 1;
done:
if (f != NULL)
Expand Down
Loading

0 comments on commit 88b60da

Please sign in to comment.