summaryrefslogtreecommitdiff
path: root/ironic_python_agent/extensions/iscsi.py
diff options
context:
space:
mode:
authorGonéri Le Bouder <goneri@redhat.com>2016-02-24 13:39:33 -0500
committerGonéri Le Bouder <goneri@redhat.com>2016-03-22 13:28:21 -0400
commit0b1f01db9474fb7630d616fab4711fefaea2bce0 (patch)
tree7442f1fbe852d9c50ce0394a393ff9487db11f81 /ironic_python_agent/extensions/iscsi.py
parent2a778f39e6151a94340c14dd012b30b9ffc52a1e (diff)
downloadironic-python-agent-0b1f01db9474fb7630d616fab4711fefaea2bce0.tar.gz
iscsi: wipe part table before starting the target
If the local disk has already a partition table, it must be clean up before the disk is exposed through iscsi. Otherwise this disk partition can create a conflict during the grub installation. How reproducible: 1. Inject an image on the root disk, like for example ipxe.usb or ipxe.iso 2. Try to deploy a system on the node using Ironic 3. The node is properly deployed but the grub installation has failed with the following error: attempting to install grub to a disk with multiple partition labels A simple sgdisk -Z /dev/vdX is not enough because grub-install will inspect the disk and will still detect a remaining partition. This commit makes use of the ironic-lib to do the clean up of the disk. The additional review Id59fa5a06b9115c0f9afc09aae95daaac97e2fac increase the amount of data to wipe. References: https://bugzilla.redhat.com/show_bug.cgi?id=1310883 Partial-Bug: 1550604 Change-Id: Ie68cb6296c782e904d40f6e9de0faa52ab2af2bf
Diffstat (limited to 'ironic_python_agent/extensions/iscsi.py')
-rw-r--r--ironic_python_agent/extensions/iscsi.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/ironic_python_agent/extensions/iscsi.py b/ironic_python_agent/extensions/iscsi.py
index 24292227..288e6a2f 100644
--- a/ironic_python_agent/extensions/iscsi.py
+++ b/ironic_python_agent/extensions/iscsi.py
@@ -16,6 +16,7 @@
# under the License.
+from ironic_lib import disk_utils
from oslo_concurrency import processutils
from oslo_log import log
from oslo_utils import uuidutils
@@ -136,13 +137,23 @@ def clean_up(device):
class ISCSIExtension(base.BaseAgentExtension):
@base.sync_command('start_iscsi_target')
- def start_iscsi_target(self, iqn=None):
- """Expose the disk as an ISCSI target."""
+ def start_iscsi_target(self, iqn=None, wipe_disk_metadata=False):
+ """Expose the disk as an ISCSI target.
+
+ :param wipe_disk_metadata: if the disk metadata should be wiped out
+ before the disk is exposed.
+ """
# If iqn is not given, generate one
if iqn is None:
iqn = 'iqn.2008-10.org.openstack:%s' % uuidutils.generate_uuid()
device = hardware.dispatch_to_managers('get_os_install_device')
+
+ if wipe_disk_metadata:
+ disk_utils.destroy_disk_metadata(
+ device,
+ self.agent.get_node_uuid())
+
LOG.debug("Starting ISCSI target with iqn %(iqn)s on device "
"%(device)s", {'iqn': iqn, 'device': device})