Code Monkey home page Code Monkey logo

vm's Introduction

About

vm is a command line utility that provides a high-level interface to create and manage virtual machines through libvirt.

It supports creation and deletion of domains and snapshots, connecting to serial and SSH terminals, downloading and converting templates from vagrantup.com and builder.libguestfs.org, and importing locally downloading images.

Installation

go get -u github.com/subpop/vm/cmd/vm

Distribution

vm includes a Makefile to aid distributions in packaging. The default target will build vm along with shell completion data and a man page. The Makefile includes an install target to install the binary and data into distribution-appropriate locations. To override the installation directory (commonly referred to as the DESTDIR), set the DESTDIR variable when running the install target:

[link@localhost vm]$ make
go build ./cmd/vm
go run ./cmd/vm --generate-fish-completion > vm.fish
go run ./cmd/vm --generate-bash-completion > vm.bash
go run ./cmd/vm --generate-man-page > vm.1
gzip -k vm.1
[link@localhost vm]$ make DESTDIR=_inst install
install -D -m755 -t _inst//usr/local/bin vm
install -D -m644 -t _inst//usr/local/share/man/man1 vm.1.gz
install -D -m644 -t _inst//usr/local/share/fish/completions vm.fish
install -d _inst//usr/local/share/bash-completion/completions
install -m644 -T vm.bash _inst//usr/local/share/bash-completion/completions/vm
[link@localhost vm]$

Usage

Download a base image:

vm image get https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2

Download and convert a Vagrant ".box":

vm image get https://dl.fedoraproject.org/pub/fedora/linux/releases/31/Cloud/x86_64/images/Fedora-Cloud-Base-Vagrant-31-1.9.x86_64.vagrant-libvirt.box

Create a domain backed by that image:

vm create Fedora-Cloud-Base-31-1.9.x86_64 --name my-f31

Create a domain without defining it:

vm create Fedora-Cloud-Base-31-1.9.x86_64 --transient

List active domains:

vm list

Start a created domain:

vm up my-f31

Connect to an existing domain over SSH:

vm connect -m ssh -u vagrant my-f31 -i ~/.ssh/cloud_user_rsa

Connect to an existing domain over VirtIO PTY:

vm connect -m console my-f31

Take a snapshot:

vm snapshot create my-f31 --name fresh_install

Revert to snapshot:

vm snapshot revert my-f31 --snapshot fresh_install

vm's People

Contributors

dependabot[bot] avatar subpop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vm's Issues

Add domain editing

Similar to virsh edit, but more user friendly (i.e. no editing XML by hand).

Release 0.1

Stuff to do:

  • Generate bash completions
  • Generate fish completions
  • Generate man page
  • Stick a version in it
  • Write a Makefile to perform build/install steps

generate flags introduce crash when running with unknown subcommand

[link@localhost ~]$ vm foo
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x8ce14a]

goroutine 1 [running]:
main.main.func20(0xc00003aa00, 0x7fff79ad69c4, 0x3)
	/home/link/Projects/vm/cmd/vm/main.go:444 +0x8a
github.com/urfave/cli/v2.(*App).Run(0xc000001b00, 0xc00000e080, 0x2, 0x2, 0x0, 0x0)
	/home/link/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:304 +0x5f0
main.main()
	/home/link/Projects/vm/cmd/vm/main.go:452 +0x21a2

error: no interfaces detected for domain

When connecting via SSH, the IP detection logic sometimes fails.

[link@thelio ~]$ vm connect -m ssh ic-rhel7-dev
error: no interfaces detected for ic-rhel7-dev
[link@thelio ~]$ vm connect -m ssh ic-rhel7-dev
error: no interfaces detected for ic-rhel7-dev
[link@thelio ~]$ vm connect -m ssh ic-rhel7-dev
error: no interfaces detected for ic-rhel7-dev
[link@thelio ~]$ vm connect -m ssh ic-rhel7-dev
error: no interfaces detected for ic-rhel7-dev
[link@thelio ~]$ vm connect -m ssh ic-rhel7-dev

Check for runtime requirements

There are a handful of external programs that are called at runtime. Their presence should be checked before doing anything.

  • qemu-img

Support cloud-init user-data

It's common for images to come configured with cloud-init. Adding support for providing a cloud-init ISO (or even creating a suitable one from provided user inputs) would be nice.

Serial & console connections term width/height

The term width and height of serial connections is set to the calling terminal emulator's window width & height and does not adjust dynamically when the terminal emulator resizes. Is it possible to adjust the term width and height inside the VM?

Creation customization options

Allow for customizing other domain features like memory at creation (i.e. vm create --memory 1GB)

  • --memory
  • --video <type>
  • --network <bridge_device_name>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.