Commit 22b7f6f8 authored by Thomas Thrainer's avatar Thomas Thrainer

Extract instance related logical units from cmdlib

All LUInstance* classes are extracted to instance.py. Common functions
are moved to common.py if used by non-instance logical units as well.
Additionally, helper functions which are only used by LUBackup* and
LUInstance* are moved to instance_utils.py.
Signed-off-by: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarBernardo Dal Seno <bdalseno@google.com>
parent 31b836b8
......@@ -314,6 +314,8 @@ cmdlib_PYTHON = \
lib/cmdlib/cluster.py \
lib/cmdlib/group.py \
lib/cmdlib/node.py \
lib/cmdlib/instance.py \
lib/cmdlib/instance_utils.py \
lib/cmdlib/tags.py \
lib/cmdlib/network.py \
lib/cmdlib/test.py
......
This diff is collapsed.
......@@ -1002,8 +1002,9 @@ def _FindFaultyInstanceDisks(cfg, rpc_runner, instance, node_name, prereq):
for dev in instance.disks:
cfg.SetDiskID(dev, node_name)
result = rpc_runner.call_blockdev_getmirrorstatus(node_name, (instance.disks,
instance))
result = rpc_runner.call_blockdev_getmirrorstatus(node_name,
(instance.disks,
instance))
result.Raise("Failed to get disk status from node %s" % node_name,
prereq=prereq, ecode=errors.ECODE_ENVIRON)
......@@ -1012,3 +1013,18 @@ def _FindFaultyInstanceDisks(cfg, rpc_runner, instance, node_name, prereq):
faulty.append(idx)
return faulty
def _CheckNodeOnline(lu, node, msg=None):
"""Ensure that a given node is online.
@param lu: the LU on behalf of which we make the check
@param node: the node to check
@param msg: if passed, should be a message to replace the default one
@raise errors.OpPrereqError: if the node is offline
"""
if msg is None:
msg = "Can't use offline node"
if lu.cfg.GetNodeInfo(node).offline:
raise errors.OpPrereqError("%s: %s" % (msg, node), errors.ECODE_STATE)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -24,12 +24,8 @@
import unittest
import os
import time
import tempfile
import os.path
import socket
import operator
import itertools
from ganeti import bootstrap
from ganeti import config
......@@ -39,7 +35,7 @@ from ganeti import objects
from ganeti import utils
from ganeti import netutils
from ganeti import compat
from ganeti import cmdlib
from ganeti.cmdlib import instance
from ganeti.config import TemporaryReservationManager
......@@ -614,7 +610,7 @@ class TestCheckInstanceDiskIvNames(unittest.TestCase):
def testNoError(self):
disks = self._MakeDisks(["disk/0", "disk/1"])
self.assertEqual(config._CheckInstanceDiskIvNames(disks), [])
cmdlib._UpdateIvNames(0, disks)
instance._UpdateIvNames(0, disks)
self.assertEqual(config._CheckInstanceDiskIvNames(disks), [])
def testWrongNames(self):
......@@ -625,7 +621,7 @@ class TestCheckInstanceDiskIvNames(unittest.TestCase):
])
# Fix names
cmdlib._UpdateIvNames(0, disks)
instance._UpdateIvNames(0, disks)
self.assertEqual(config._CheckInstanceDiskIvNames(disks), [])
......
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