Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
8585f204
Commit
8585f204
authored
Nov 04, 2013
by
Dwight Engen
Committed by
Stéphane Graber
Nov 05, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua: add cmd_get_config_item to API
Signed-off-by:
Dwight Engen
<
dwight.engen@oracle.com
>
Acked-by:
Stéphane Graber
<
stgraber@ubuntu.com
>
parent
6502006a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
+40
-0
core.c
src/lua-lxc/core.c
+25
-0
lxc.lua
src/lua-lxc/lxc.lua
+8
-0
apitest.lua
src/lua-lxc/test/apitest.lua
+7
-0
No files found.
src/lua-lxc/core.c
View file @
8585f204
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <unistd.h>
#include <libgen.h>
#include <libgen.h>
#include <lxc/lxccontainer.h>
#include <lxc/lxccontainer.h>
#include <lxc/commands.h>
#if LUA_VERSION_NUM < 502
#if LUA_VERSION_NUM < 502
#define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
#define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
...
@@ -417,6 +418,29 @@ static int lxc_default_config_path_get(lua_State *L) {
...
@@ -417,6 +418,29 @@ static int lxc_default_config_path_get(lua_State *L) {
return
1
;
return
1
;
}
}
static
int
cmd_get_config_item
(
lua_State
*
L
)
{
int
arg_cnt
=
lua_gettop
(
L
);
const
char
*
name
=
luaL_checkstring
(
L
,
1
);
const
char
*
key
=
luaL_checkstring
(
L
,
2
);
const
char
*
lxcpath
=
NULL
;
char
*
value
;
if
(
arg_cnt
>
2
)
lxcpath
=
luaL_checkstring
(
L
,
3
);
value
=
lxc_cmd_get_config_item
(
name
,
key
,
lxcpath
);
if
(
!
value
)
goto
not_found
;
lua_pushstring
(
L
,
value
);
return
1
;
not_found:
lua_pushnil
(
L
);
return
1
;
}
/* utility functions */
/* utility functions */
static
int
lxc_util_usleep
(
lua_State
*
L
)
{
static
int
lxc_util_usleep
(
lua_State
*
L
)
{
usleep
((
useconds_t
)
luaL_checkunsigned
(
L
,
1
));
usleep
((
useconds_t
)
luaL_checkunsigned
(
L
,
1
));
...
@@ -432,6 +456,7 @@ static int lxc_util_dirname(lua_State *L) {
...
@@ -432,6 +456,7 @@ static int lxc_util_dirname(lua_State *L) {
static
luaL_Reg
lxc_lib_methods
[]
=
{
static
luaL_Reg
lxc_lib_methods
[]
=
{
{
"version_get"
,
lxc_version_get
},
{
"version_get"
,
lxc_version_get
},
{
"default_config_path_get"
,
lxc_default_config_path_get
},
{
"default_config_path_get"
,
lxc_default_config_path_get
},
{
"cmd_get_config_item"
,
cmd_get_config_item
},
{
"container_new"
,
container_new
},
{
"container_new"
,
container_new
},
{
"usleep"
,
lxc_util_usleep
},
{
"usleep"
,
lxc_util_usleep
},
{
"dirname"
,
lxc_util_dirname
},
{
"dirname"
,
lxc_util_dirname
},
...
...
src/lua-lxc/lxc.lua
View file @
8585f204
...
@@ -385,6 +385,14 @@ function M.default_config_path_get()
...
@@ -385,6 +385,14 @@ function M.default_config_path_get()
return
core
.
default_config_path_get
()
return
core
.
default_config_path_get
()
end
end
function
M
.
cmd_get_config_item
(
name
,
item
,
lxcpath
)
if
(
lxcpath
)
then
return
core
.
cmd_get_config_item
(
name
,
item
,
lxcpath
)
else
return
core
.
cmd_get_config_item
(
name
,
item
)
end
end
lxc_path
=
core
.
default_config_path_get
()
lxc_path
=
core
.
default_config_path_get
()
return
M
return
M
src/lua-lxc/test/apitest.lua
View file @
8585f204
...
@@ -217,6 +217,12 @@ function test_container_cgroup()
...
@@ -217,6 +217,12 @@ function test_container_cgroup()
assert
(
container
:
set_cgroup_item
(
"memory.limit_in_bytes"
,
"-1"
))
assert
(
container
:
set_cgroup_item
(
"memory.limit_in_bytes"
,
"-1"
))
end
end
function
test_container_cmd
()
log
(
0
,
"Test get config from running container..."
)
veth_pair
=
lxc
.
cmd_get_config_item
(
optarg
[
"n"
],
"lxc.network.0.veth.pair"
)
log
(
0
,
" veth.pair:%s"
,
veth_pair
)
end
function
test_config_items
()
function
test_config_items
()
log
(
0
,
"Test set/clear configuration items..."
)
log
(
0
,
"Test set/clear configuration items..."
)
...
@@ -325,6 +331,7 @@ test_container_start()
...
@@ -325,6 +331,7 @@ test_container_start()
test_container_started
()
test_container_started
()
test_container_cgroup
()
test_container_cgroup
()
test_container_cmd
()
test_container_freeze
()
test_container_freeze
()
test_container_frozen
()
test_container_frozen
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment