Commit 249069a1 authored by Iustin Pop's avatar Iustin Pop
Browse files

Remove the add/remove mirror operations

These two operations are related to md/drbd7 code (remote_raid1). Remove
them as part of the md/drbd7 removal.

Reviewed-by: imsnah
parent 2872a949
......@@ -3203,207 +3203,6 @@ class LUConnectConsole(NoHooksLU):
return cmd[0], cmd
class LUAddMDDRBDComponent(LogicalUnit):
"""Adda new mirror member to an instance's disk.
"""
HPATH = "mirror-add"
HTYPE = constants.HTYPE_INSTANCE
_OP_REQP = ["instance_name", "remote_node", "disk_name"]
def BuildHooksEnv(self):
"""Build hooks env.
This runs on the master, the primary and all the secondaries.
"""
env = {
"NEW_SECONDARY": self.op.remote_node,
"DISK_NAME": self.op.disk_name,
}
env.update(_BuildInstanceHookEnvByObject(self.instance))
nl = [self.sstore.GetMasterNode(), self.instance.primary_node,
self.op.remote_node,] + list(self.instance.secondary_nodes)
return env, nl, nl
def CheckPrereq(self):
"""Check prerequisites.
This checks that the instance is in the cluster.
"""
instance = self.cfg.GetInstanceInfo(
self.cfg.ExpandInstanceName(self.op.instance_name))
if instance is None:
raise errors.OpPrereqError("Instance '%s' not known" %
self.op.instance_name)
self.instance = instance
remote_node = self.cfg.ExpandNodeName(self.op.remote_node)
if remote_node is None:
raise errors.OpPrereqError("Node '%s' not known" % self.op.remote_node)
self.remote_node = remote_node
if remote_node == instance.primary_node:
raise errors.OpPrereqError("The specified node is the primary node of"
" the instance.")
if instance.disk_template != constants.DT_REMOTE_RAID1:
raise errors.OpPrereqError("Instance's disk layout is not"
" remote_raid1.")
for disk in instance.disks:
if disk.iv_name == self.op.disk_name:
break
else:
raise errors.OpPrereqError("Can't find this device ('%s') in the"
" instance." % self.op.disk_name)
if len(disk.children) > 1:
raise errors.OpPrereqError("The device already has two slave devices."
" This would create a 3-disk raid1 which we"
" don't allow.")
self.disk = disk
def Exec(self, feedback_fn):
"""Add the mirror component
"""
disk = self.disk
instance = self.instance
remote_node = self.remote_node
lv_names = [".%s_%s" % (disk.iv_name, suf) for suf in ["data", "meta"]]
names = _GenerateUniqueNames(self.cfg, lv_names)
new_drbd = _GenerateMDDRBDBranch(self.cfg, instance.primary_node,
remote_node, disk.size, names)
logger.Info("adding new mirror component on secondary")
#HARDCODE
if not _CreateBlockDevOnSecondary(self.cfg, remote_node, instance,
new_drbd, False,
_GetInstanceInfoText(instance)):
raise errors.OpExecError("Failed to create new component on secondary"
" node %s" % remote_node)
logger.Info("adding new mirror component on primary")
#HARDCODE
if not _CreateBlockDevOnPrimary(self.cfg, instance.primary_node,
instance, new_drbd,
_GetInstanceInfoText(instance)):
# remove secondary dev
self.cfg.SetDiskID(new_drbd, remote_node)
rpc.call_blockdev_remove(remote_node, new_drbd)
raise errors.OpExecError("Failed to create volume on primary")
# the device exists now
# call the primary node to add the mirror to md
logger.Info("adding new mirror component to md")
if not rpc.call_blockdev_addchildren(instance.primary_node,
disk, [new_drbd]):
logger.Error("Can't add mirror compoment to md!")
self.cfg.SetDiskID(new_drbd, remote_node)
if not rpc.call_blockdev_remove(remote_node, new_drbd):
logger.Error("Can't rollback on secondary")
self.cfg.SetDiskID(new_drbd, instance.primary_node)
if not rpc.call_blockdev_remove(instance.primary_node, new_drbd):
logger.Error("Can't rollback on primary")
raise errors.OpExecError("Can't add mirror component to md array")
disk.children.append(new_drbd)
self.cfg.AddInstance(instance)
_WaitForSync(self.cfg, instance, self.proc)
return 0
class LURemoveMDDRBDComponent(LogicalUnit):
"""Remove a component from a remote_raid1 disk.
"""
HPATH = "mirror-remove"
HTYPE = constants.HTYPE_INSTANCE
_OP_REQP = ["instance_name", "disk_name", "disk_id"]
def BuildHooksEnv(self):
"""Build hooks env.
This runs on the master, the primary and all the secondaries.
"""
env = {
"DISK_NAME": self.op.disk_name,
"DISK_ID": self.op.disk_id,
"OLD_SECONDARY": self.old_secondary,
}
env.update(_BuildInstanceHookEnvByObject(self.instance))
nl = [self.sstore.GetMasterNode(),
self.instance.primary_node] + list(self.instance.secondary_nodes)
return env, nl, nl
def CheckPrereq(self):
"""Check prerequisites.
This checks that the instance is in the cluster.
"""
instance = self.cfg.GetInstanceInfo(
self.cfg.ExpandInstanceName(self.op.instance_name))
if instance is None:
raise errors.OpPrereqError("Instance '%s' not known" %
self.op.instance_name)
self.instance = instance
if instance.disk_template != constants.DT_REMOTE_RAID1:
raise errors.OpPrereqError("Instance's disk layout is not"
" remote_raid1.")
for disk in instance.disks:
if disk.iv_name == self.op.disk_name:
break
else:
raise errors.OpPrereqError("Can't find this device ('%s') in the"
" instance." % self.op.disk_name)
for child in disk.children:
if (child.dev_type == constants.LD_DRBD7 and
child.logical_id[2] == self.op.disk_id):
break
else:
raise errors.OpPrereqError("Can't find the device with this port.")
if len(disk.children) < 2:
raise errors.OpPrereqError("Cannot remove the last component from"
" a mirror.")
self.disk = disk
self.child = child
if self.child.logical_id[0] == instance.primary_node:
oid = 1
else:
oid = 0
self.old_secondary = self.child.logical_id[oid]
def Exec(self, feedback_fn):
"""Remove the mirror component
"""
instance = self.instance
disk = self.disk
child = self.child
logger.Info("remove mirror component")
self.cfg.SetDiskID(disk, instance.primary_node)
if not rpc.call_blockdev_removechildren(instance.primary_node,
disk, [child]):
raise errors.OpExecError("Can't remove child from mirror.")
for node in child.logical_id[:2]:
self.cfg.SetDiskID(child, node)
if not rpc.call_blockdev_remove(node, child):
logger.Error("Warning: failed to remove device from node %s,"
" continuing operation." % node)
disk.children.remove(child)
self.cfg.AddInstance(instance)
class LUReplaceDisks(LogicalUnit):
"""Replace the disks of an instance.
......
......@@ -68,8 +68,6 @@ class Processor(object):
opcodes.OpStartupInstance: cmdlib.LUStartupInstance,
opcodes.OpRebootInstance: cmdlib.LURebootInstance,
opcodes.OpDeactivateInstanceDisks: cmdlib.LUDeactivateInstanceDisks,
opcodes.OpAddMDDRBDComponent: cmdlib.LUAddMDDRBDComponent,
opcodes.OpRemoveMDDRBDComponent: cmdlib.LURemoveMDDRBDComponent,
opcodes.OpReplaceDisks: cmdlib.LUReplaceDisks,
opcodes.OpFailoverInstance: cmdlib.LUFailoverInstance,
opcodes.OpConnectConsole: cmdlib.LUConnectConsole,
......
......@@ -301,18 +301,6 @@ class OpRebootInstance(OpCode):
"ignore_secondaries" ]
class OpAddMDDRBDComponent(OpCode):
"""Add a MD-DRBD component."""
OP_ID = "OP_INSTANCE_ADD_MDDRBD"
__slots__ = ["instance_name", "remote_node", "disk_name"]
class OpRemoveMDDRBDComponent(OpCode):
"""Remove a MD-DRBD component."""
OP_ID = "OP_INSTANCE_REMOVE_MDDRBD"
__slots__ = ["instance_name", "disk_name", "disk_id"]
class OpReplaceDisks(OpCode):
"""Replace the disks of an instance."""
OP_ID = "OP_INSTANCE_REPLACE_DISKS"
......
......@@ -895,46 +895,6 @@
</refsect3>
<refsect3>
<title>ADD-MIRROR</title>
<cmdsynopsis>
<command>add-mirror</command>
<arg choice="req">-b <replaceable>sdX</replaceable></arg>
<arg choice="req">-n <replaceable>node</replaceable></arg>
<arg choice="req"><replaceable>instance</replaceable></arg>
</cmdsynopsis>
<para>
Adds a new mirror to the disk layout of the instance, if the
instance has a remote raid disk layout.
The new mirror member will be between the instance's primary
node and the node given with the <option>-n</option> option.
</para>
</refsect3>
<refsect3>
<title>REMOVE-MIRROR</title>
<cmdsynopsis>
<command>removemirror</command>
<arg choice="req">-b <replaceable>sdX</replaceable></arg>
<arg choice="req">-p <replaceable>id</replaceable></arg>
<arg choice="req"><replaceable>instance</replaceable></arg>
</cmdsynopsis>
<para>
Removes a mirror componenent from the disk layout of the
instance, if the instance has a remote raid disk layout.
</para>
<para>
You need to specifiy on which disk to act on using the
<option>-b</option> option (either <filename>sda</filename>
or <filename>sdb</filename>) and the mirror component, which
is identified by the <option>-p</option> option. You can
find the list of valid identifiers with the
<command>info</command> command.
</para>
<refsect3>
<title>ACTIVATE-DISKS</title>
......
......@@ -435,36 +435,6 @@ def ShutdownInstance(opts, args):
return 0
def AddMDDRBDComponent(opts, args):
"""Add a new component to a remote_raid1 disk.
Args:
opts - class with options as members
args - list with a single element, the instance name
"""
op = opcodes.OpAddMDDRBDComponent(instance_name=args[0],
disk_name=opts.disk,
remote_node=opts.node)
SubmitOpCode(op)
return 0
def RemoveMDDRBDComponent(opts, args):
"""Remove a component from a remote_raid1 disk.
Args:
opts - class with options as members
args - list with a single element, the instance name
"""
op = opcodes.OpRemoveMDDRBDComponent(instance_name=args[0],
disk_name=opts.disk,
disk_id=opts.port)
SubmitOpCode(op)
return 0
def ReplaceDisks(opts, args):
"""Replace the disks of an instance
......@@ -792,13 +762,6 @@ commands = {
'add': (AddInstance, ARGS_ONE, add_opts,
"[opts...] <name>",
"Creates and adds a new instance to the cluster"),
'add-mirror': (AddMDDRBDComponent, ARGS_ONE,
[DEBUG_OPT, node_opt,
make_option("-b", "--disk", dest="disk", metavar="sdX",
help=("The name of the instance disk for which to"
" add the mirror"))],
"-n node -b disk <instance>",
"Creates a new mirror for the instance"),
'console': (ConnectToInstanceConsole, ARGS_ONE, [DEBUG_OPT],
"<instance>",
"Opens a console on the specified instance"),
......@@ -833,18 +796,6 @@ commands = {
" process (shutdown, disk removal, etc.)")),
],
"[-f] <instance>", "Shuts down the instance and removes it"),
'remove-mirror': (RemoveMDDRBDComponent, ARGS_ONE,
[DEBUG_OPT, node_opt,
make_option("-b", "--disk", dest="disk", metavar="sdX",
help=("The name of the instance disk"
" for which to add the mirror")),
make_option("-p", "--port", dest="port", metavar="PORT",
help=("The port of the drbd device"
" which to remove from the mirror"),
type="int"),
],
"-b disk -p port <instance>",
"Removes a mirror from the instance"),
'rename': (RenameInstance, ARGS_FIXED(2),
[DEBUG_OPT,
make_option("--no-ip-check", dest="ignore_ip",
......
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