Statistics
| Branch: | Tag: | Revision:

root / qa / qa_other.py @ 7910e7a5

History | View | Annotate | Download (1.3 kB)

1 c68d1f43 Michael Hanselmann
#
2 c68d1f43 Michael Hanselmann
#
3 c68d1f43 Michael Hanselmann
4 cec9845c Michael Hanselmann
# Copyright (C) 2007 Google Inc.
5 cec9845c Michael Hanselmann
#
6 cec9845c Michael Hanselmann
# This program is free software; you can redistribute it and/or modify
7 cec9845c Michael Hanselmann
# it under the terms of the GNU General Public License as published by
8 cec9845c Michael Hanselmann
# the Free Software Foundation; either version 2 of the License, or
9 cec9845c Michael Hanselmann
# (at your option) any later version.
10 cec9845c Michael Hanselmann
#
11 cec9845c Michael Hanselmann
# This program is distributed in the hope that it will be useful, but
12 cec9845c Michael Hanselmann
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 cec9845c Michael Hanselmann
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 cec9845c Michael Hanselmann
# General Public License for more details.
15 cec9845c Michael Hanselmann
#
16 cec9845c Michael Hanselmann
# You should have received a copy of the GNU General Public License
17 cec9845c Michael Hanselmann
# along with this program; if not, write to the Free Software
18 cec9845c Michael Hanselmann
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 cec9845c Michael Hanselmann
# 02110-1301, USA.
20 cec9845c Michael Hanselmann
21 cec9845c Michael Hanselmann
22 cec9845c Michael Hanselmann
from ganeti import utils
23 cec9845c Michael Hanselmann
from ganeti import constants
24 cec9845c Michael Hanselmann
25 cec9845c Michael Hanselmann
import qa_config
26 cec9845c Michael Hanselmann
import qa_utils
27 cec9845c Michael Hanselmann
28 cec9845c Michael Hanselmann
from qa_utils import AssertEqual, StartSSH
29 cec9845c Michael Hanselmann
30 cec9845c Michael Hanselmann
31 b1ffe1eb Michael Hanselmann
def UploadKnownHostsFile(localpath):
32 cec9845c Michael Hanselmann
  """Uploading known_hosts file.
33 cec9845c Michael Hanselmann

34 cec9845c Michael Hanselmann
  """
35 cec9845c Michael Hanselmann
  master = qa_config.GetMasterNode()
36 cec9845c Michael Hanselmann
37 cec9845c Michael Hanselmann
  tmpfile = qa_utils.UploadFile(master['primary'], localpath)
38 cec9845c Michael Hanselmann
  try:
39 cec9845c Michael Hanselmann
    cmd = ['mv', tmpfile, constants.SSH_KNOWN_HOSTS_FILE]
40 cec9845c Michael Hanselmann
    AssertEqual(StartSSH(master['primary'],
41 cec9845c Michael Hanselmann
                         utils.ShellQuoteArgs(cmd)).wait(), 0)
42 cec9845c Michael Hanselmann
  except:
43 cec9845c Michael Hanselmann
    cmd = ['rm', '-f', tmpfile]
44 cec9845c Michael Hanselmann
    AssertEqual(StartSSH(master['primary'],
45 cec9845c Michael Hanselmann
                utils.ShellQuoteArgs(cmd)).wait(), 0)
46 cec9845c Michael Hanselmann
    raise