Commit 61631293 authored by Stephen Shirley's avatar Stephen Shirley
Browse files

Adding a wrapper around "xm console"



The wrapper will connect to the console, and check in the background if
the instance is paused, unpausing it as necessary.
Signed-off-by: default avatarStephen Shirley <diamond@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 3aa8ed2b
......@@ -477,7 +477,7 @@ nodist_sbin_SCRIPTS = \
$(PYTHON_BOOTSTRAP_SBIN) \
daemons/ganeti-cleaner
dist_tools_SCRIPTS = \
dist_tools_PYTHON = \
tools/burnin \
tools/cfgshell \
tools/cfgupgrade \
......@@ -488,6 +488,10 @@ dist_tools_SCRIPTS = \
tools/setup-ssh \
tools/sanitize-config
dist_tools_SCRIPTS = \
$(dist_tools_PYTHON) \
tools/xm-console-wrapper
pkglib_python_scripts = \
daemons/import-export \
tools/check-cert-expired
......@@ -684,7 +688,7 @@ TESTS_ENVIRONMENT = \
all_python_code = \
$(dist_sbin_SCRIPTS) \
$(dist_tools_SCRIPTS) \
$(dist_tools_PYTHON) \
$(pkglib_python_scripts) \
$(nodist_pkglib_python_scripts) \
$(python_tests) \
......@@ -721,7 +725,7 @@ lint_python_code = \
ganeti \
ganeti/http/server.py \
$(dist_sbin_SCRIPTS) \
$(dist_tools_SCRIPTS) \
$(dist_tools_PYTHON) \
$(pkglib_python_scripts) \
$(BUILD_BASH_COMPLETION) \
$(DOCPP) \
......
......@@ -144,6 +144,7 @@ QUEUE_DIR = DATA_DIR + "/queue"
DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util"
SETUP_SSH = _autoconf.TOOLSDIR + "/setup-ssh"
KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
XM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/xm-console-wrapper"
ETC_HOSTS = "/etc/hosts"
DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR
DEFAULT_SHARED_FILE_STORAGE_DIR = _autoconf.SHARED_FILE_STORAGE_DIR
......
......@@ -307,7 +307,8 @@ class XenHypervisor(hv_base.BaseHypervisor):
kind=constants.CONS_SSH,
host=instance.primary_node,
user=constants.GANETI_RUNAS,
command=["xm", "console", instance.name])
command=[constants.XM_CONSOLE_WRAPPER,
instance.name])
def Verify(self):
"""Verify the hypervisor.
......
#!/bin/bash
# Copyright (C) 2011 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
INSTANCE="$1"
unpause() {
ispaused=$(xm list -l "$INSTANCE" 2>/dev/null |
sed -n 's/^[[:blank:]]*(state ..\(.\)...)/\1/p')
[[ "$ispaused" == "p" ]] || return
# As there is no way to be sure when xm console has actually connected to the
# instance, sleep for a few seconds before unpausing the instance. This is a
# tradeoff between missing some console output if the node is overloaded and
# making the user wait everytime when the node isn't so busy.
sleep 3
# Send \r\n after notice as terminal is in raw mode
printf "Instance $INSTANCE is paused, unpausing\r\n"
xm unpause "$INSTANCE"
}
unpause &
exec xm console "$INSTANCE"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment