XC4U

lxc4u的Python项目详细描述


警告!这项工作仍在进行中。

提供在Ubuntu12.04和Ubuntu12.04容器中管理LXC的工具。 不支持其他容器(还不支持?)

  • 使用overlayfs创建容器
  • 可以处理多个覆盖层

工作示例

创建名为test1

的容器
import lxc4u

test1_lxc = lxc4u.create('test1')
# Wait a long time...

# Start the container
test1_lxc.start()

创建覆盖test1

的容器
import lxc4u

test1_overlay_lxc = lxc4u.create('test1_overlay', base='test1',
                                overlays=['overlay_path'])

# Start the container
test1_overlay_lxc.start()

test1_overlay_lxc.destroy()

创建一个包含多个test1覆盖的容器。最右边的覆盖 是最上面的覆盖目录:

import lxc4u

test1_overlay_lxc = lxc4u.create('test1_overlay', base='test1',
                            overlays=['overlay1_path', 'overlay2_path'])

# Start the container
test1_overlay_lxc.start()

这些例子尚未实施。很快!

正在启动名为test1的容器。这假设lxc配置正确 在您的系统中:

import lxc4u

# Start container
test1_lxc = lxc4u.start('test1')

# Stop container
test1_lxc.stop()
# or lxc4u.stop('test1')

可能的接口示例

以test1为基础启动临时容器:

import lxc4u

# Start container
test1_ephemeral_lxc = lxc4u.start('test1', ephemeral=True)

# Stop container
test1_ephemeral_lxc.stop()

使用带有静态网络设置的test1启动临时容器:

import lxc4u

network_settings = dict(
    ip="10.0.3.5",
    gateway="10.0.3.1",
    netmask="255.255.255.0",
    network="10.0.3.0",
)

# Start container
test1_ephemeral_lxc = lxc4u.start('test1', ephemeral=True,
                                static_network=network_settings)

# Stop container
test1_ephemeral_lxc.stop()

使用startup命令启动临时容器(必须可用 在容器的路径上):

import lxc4u

# Start container
test1_ephemeral_lxc = lxc4u.start('test1', ephemeral=True,
                    startup_command="/usr/local/bin/somecommand")

# Stop container
test1_ephemeral_lxc.stop()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在ArrayList中比较数字   java在Kotlin中使异步调用同步   让“Scala编程”junit示例在IntelliJ中工作的java问题   java Servlet侦听器未在ContextListener中设置属性   将Microsoft SQL Server数据库连接到我的Java项目   加载资源时出现java“需要注册工厂”异常   java如何使用POI检查excel中的重复记录?   java如何更改机器生成的代码   java如何确保重写的方法是同步的   用Spring编写Hibernate时的java XML奥秘   java管理mysql数据库中存储的用户权限   java如何运行。来自Javascript的jar方法   java我想在Web应用程序中进行身份验证&对桌面应用程序使用相同的凭据。我该怎么做?