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>
This commit is contained in:
Rafał Miłecki 2017-11-30 11:04:53 +01:00
parent 55e530747f
commit 650704c425
1 changed files with 5 additions and 0 deletions

View File

@ -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);