使用python api在opennebula上创建vm

2024-06-09 06:11:35 发布

您现在位置:Python中文网/ 问答频道 /正文

正如标题所说,我正试图用pythonapi在opennebula上创建一个vm。(这是我第一次和一个人合作,我什么都不知道,所以请不要对我太苛刻)

#!/usr/bin/python3

import oca
client = oca.Client('username:passwd', 'ip:2633/RPC2')
oca.VirtualMachine.allocate(client, 'test')
#'test' is the name of the template i want to use 

它给了我一个错误:

^{pr2}$

有人知道怎么解决这个问题吗? 提前谢谢。在


Tags: thetestimportclient标题pythonapibinusr
1条回答
网友
1楼 · 发布于 2024-06-09 06:11:35

好吧。。我很蠢,在正确的地方尝试了4小时之后才搜索到git存储库和“问题”选项卡。在

vm_templ = oca.VmTemplatePool(client)
vm_templ.info()

for templ in vm_templ:
    if templ.name == "Ubuntu 14.04 - KVM":
        templ.instantiate("oca-test")

这是一种通过python为现有模板创建vm的方法。 (缺少连接部分,但这很简单)。在

我不想删除这个问题,也许有人也会很难接受这个问题。在

相关问题 更多 >