GithubHelp home page GithubHelp logo

ryran / valine Goto Github PK

View Code? Open in Web Editor NEW
30.0 30.0 3.0 46 KB

Easy qcow & LVM snapshot management of libvirt guests with intelligent tab-completion

License: GNU General Public License v3.0

Shell 100.00%

valine's People

Contributors

csutherl avatar ryran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

goetzvr gema-arta

valine's Issues

get rid of blank lines in the standard list output

When running valine with no args, we've always inserted a blank line in between each VM ... Now that I'm seeing valine run on machines with more than a few VMs, well ... it really wastes space. Time to fix.

valine not working on xen hypervisor due to LIBVIRT_DEFAULT_URI variable

Hi

I found this script could be very useful and decied to try it on my env.
I downloaded your code and started to do simple things like
./valine DOMAIN {console|loop-ssh}
on my xen 4.2 env and i get error that vm not reconised :

[root@xen valine-master]# virsh list 
 Id    Name                           State
----------------------------------------------------
 0     Domain-0                       running
 6     informix-21-222_4              idle

[root@xen valine-master]# ./valine informix-21-222_4 console
Error: DOMAIN 'informix-21-222_4' not recognized
Available domains:
[root@xen valine-master]# 

I couldn't find reason why it got this error and also why there is no output after Available domain:

Keep good work.

Best Regards
Kenan

fix & improve lvm support

  • valine doesn't auto-create /etc/valine directory for you YIKES
/usr/bin/valine: line 313: /etc/valine/rhel65: No such file or directory
/usr/bin/valine: line 333: /etc/valine/rhel65: No such file or directory
/usr/bin/valine: line 333: /etc/valine/rhel65: No such file or directory
awk: fatal: cannot open file `/etc/valine/rhel65' for reading (No such file or directory)
Warning: rhel65 config file has improper CfgVersion ('0Sifr' expected)
Storage displayed for this domain might not be accurate
If this causes problems, delete /etc/valine/rhel65
awk: cmd. line:2: fatal: cannot open file `/etc/valine/rhel65' for reading (No such file or directory)
  • lvm state files for VMs should be in /var/lib instead of /etc
  • For each VM that has lvm storage, you get /usr/sbin/lvm printed in the main output, i.e.:
──────────────┬───┬─────────┬───────────────────────────────────────────
 DOMAIN       │ ⚡ │ STORAGE │ SNAPSHOTS
──────────────┼───┼─────────┼───────────────────────────────────────────
 r72          │ ◌ │ qcow2   │ /var/lib/upvm/r72.qcow2
              │   │         │   └─pristine
              │   │         │       └─webdb
              │   │         │           └─reg-updated ←
/usr/sbin/lvm
 rhel65       │ ◌ │ lvm     │ /dev/jiop/rhel65
              │   │         │   └─rhel65-snap0 ←
 tae511       │ ◌ │ qcow2   │ /var/lib/libvirt/images/tae511.qcow2 ←
  • If a VM has lvm storage, you get prompted by sudo for passwords
  • If a VM has lvm storage and you don't have sudo access to run sudo lvm, you get weird corrupted output even if there's already a generated configfile for that vm:
────────┬───┬─────────┬───────────────────────────────────────────
 DOMAIN │ ⚡ │ STORAGE │ SNAPSHOTS
────────┼───┼─────────┼───────────────────────────────────────────
 tae66  │ ◉ │ qcow2   │ /var/lib/upvm/tae66.qcow2 ←
 tae72  │ ◉ │ qcow2   │ /var/lib/upvm/tae72.qcow2 ←
 r49    │ ◌ │ qcow2   │ /var/lib/upvm/r49.qcow2
        │   │         │   └─pristine ←
 r511   │ ◌ │ qcow2   │ /var/lib/upvm/r511.qcow2
        │   │         │   └─pristine ←
 r65    │ ◌ │ qcow2   │ /var/lib/upvm/r65.qcow2
        │   │         │   └─pristine
        │   │         │       └─httpd ←
 r67    │ ◌ │ qcow2   │ /var/lib/upvm/r67.qcow2
        │   │         │   └─pristine
        │   │         │       └─webdb
        │   │         │           └─reg-updated ←
 r71    │ ◌ │ qcow2   │ /var/lib/upvm/r71.qcow2 ←
 r72    │ ◌ │ qcow2   │ /var/lib/upvm/r72.qcow2
        │   │         │   └─pristine
        │   │         │       └─webdb
        │   │         │           └─reg-updated ←
Error: Not root and this user doesn't have required sudo access to 'lvm' command
Consdier running as root:
──echo─'junkbob─ALL=(ALL)─NOPASSWD:─/usr/sbin/lvm'─>>/etc/sudoers.d/junkbob-lvm──────────────────────────────────────────

add subcommand: sendkey?

corresponding with virsh send-key for sending keystrokes

This could be used to send sysrq or ctrl-alt-del ... I dunno.

add subcommand: Hard-reboot

This would correspond with virsh reset ... unfortunately I think it would be too confusing to have reset be the command for this since valine is all about snapshots. I dunno ... thoughts?

qemu-img complains about no access to images that are not qcow*

Looks like all of the errors I receive when using valine without escalated privileges are related to the images being 'raw image' rather than a 'qcow2'.

When I invoke valine with sudo, I do not hit this issue, currently.

See below:

# valine
qemu-img: Could not open '/home/data/virts/images/rhel4.5.qcow2': Could not open '/home/data/virts/images/rhel4.5.qcow2': Permission denied
qemu-img: Could not open '/home/data/virts/images/rhel5.10.qcow2': Could not open '/home/data/virts/images/rhel5.10.qcow2': Permission denied
qemu-img: Could not open '/home/data/virts/images/rhel5.11.qcow2': Could not open '/home/data/virts/images/rhel5.11.qcow2': Permission denied
qemu-img: Could not open '/home/data/virts/images/rhel6.5.qcow2': Could not open '/home/data/virts/images/rhel6.5.qcow2': Permission denied
qemu-img: Could not open '/home/data/virts/images/rhel6.6.qcow2': Could not open '/home/data/virts/images/rhel6.6.qcow2': Permission denied
qemu-img: Could not open '/home/data/virts/images/rhel7.0.qcow2': Could not open '/home/data/virts/images/rhel7.0.qcow2': Permission denied
───────────────────────────┬───┬────────────┬───────────────────────────────────────────
 DOMAIN                    │ ⚡ │ STORAGE    │ SNAPSHOTS
───────────────────────────┼───┼────────────┼───────────────────────────────────────────
 r71                       │ ◌ │ qcow2      │ /home/data/virts/images/r71.qcow2 ←
                           │   │            │ 
 r72                       │ ◌ │ qcow2      │ /home/data/virts/images/r72.qcow2 ←
                           │   │            │ 
 rhel4.5-ss                │ ◌ │ raw image  │ /home/data/virts/images/rhel4.5.qcow2 ←
                           │   │            │ 
 rhel5.10                  │ ◌ │ raw image  │ /home/data/virts/images/rhel5.10.qcow2 ←
                           │   │            │ 
 rhel5.10-sat6             │ ◌ │ qcow2      │ /home/data/virts/images/rhel5.10-sat6.qcow2
                           │   │            │   └─5.10 ─no release set
                           │   │            │ 
 rhel5.11                  │ ◌ │ raw image  │ /home/data/virts/images/rhel5.11.qcow2 ←
                           │   │            │ 
 rhel5.11-sat6             │ ◌ │ qcow2      │ /home/data/virts/images/rhel5.11-sat6.qcow2 ←
                           │   │            │ 
 rhel5.5                   │ ◌ │ qcow2      │ /home/data/virts/images/rhel5.5.qcow2 ←
                           │   │            │ 
 rhel6.5                   │ ◌ │ raw image  │ /home/data/virts/images/rhel6.5.qcow2 ←
                           │   │            │ 
 rhel6.5-sat6              │ ◌ │ qcow2      │ /home/data/virts/images/rhel6.5-sat6.qcow2 ←
                           │   │            │ 
 rhel6.6                   │ ◌ │ raw image  │ /home/data/virts/images/rhel6.6.qcow2 ←

