Skip to content
Snippets Groups Projects
Commit 033a1d00 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

cmdlib: Add utility for instance data import/export


Interpreting the backend's import/export daemon status is a bit tricky.
This utility code keeps track of multiple transfers at the same time.
Users can supply callback functions to react to events.

Timeouts are currently hardcoded. Intra-cluster instance moves will likely
require other timeouts.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
parent 6b92f2af
No related branches found
No related tags found
No related merge requests found
...@@ -144,7 +144,8 @@ confd_PYTHON = \ ...@@ -144,7 +144,8 @@ confd_PYTHON = \
lib/confd/server.py lib/confd/server.py
masterd_PYTHON = \ masterd_PYTHON = \
lib/masterd/__init__.py lib/masterd/__init__.py \
lib/masterd/instance.py
docrst = \ docrst = \
doc/admin.rst \ doc/admin.rst \
...@@ -345,6 +346,7 @@ python_tests = \ ...@@ -345,6 +346,7 @@ python_tests = \
test/ganeti.http_unittest.py \ test/ganeti.http_unittest.py \
test/ganeti.locking_unittest.py \ test/ganeti.locking_unittest.py \
test/ganeti.luxi_unittest.py \ test/ganeti.luxi_unittest.py \
test/ganeti.masterd.instance_unittest.py \
test/ganeti.mcpu_unittest.py \ test/ganeti.mcpu_unittest.py \
test/ganeti.objects_unittest.py \ test/ganeti.objects_unittest.py \
test/ganeti.opcodes_unittest.py \ test/ganeti.opcodes_unittest.py \
......
...@@ -376,6 +376,8 @@ LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT ...@@ -376,6 +376,8 @@ LVM_STRIPECOUNT = _autoconf.LVM_STRIPECOUNT
# default maximum instance wait time, in seconds. # default maximum instance wait time, in seconds.
DEFAULT_SHUTDOWN_TIMEOUT = 120 DEFAULT_SHUTDOWN_TIMEOUT = 120
NODE_MAX_CLOCK_SKEW = 150 NODE_MAX_CLOCK_SKEW = 150
# Time for an intra-cluster disk transfer to wait for a connection
DISK_TRANSFER_CONNECT_TIMEOUT = 30
# runparts results # runparts results
(RUNPARTS_SKIP, (RUNPARTS_SKIP,
......
This diff is collapsed.
#!/usr/bin/python
#
# Copyright (C) 2010 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.
"""Script for testing ganeti.masterd.instance"""
import os
import sys
import unittest
from ganeti import utils
from ganeti import masterd
from ganeti.masterd.instance import \
ImportExportTimeouts, _TimeoutExpired, _DiskImportExportBase
import testutils
class TestMisc(unittest.TestCase):
def testTimeouts(self):
tmo = ImportExportTimeouts(0)
self.assertEqual(tmo.connect, 0)
self.assertEqual(tmo.listen, ImportExportTimeouts.DEFAULT_LISTEN_TIMEOUT)
self.assertEqual(tmo.ready, ImportExportTimeouts.DEFAULT_READY_TIMEOUT)
self.assertEqual(tmo.error, ImportExportTimeouts.DEFAULT_ERROR_TIMEOUT)
tmo = ImportExportTimeouts(999)
self.assertEqual(tmo.connect, 999)
def testTimeoutExpired(self):
self.assert_(_TimeoutExpired(100, 300, _time_fn=lambda: 500))
self.assertFalse(_TimeoutExpired(100, 300, _time_fn=lambda: 0))
self.assertFalse(_TimeoutExpired(100, 300, _time_fn=lambda: 100))
self.assertFalse(_TimeoutExpired(100, 300, _time_fn=lambda: 400))
def testDiskImportExportBaseDirect(self):
self.assertRaises(AssertionError, _DiskImportExportBase,
None, None, None, None, None, None, None)
if __name__ == "__main__":
testutils.GanetiTestProgram()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment