From 6c0c602ea1dd4773291b85be13a84be7095cf44e Mon Sep 17 00:00:00 2001 From: Daniel STAN Date: Fri, 29 Nov 2013 19:30:51 +0100 Subject: [PATCH] proxmox: script pour console serie --- gestion/virtualisation/connect-qm | 55 +++++++++++++++++++++++++++++++ gestion/virtualisation/manage.py | 5 --- 2 files changed, 55 insertions(+), 5 deletions(-) create mode 100755 gestion/virtualisation/connect-qm delete mode 100644 gestion/virtualisation/manage.py diff --git a/gestion/virtualisation/connect-qm b/gestion/virtualisation/connect-qm new file mode 100755 index 00000000..1fe23a83 --- /dev/null +++ b/gestion/virtualisation/connect-qm @@ -0,0 +1,55 @@ +#!/bin/bash + +VM_PATH=/etc/pve/qemu-server +PVE_PATH=/etc/pve +LOCAL_VM_PATH=/etc/pve/local/qemu-server +SERIAL_PATH=/var/run/qemu-server + +if [[ ! -d /etc/pve ]]; then + echo "Not a proxmox server !" + exit 1 +fi + +if [[ -z "$1" ]]; then + echo "Please give vmid or pve name" + exit 5 +fi + +if [[ "`whoami`" != "root" ]]; then + echo "You must probably be root" + exit 42 +fi + +if [[ $1 != *[!0-9]* ]]; then + vmid=$1 +else + echo "Looking for vmid of $1 ..." + for host in `ls $PVE_PATH/nodes`; do + p=$PVE_PATH/nodes/$host/qemu-server + for f in `ls $p`; do + grep "name: *$1" $p/$f -q && { + vmid=`echo $f | grep -o "[0-9]*"` + node=$host + echo "Found vmid $vmid" + break + } + done + done + if [[ -z "$node" ]]; then + echo "vmid not found" + exit 2 + elif [[ "$node" != "`hostname`" ]]; then + echo "Wrong node (go to $node)" + exit 3 + fi +fi +shift + +device=$SERIAL_PATH/$vmid.serial + +if [[ ! -S $device ]]; then + echo "$device missing (vm misconfigured or shutdown ?)" + exit 4 +fi + +minicom -D unix#$device "$@" diff --git a/gestion/virtualisation/manage.py b/gestion/virtualisation/manage.py deleted file mode 100644 index f4668289..00000000 --- a/gestion/virtualisation/manage.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python -# -*- coding:utf-8 -*- -# -# High level interface between XEN -# and XEN user