Skip to content

Instantly share code, notes, and snippets.

@bison--
Created May 12, 2020 09:56
Show Gist options
  • Save bison--/45df2c2130cfcf558a99d1da1c450c3b to your computer and use it in GitHub Desktop.
Save bison--/45df2c2130cfcf558a99d1da1c450c3b to your computer and use it in GitHub Desktop.
a tiny interactive script to create Ubuntu VMs with multipass
#!/usr/bin/python3
import subprocess
full_params = ['multipass', 'launch']
name = input('name: ')
if name:
full_params.extend(['--name', name])
version = input('version: ')
if version:
full_params.append(version)
cpu_cores = input('cores (def 4): ')
full_params.append('-c')
if cpu_cores:
full_params.append(cpu_cores)
else:
full_params.append('4')
ram = input('ram (in gb, def 4gb): ')
full_params.append('-m')
if ram:
full_params.append(ram + 'gb')
else:
full_params.append('4gb')
disk_space = input('disk space (in gb, def 20gb): ')
full_params.append('-d')
if disk_space:
full_params.append(disk_space + 'G')
else:
full_params.append('20G')
#multipass launch --name builder 18.04 -c 8 -m 8gb -d 40G
subprocess.run(full_params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment