使用python创建LVM存储

2024-09-30 20:21:49 发布

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

我试图用python编写一个脚本来复制VMs,但是我得到了以下错误:

sudo lvcreate -L3072 -s -n TestPrestashop1-disk /dev/ls2018-vg/Prestashop-disk
Traceback (most recent call last):
  File "VMDuplicator.py", line 74, in <module>
    main()
  File "VMDuplicator.py", line 62, in main
    createLV(True, amount)
  File "VMDuplicator.py", line 37, in createLV
    output = call(s)
  File "/usr/lib/python2.7/subprocess.py", line 172, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 394, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1047, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

我的代码:

^{pr2}$

有人知道这是否是在python中使用函数调用或子进程的正确方法吗?因为它可以很好地使用ls-l命令。在

我还打印出执行的命令,即:sudolvcreate-L3072-s-ntestprestashop1disk/dev/ls2018 vg/Prestashop disk(在变量s中)。如果我手动执行这个命令,它可以正常工作。。。如有任何建议,我们将不胜感激!!在


Tags: inpydev命令libusrlinecall