Error in bash substring during `domain_cfgfile_create`

When running valine on a Fedora25 for the first time, I receive, one per each VM in my libvirt:

./valine/valine: riga 330: /var/lib/valine/centos7-prometheus: No such file or directory
./valine/valine: riga 350: /var/lib/valine/centos7-prometheus: No such file or directory
Warning: centos7-prometheus config file has improper CfgVersion ('0Sifr' expected)
Storage displayed for this domain might not be accurate
If this causes problems, delete /var/lib/valine/centos7-prometheus

The error is triggered by the lack of /var/lib/valine , problem is that user do not receive the expected message:

mkdir: impossibile creare la directory "/var/lib/valine": Permission denied
Error: Missing [and unable to create] needed directory '/var/lib/valine'
As root, execute:
  mkdir -pm 2775 /var/lib/valine; chgrp libvirt /var/lib/valine

due to some bash substring mistake.

In attach lvm config and debug output.

valine.zip

move snapshot details out of the main scope (and into per-vm scope)?

What if we moved all the multiline snapshot details from the main valine output and into the per-VM output (e.g., valine SOMEVM) ...?

We could then keep the main valine output to 1 line for each VM ... and we could add mem/cpu limit details -- maybe even including virt-top percentages as mentioned in another issue. I'd love to get some feedback from people on this.

running valine on CentOS 6 gives error: column: invalid option -- 'o'

Hi

Me again :)
Is there something i missing in versions you use for bash/libvirt or there is something incomplete in code.

Just start valine gives me this :

[root@xen2 ~]# valine 
column: invalid option -- 'o'
usage: column [-tx] [-c columns] [file ...]

Key:
  • Each domain's current storage is marked with a green arrow: ←
  • Storage which is revertable & Deletable is displayed in cyan

[root@xen2 ~]# 

I found that column version column i use is util-linux-ng-2.17.2-12.14.el6.x86_64 and there is no option -o. I tried to put to -c insted -o

[root@xen2 ~]# diff myversion.sh bin/valine 
570c570
<         column -t -s "❚" -c " │ " |

---
>         column -t -s "❚" -o " │ " |

and i got this output :

./1.sh: line 319: /var/lib/valine/informix-21-222_4: No such file or directory
./1.sh: line 339: /var/lib/valine/informix-21-222_4: No such file or directory
Warning: informix-21-222_4 config file has improper CfgVersion ('0Sifr' expected)
Storage displayed for this domain might not be accurate
If this causes problems, delete /var/lib/valine/informix-21-222_4
─DOMAIN──────────────⚡──STORAGE───SNAPSHOTS──────────────────────────────────────────
 Domain-0            ◉  unknown    ←
─informix-21-222_4───◉──lvm───────/dev/vmspace/informix-21-222_4─←──────────────────────────────────────────
─privremeno──────────◌──unknown───/backup/systemrescuecd-x86-4.2.0.iso─←──────────────────────────────────────────

Key:
  • Each domain's current storage is marked with a green arrow: ←
  • Storage which is revertable & Deletable is displayed in cyan


