Skip to content

Commit

Permalink
Fixed: [CLI expand of apply services instance](#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Feb 22, 2024
1 parent 31f2dd9 commit 847cb1a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ test/site.sh
test/py

src/controller.xml
src/build.c
test/config.sh

# purged from history with git filter-repo
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Expected: February 2024

### Corrected Bugs

* Fixed: [CLI expand of apply services instance](https://github.com/clicon/clixon-controller/issues/106)
* Fixed: [Syntax errors must be shown in CLI](https://github.com/clicon/clixon-controller/issues/103)
* Fixed: [Lock-denied if device connection fails](https://github.com/clicon/clixon-controller/issues/98)
* Fixed: [Device connection errors could be more informative](https://github.com/clicon/clixon-controller/issues/7)
Expand Down
16 changes: 14 additions & 2 deletions src/controller_cli_callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,12 @@ cli_rpc_commit_diff(clixon_handle h)
}

/*! Get first list key of controller service
*
* @param[in] yspec YANG specification
* @param[in] service Name o service
* @param[out] keyname Name of (first) key of service
* @retval 0 OK
* @retval -1 Error
*/
static int
get_service_key(yang_stmt *yspec,
Expand Down Expand Up @@ -852,6 +858,7 @@ cli_rpc_controller_commit(clixon_handle h,
char *actions_type;
char *source;
transaction_result result;
char *str;
char *service = NULL;
char *instance = NULL;
yang_stmt *yspec;
Expand Down Expand Up @@ -890,8 +897,11 @@ cli_rpc_controller_commit(clixon_handle h,
}
if ((cv = cvec_find(cvv, "name")) != NULL)
name = cv_string_get(cv);
if ((cv = cvec_find(cvv, "service")) != NULL)
service = cv_string_get(cv);
if ((cv = cvec_find(cvv, "service")) != NULL &&
(str = cv_string_get(cv)) != NULL){
if (nodeid_split(str, NULL, &service) < 0)
goto done;
}
if ((cv = cvec_find(cvv, "instance")) != NULL)
instance = cv_string_get(cv);
if ((cb = cbuf_new()) == NULL){
Expand Down Expand Up @@ -959,6 +969,8 @@ cli_rpc_controller_commit(clixon_handle h,
ok:
retval = 0;
done:
if (service)
free(service);
if (cb)
cbuf_free(cb);
if (xret)
Expand Down
7 changes: 3 additions & 4 deletions src/controller_configure.cli
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ apply("Apply template on devices") {
variables @template_vars;
}
services("(Re)Apply services"), cli_rpc_controller_commit("candidate", "FORCE", "COMMIT"); {
<service:string expand_yang("/ctrl:services")>
<instance:string>
# (<instance:string>|<instance:string expand_dbvar("running", "/clixon-controller:services/${service}")>)
, cli_rpc_controller_commit("candidate", "FORCE", "COMMIT");
<service:string expand_yang_list("/ctrl:services", "true")>
<instance:string expand_dbvar("running", "/clixon-controller:services/%s/name")>,
cli_rpc_controller_commit("candidate", "FORCE", "COMMIT");
{
diff("Show the result of running the services but do not commit"), cli_rpc_controller_commit("candidate", "FORCE", "NONE");
}
Expand Down
4 changes: 2 additions & 2 deletions test/test-c-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,10 @@ expectpart "$(${clixon_cli} -m configure -1f $CFG commit 2>&1)" 0 "OK"

# XXX: These are not properly tested
new "apply single services diff"
expectpart "$(${clixon_cli} -m configure -1f $CFG apply services testA foo diff 2>&1)" 0 "OK"
expectpart "$(${clixon_cli} -m configure -1f $CFG apply services myyang:testA foo diff 2>&1)" 0 "OK"

new "apply single services"
expectpart "$(${clixon_cli} -m configure -1f $CFG apply services testA foo 2>&1)" 0 "OK"
expectpart "$(${clixon_cli} -m configure -1f $CFG apply services myyang:testA foo 2>&1)" 0 "OK"

new "apply all services"
expectpart "$(${clixon_cli} -m configure -1f $CFG apply services 2>&1)" 0 "OK"
Expand Down

0 comments on commit 847cb1a

Please sign in to comment.