I get the following error when i run the following code.
Version info:
Python 3.6.5 (default, May 11 2018, 04:00:52) [GCC 8.1.0] on linux
Code:
Proper format at https://gist.github.com/Drunkenpanda2000/31f76521ce1166b804a539f40ec21c60
#!/usr/bin/env python
import subprocess
#will be replaced with inputs from Chef
name='test'
vcpus=1
memory=2048
iso='/var/lib/libvirt/images/Centos.iso'
discsize= 80
os_type='linux'
os_variant='centos7'
network_bridge='default'
#setting up the command
args = (
'virt-install' +
' --name=' + name +
' --vcpus=' + vcpus +
' --memory=' + memory +
' --cdrom=' + iso +
' --disk size=' + discsize +
' --os-type=' + os_type +
' --os-varient=' + os_variant +
' --network bridge=' + network_bridge +
" --extra-args 'console=ttyS0,115200n8 serial'" )
#execute the commands in bash
subprocess.call(args, shell=True)
Error
[drunkenpanda@Diablo Scripts]$ ./createvm.py Traceback (most recent call last): File "./createvm.py", line 27, in <module>
' --network bridge=' + network_bridge + TypeError: must be str, not int
New code
args = ['virt-install',
' --name',name,
' --vcpus',str(vcpus),
' --memory',str(memory),
' --cdrom',iso,
' --disk-size',str(discsize),
' --os-variant',os_variant,
' --os-type',os_type,
' --network bridge',network_bridge]
# " --extra-args 'console=ttyS0,115200n8 serial'"\
#execute the commands in bash
subprocess.call(args, shell=False)
New error
./createvmattend.1.py
usage: virt-install --name NAME --memory MB STORAGE INSTALL [options]
virt-install: error: unrecognized arguments: --name bob --vcpus 1 --memory 2048 --cdrom /var/lib/libvirt/images/Centos.iso --disk-size 80 --os-variant centos7.0 --os-type linux --network bridge virbr0