aboutsummaryrefslogtreecommitdiff
path: root/utils/rpcd-mod-lxc
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2017-11-30 11:04:53 +0100
committerRafał Miłecki <rafal@milecki.pl>2017-12-06 09:58:17 +0100
commit650704c4258c0e02fc3519cb8a45728ea14eac9a (patch)
tree0061ab08743008b380bdf871e7ccc7b8b86a9f19 /utils/rpcd-mod-lxc
parent55e530747f3543dec326ab057249b52d50431916 (diff)
rpcd-mod-lxc: info: return NOT_FOUND if container doesn't exist
It allow distinction between not existing and stopped container. So far querying for not existing container was resulting in: > ubus call lxc info '{ "name": "foo" }' { "name": "foo", "state": "STOPPED", "ips": [ ] } Now it's an error and it matches lxc-info command line: > ubus call lxc info '{ "name": "foo" }' Command failed: Not found > lxc-info --name foo foo doesn't exist Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Diffstat (limited to 'utils/rpcd-mod-lxc')
-rw-r--r--utils/rpcd-mod-lxc/files/lxc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/utils/rpcd-mod-lxc/files/lxc.c b/utils/rpcd-mod-lxc/files/lxc.c
index 6db1b3117..a98fcfc54 100644
--- a/utils/rpcd-mod-lxc/files/lxc.c
+++ b/utils/rpcd-mod-lxc/files/lxc.c
@@ -332,6 +332,11 @@ rpc_lxc_info(struct ubus_context *ctx, struct ubus_object *obj,
l = rpc_lxc_init(tb);
if (!l)
return UBUS_STATUS_INVALID_ARGUMENT;
+
+ if (!l->container->is_running(l->container) &&
+ !l->container->is_defined(l->container))
+ return UBUS_STATUS_NOT_FOUND;
+
blob_buf_init(&buf, 0);
blobmsg_add_string(&buf, "name", l->container->name);