Am i doing something wrong or missing prerequisites list somewhere. How to make files /var/lib/valine/* and are they required.

Best Regards
Kenan

show current/max memory & current/max vcpus in main output?

I'm leaning toward yes. E.g., mockup:

─────────┬───┬──────────────┬───────┬─────────┬───────────────────────────────────────────
 DOMAIN  │ ⚡ │ MEMORY       │ VCPU  │ STORAGE │ SNAPSHOTS
─────────┼───┼──────────────┼───────┼─────────┼───────────────────────────────────────────
 r67     │ ◉ │ 2048M        │ 2     │ qcow2   │ /var/lib/upvm/r67.qcow2
         │   │              │       │         │   └─pristine
         │   │              │       │         │       └─webdb
         │   │              │       │         │           └─reg-updated ←
 r72     │ ◉ │ 512M / 2048M │ 1 / 2 │ qcow2   │ /var/lib/upvm/r72.qcow2
         │   │              │       │         │   └─pristine ←
         │   │              │       │         │       └─webdb
         │   │              │       │         │           └─reg-updated
 r511    │ ◉ │ 512M / 2048M │ 1 / 2 │ qcow2   │ /var/lib/upvm/r511.qcow2
         │   │              │       │         │   └─pristine ←
 r49     │ ◌ │ 1024M        │ 1     │ qcow2   │ /var/lib/upvm/r49.qcow2
         │   │              │       │         │   └─pristine ←
 r65     │ ◌ │ 512M / 2048M │ 1 / 2 │ qcow2   │ /var/lib/upvm/r65.qcow2
         │   │              │       │         │   └─pristine
         │   │              │       │         │       └─httpd ←
 r71     │ ◌ │ 512M / 2048M │ 1 / 2 │ qcow2   │ /var/lib/upvm/r71.qcow2 ←
 rhel65  │ ◌ │ 1024M        │ 1     │ lvm     │ /dev/jiop/rhel65
         │   │              │       │         │   └─rhel65-snap0 ←
 tae511  │ ◌ │ 1024M        │ 1     │ qcow2   │ /var/lib/libvirt/images/tae511.qcow2 ←
 tae66   │ ◌ │ 1024M        │ 1     │ qcow2   │ /var/lib/upvm/tae66.qcow2 ←
 tae67   │ ◌ │ 1024M        │ 1     │ qcow2   │ /var/lib/libvirt/images/tae67.qcow2 ←
 z72     │ ◌ │ 1024M        │ 1     │ qcow2   │ /var/lib/upvm/z72.qcow2
         │   │              │       │         │   └─teamd ←
─────────┴───┴──────────────┴───────┴ ────────┴───────────────────────────────────────────

If I do that, then do I need to also integrate NICs and other non-snapshot disks? Probably won't but still ...

add subcommand: loop-ssh

One annoying thing about until ssh HOST; sleep 2; done is that sometimes shutting down a VM will result in the ssh connection being disconnected such that ssh quits with non-zero exit code.

We could save unixtime on each iteration of the loop and break the loop if it's been more than 60sec (or slt) since the last iteration.

valine on Debian VM list issue

I think this should be added as a note in the README. When running valine I received the following error message:

root@helios:~# v
column: invalid option -- 'o'
usage: column [-tx] [-c columns] [-s sep] [file ...]

Key:
  • Each domain's current storage is marked with a green arrow: ←
  • Storage which is revertable & Deletable is displayed in cyan

I'm running Debian 9.

I fixed this by downloading the latest util-linux (at the time of writing it was this - https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.34/ ). Compile then editing .bashrc to include the path to the compiled binaries.

Now it works great:

root@helios:~# v
──────────────────┬────┬──────────┬───────────────────────────────────────────
 DOMAIN           │ ⚡ │ STORAGE  │ SNAPSHOTS
──────────────────┼────┼──────────┼───────────────────────────────────────────
 pilot            │ ◉  │ qcow2    │ /var/lib/libvirt/images/pilot.before-resize-clone.qcow2 ←
 fusionpbx        │ ◉  │ qcow2    │ /var/lib/libvirt/images/fusionpbx.qcow2
                  │    │          │   └─snapshot-beforeupgrade ←
...

I should probably switch to CentOS at some point but 🤷‍♀

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.