如果您是开发人员或爱好者,使用 Fedora qcow2 镜像 用于云,您总是需要在镜像准备好使用之前进行一堆初始配置。我对此非常清楚,并且渴望找到一种使设置过程更简单的方法。碰巧的是,整个 Fedora 质量保证团队也有同感,因此我们开发了 Testcloud。
Testcloud 是一款工具,可以轻松地在几分钟内准备好用于测试的云镜像。它自动化了设置过程,并交付了一个虚拟机 (VM),只需几个命令即可在云端运行。
Testcloud
- 下载 qcow2 镜像
- 使用您选择的名称创建实例
- 创建一个名为
fedora
的用户,密码为passw0rd
- 分配一个 IP,您稍后可以使用该 IP 安全外壳 (SSH) 进入云
- 启动、停止、移除和列出实例
安装 Testcloud
要开始您的旅程,您首先必须安装 Testcloud 软件包。您可以从终端或通过软件应用程序安装它。在这两种情况下,软件包名称都是 testcloud
。使用以下命令安装
$ sudo dnf install testcloud -y
安装完成后,将您想要的用户添加到 testcloud
组,这将帮助 Testcloud 自动化其余过程。执行以下两个命令将您的用户添加到 testcloud
组并使用更新的组权限重启会话
$ sudo usermod -a -G testcloud $USER
$ su - $USER

(Sumantro Mukherjee,CC BY-SA 4.0)
像专业人士一样旋转云镜像
一旦您的用户拥有所需的组权限,创建一个实例
$ testcloud instance create <instance name> -u <url for qcow2 image>
或者,您可以使用 fedora:latest/fedora:XX
(其中 XX
是您的 Fedora 版本)而不是完整 URL
$ testcloud instance create <instance name> -u fedora:latest
这将返回您的 VM 的 IP 地址
$ testcloud instance create testcloud272593 -u https://download.fedoraproject.org/pub/fedora/linux/releases/33/Cloud/x86_64/images/Fedora-Cloud-Base-33-1.2.x86_64.qcow2
[...]
INFO:Successfully booted instance testcloud272593
The IP of vm testcloud272593: 192.168.122.202
------------------------------------------------------------
To connect to the VM, use the following command (password is 'passw0rd'):
ssh fedora@192.168.122.202
------------------------------------------------------------
您可以使用密码 passw0rd
(注意是零)以默认用户 fedora
身份登录。您可以使用 ssh
、virt-manager
或任何其他支持连接到 libvirt 机器的方法访问 VM。
创建 Fedora 云的另一种简单方法是
$ testcloud instance create testcloud193 -u fedora:33
WARNING:Not proceeding with backingstore cleanup because there are some testcloud instances running.
You can fix this by following command(s):
testcloud instance stop testcloud272593
DEBUG:Local downloads will be stored in /var/lib/testcloud/backingstores.
DEBUG:successfully changed SELinux context for image /var/lib/testcloud/backingstores/Fedora-Cloud-Base-33-1.2.x86_64.qcow2
DEBUG:Creating instance directories
DEBUG:creating seed image /var/lib/testcloud/instances/testcloud193/testcloud193-seed.img
INFO:Seed image generated successfully
INFO:Successfully booted instance testcloud193
The IP of vm testcloud193: 192.168.122.225
------------------------------------------------------------
To connect to the VM, use the following command (password is 'passw0rd'):
ssh fedora@192.168.122.225
------------------------------------------------------------
玩转实例
Testcloud 可用于管理实例。这包括诸如列出镜像或停止和启动实例之类的活动。
要列出实例,请使用 list
子命令
$ testcloud instance list
Name IP State
------------------------------------------------------------
testcloud272593 192.168.122.202 running
testcloud193 192.168.122.225 running
testcloud252793 192.168.122.146 shutoff
testcloud93 192.168.122.152 shutoff
要停止正在运行的实例
$ testcloud instance stop testcloud193
DEBUG:stop instance: testcloud193
DEBUG:stopping instance testcloud193.
要移除实例
$ testcloud instance destroy testcloud193
DEBUG:remove instance: testcloud193
DEBUG:removing instance testcloud193 from libvirt.
DEBUG:Unregistering instance from libvirt.
DEBUG:removing instance /var/lib/testcloud/instances/testcloud193 from disk
要重启正在运行的实例
$ testcloud instance reboot testcloud93
DEBUG:stop instance: testcloud93
[...]
INFO:Successfully booted instance testcloud93
The IP of vm testcloud93: 192.168.122.152
usage: testcloud [-h] {instance,image} ...
试用 Testcloud,并在评论中告诉我您的想法。
4 条评论