在云端自动化虚拟机设置和交付

通过使用 Testcloud 自动化设置过程并交付可运行的 VM,在几分钟内准备好云镜像。
69 位读者喜欢这个。
Looking at a map

opensource.com

如果您是开发人员或爱好者,使用 Fedora qcow2 镜像 用于云,您总是需要在镜像准备好使用之前进行一堆初始配置。我对此非常清楚,并且渴望找到一种使设置过程更简单的方法。碰巧的是,整个 Fedora 质量保证团队也有同感,因此我们开发了 Testcloud

Testcloud 是一款工具,可以轻松地在几分钟内准备好用于测试的云镜像。它自动化了设置过程,并交付了一个虚拟机 (VM),只需几个命令即可在云端运行。 

Testcloud

  1. 下载 qcow2 镜像
  2. 使用您选择的名称创建实例
  3. 创建一个名为 fedora 的用户,密码为 passw0rd
  4. 分配一个 IP,您稍后可以使用该 IP 安全外壳 (SSH) 进入云
  5. 启动、停止、移除和列出实例

安装 Testcloud

要开始您的旅程,您首先必须安装 Testcloud 软件包。您可以从终端或通过软件应用程序安装它。在这两种情况下,软件包名称都是 testcloud。使用以下命令安装

$ sudo dnf install testcloud -y

安装完成后,将您想要的用户添加到 testcloud 组,这将帮助 Testcloud 自动化其余过程。执行以下两个命令将您的用户添加到 testcloud 组并使用更新的组权限重启会话

$ sudo usermod -a -G testcloud $USER 
$ su - $USER 

像专业人士一样旋转云镜像

一旦您的用户拥有所需的组权限,创建一个实例

$ 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 身份登录。您可以使用 sshvirt-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,并在评论中告诉我您的想法。

接下来阅读什么
标签
User profile image.
嘿,开源爱好者们!我是 Sumantro,来自印度(东部地区 - 英国时代的前首都,又名加尔各答)。我喜欢分享知识并撰写关于技术和经验的文章(主要是我每天尝试的)。

4 条评论

[url]https://writemypapertoday.org/[/url]
[url=https://writemypapertoday.org/]writemypapertoday.org[/url]
<a href="https://theappsolutions.com/blog/how-to/live-stream-website-like-twitch/">如何制作像 Twitch 这样的流媒体服务</a>
[bestessaytyper.com/do-my-essay](https://bestessaytyper.com/do-my-essay)

https://writemypapertoday.org/
www.writemypapertoday.org/

如果您对创意乐高积木模型感兴趣,或者您收集自己喜欢的乐高系列,欢迎访问我们的 < a href="https://legofanblog.tumblr.com">乐高粉丝 </a> 博客,您可以在那里找到有关乐高的最新消息等等。

如果您对创意乐高积木模型感兴趣,或者您收集自己喜欢的乐高系列,欢迎访问我们的 <a href="https://legofanblog.tumblr.com">乐高粉丝 </a> 博客,您可以在那里找到有关乐高的最新消息等等。

知识共享许可协议本作品根据知识共享署名-相同方式共享 4.0 国际许可协议获得许可。
© . All rights reserved.