Skip to content

Instantly share code, notes, and snippets.

@NicTanghe
Created June 5, 2018 21:08
Show Gist options
  • Save NicTanghe/31f76521ce1166b804a539f40ec21c60 to your computer and use it in GitHub Desktop.
Save NicTanghe/31f76521ce1166b804a539f40ec21c60 to your computer and use it in GitHub Desktop.
#!/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)
#reminder
# virt-install\
# --name=name \
# --vcpus=vcpus \
# --memory=memory \
# --cdrom=iso \
# --disk size=discsize \
# --os-type=os_type
# --os-variant=os_variant\
# --network bridge=network_bridge \
# --extra-args 'console=ttyS0,115200n8 serial'
# )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment