30 Commits

Author SHA1 Message Date
Giulio Fidente
bc21b5b140 Clear GPT and MBR headers with dd to avoid sgdisk CRC errors
This change adds a dd before the existing sgdisk -Z command to
workaround CRC verification errors.

Change-Id: Ia1ac4e1c0faf14ad4bb11c2a1c796c93ca8cb5e3
Closes-Bug: #1737556
Story: 1737556
Task: 11496
2018-08-08 16:40:22 +00:00
Olivier Bourdon
5fcf3f066c Fix for fatal error when GPT was used and only MBR was cleaned
You can generate this error if after having provisioned a node
using GPT partitioning, you clean its MBR using say
dd if=/dev/zero bs=1024 count=1 of=/dev/sda
and then cleanup all Ironic/Bifrost informations to get it
reprovisioned.
In this case sgdisk -Z returns an error and last_error field
in Ironic contains:
Error writing image to device: Writing image to device
        /dev/sda failed with exit code 2
Caution: invalid main GPT header, but valid backup;
        regenerating main header\nfrom backup!\n
        \nInvalid partition data!\

Change-Id: Ib617737fff5e40cb376edda0232e0726d9c71231
2018-05-17 12:51:55 +02:00
Lucas Alvares Gomes
449cda4fed Limit memory usage when running qemu-img convert
This patch is limiting the memory address space to 1 GiB when invoking
qemu-img convert. The qemu-img command can be exploited so we better
play on the safe side (See: bug #1449062).

Change-Id: I2088f74b32d1392310c569cfaa7fd368cb737421
Closes-Bug: #1657808
2017-01-19 18:01:30 +00:00
Bharath kumar
9948349b10 Moving Reboot bashscript to python
Currently a reboot bash script file is used to call reboot and
poweroff operation. Deleting this file and moving the code to
python file using utils.execute()

Partial-Bug: #1557542

Change-Id: Iad9cd9d15417e9a954d108d2759e6303452fca27
Author: Bharath kumar <shettybharath4@gmail.com>
Co-Authored-By: Annie Lezil <annie.lezil@gmail.com>
2016-12-15 00:05:03 +00:00
OpenStack Proposal Bot
c40575e4e0 Add bash scripts style checking for IPA
Updated file tox.ini allows to check code style in all ".sh" files
included in Ironic Python Agent. Checking can be invoked by calling either
"tox" or "tox -e pep8".

Change-Id: Ie76605737c7db10a064f2aebfda388372a4c0591
Closes-Bug: #1625215
2016-11-09 14:14:40 -08:00
Shivanand Tendulker
3665306dfb Use ironic-lib to create configdrive
Shell script to create config drive being replaced with python
code in ironic-lib.

Closes-Bug: #1493328

Change-Id: I31108f1173db3fb585386b2949ec880a95305fb6
2016-10-21 03:39:06 +00:00
Vladyslav Drok
7bda3408f5 Fix config drive writing script
When the deployment happens on a GPT disk with config drive, writing
it to disk fails. Three reasons for that:

* parted should be used instead of partprobe to determine the type of
  the disk;
* gdisk -l sorts the partitions by their number, sort them by start
  sector instead;
* after sgdisk completion, the configdrive device is not immediately
  visible in the /dev folder, udevadm settle needed here too.

Closes-Bug: #1633063
Change-Id: Ifed89e343f9db4cf303baf7f8823342f6041f202
2016-10-18 00:28:04 +03:00
Ricardo Araújo Santos
a90ee859a2 Prevent failure on 'copy_configdrive_to_disk.sh'
The script splits 'sfdisk' output wrongly in blank spaces leading to
failures when partition id is greater than 10, e.g.:
"/dev/sda10: start= ...".

This fix splits the output on ":" and trims trailing space when
partition id is less than 10, e.g.: "/dev/sda1 : start= ...".

Change-Id: I23f4b747fc0a86713cb912afc5d193398e6a597b
Closes-Bug: 1581699
2016-05-17 18:09:03 -03:00
Lucas Alvares Gomes
cbd90c1c14 Replace SYSRQ commands
This patch is modifying the shutdown.sh script to not use SYSRQ when
performing power actions. SYSRQ has a similar effect to a hardware reset
button/power switch, which can be problematic after copying an image to
the disk (data loss) therefore, this patch is changing the script to use
soft power action via the poweroff and reboot commands.

SYSRQ was required before because the ironic-python-agent service was
running inside a docker container, but since we've moved it to run into
a chroot (when built with coreos) or on the ramdisk's OS (when built
with DIB) the SYSRQ actions are not needed anymore.

In many parts of Ironic we were considering the standby.{power_off,
reboot} methods of IPA to be soft actions, which they are not at
present. This patch is also fixing that assumption.

Change-Id: Ibe3a3f61a4a0e98b2c2501ad95154839933b4d7a
Closes-Bug: #1557450
2016-03-21 12:57:50 +00:00
Shivanand Tendulker
8f5ed3e2f1 Clear GPT and MBR data structures on disk before imaging
This patch clears all GPT and MBR data structures on the disk.
GPT maintains its data structures at start and at end of the
disk.

Change-Id: I8d0b367755b568cb44f02f62b873659b4bea0f14
Closes-Bug: #1543339
2016-02-09 09:13:07 -08:00
Sam Betts
632c7e6d31 Add tinyipa to IPA imagebuild directory
TinyCoreLinux is a small 10mb base linux distribution which can easily
be built into a ramdisk for PXE and ISO booting. This patch adds scripts
and other required files to build a TinyCore based ramdisk which runs
the Ironic Python Agent.

Change-Id: I79fbec75de19b3d6feb19f87a3a0f662eae42bf3
2016-01-29 12:07:19 +00:00
Yolanda Robla
a01c4c90eb Create partition at max msdos limit for disks > 2TB
Currently there is a problem on partition creation for MBR
case. If disk exceeds 2TB, partition creation fails because
we are hitting max msdos limit. Detect total disk size, and if
it exceeds that limit, create the partition at the end of legal
limits.

Fixes-Bug: #1517077
Change-Id: I11dd3f11eaa6af764151b442768d10289ced6d3f
2015-11-18 10:48:46 +01:00
Shivanand Tendulker
2d341c7f0d Fixes config drive creation failure in UEFI boot mode
This fix enables creation of config drive for UEFI only whole disk
images.
It will not work with the hybrid images that support booting in BIOS
and UEFI boot mode.

Change-Id: Ib4dd8c082a50e1dbaf0df91477b062716cb780ff
Closes-Bug: #1486887
Depends-On: I81400305f166d62aa4612aab54602abb8178b64c
2015-09-23 23:14:46 +00:00
Mathieu Mitchell
63851b72ee Use host_device mode for qemu-img
When writing to a host device, possibly one that does not support holes,
it is preferable to use host_device instead of the raw mode. Not doing so
means holes are simply skipped and the deployed image is invalid.

Change-Id: I24f8b4daf099af8bb03c3a4f6417b6c87bd49021
Closes-Bug: #1466632
2015-06-18 16:00:25 -04:00
Ramakrishnan G
be36ed6903 Add power_off command in standby extension
This commit adds a new command power_off to
standby extension which runs shutdown -h now
on the system. This commit also adds mappings
for /proc and /sys in cloud-config.yml for the
agent service spawned.

Partial-Bug: #1451310
Change-Id: I2a5f984af26bbbe03002bb8c367c8c6af8d91434
2015-06-09 23:44:08 +00:00
Ramakrishnan G
8faa3ae9d5 Make sure sysrq functions are enabled in reboot.sh
This commit echoes '1' to >/proc/sys/kernel/sysrq to
make sure that sysrq functions are enabled before
invoking them.

Change-Id: I88697efbc1bd0dec5ed4cbcd8d89b0b5d0734bdd
2015-06-02 12:41:06 +00:00
Jay Faulkner
79790171bc Call partprobe+partx before writing configdrive
partx -u $DEVICE doesn't work in some cases, but partprobe $DEVICE fails
in virtual environments (like devstack). For now, run both commands and
ignore partprobe failures.

Moving forward, this shell should be factored into python and share code
with the other partition-modifying code added this cycle.

Change-Id: I7e4c010e260be2a23dcc894bc0c1b30aea949084
Partial-bug: 1433812
2015-03-19 11:25:35 -07:00
Jim Rollenhagen
877f66826c Use partx to update partition table
partprobe does not appear to work in virtual machines. Let's find out if
`partx -u` does the same thing and also works on virt.

Change-Id: I4467299a82e728930ac8f99a0ba16d3ea7c6755c
Closes-Bug: #1418833
2015-02-06 13:44:42 -08:00
Mathieu Mitchell
e53e297a5e Write image directly to disk
Write image directly to disk by telling qemu-img that the output
file is the disk. Still uses O_DIRECT directly within qemu-img.

This avoids the need to have a huge amount of system memory to be
able to deploy an image that contains a huge disk.

The only feature left behind by that commit is the 64K block size.

Change-Id: If60bcd82581b2ea76c4acbc3eaa3f317d2ee6590
2014-10-20 10:27:02 -04:00
Jay Faulkner
b43c8c4c4e Fix comments to reflect reality
These comments were left in write_image.sh from the 'teeth-agent' days
when these were split into two scripts. I moved the comment into the
correct script and clarified what it means.

Change-Id: Iccdcd925be5c94d993d8125534264f496de4594f
2014-06-20 15:39:12 -07:00
Jenkins
3cd9d47ba6 Merge "Fix: partitions recently imaged not being detected" 2014-06-16 23:36:34 +00:00
Jenkins
0ca6ae10d5 Merge "Perform manual error checks instead of set -e" 2014-06-16 09:27:45 +00:00
Jay Faulkner
6d9e9e8ba7 Fix incorrect log statement
Logging statement says it's 'imaging' to RAW, when in reality it's a
conversion.

Change-Id: I80d112062f51a6ccc932aeb71ec05042edb09884
2014-06-12 09:21:05 -07:00
Jay Faulkner
d159aec4f0 Fix: partitions recently imaged not being detected
When we have just written out a whole disk image, if we do not run
partprobe none of the new partitions show up in blkid, therefore even
images with a built-in configdrive partition will have one created

Change-Id: I6ec98dc237b42bfe94ce79cf84d155332335c9f6
2014-06-11 16:10:41 -07:00
Jay Faulkner
d82b8c6bc0 Perform manual error checks instead of set -e
When using set -e, if you have a command fail, even when setting a
variable, it causes the node to fail. I have removed set -e and checked
error state where unexpected everywhere. I also added additional
logging.

Closes-Bug: #1326326
Change-Id: I7d2568c3693b9c486672e4322c7f01622aeba875
2014-06-10 08:22:31 -07:00
Jay Faulkner
a7d6865883 Allow configdrive partition to be precreated
This adds support for copying configdrives to disks that already have
partitions enabled and labeled for configdrives. This is neccessary for
supporting configdrives on partitioning schemes we don't support yet
(like GPT) or for some future agent iteration where we create partitions
separately.

Change-Id: Iee5b87d82be08febc495aaef3272ced4f2f32235
2014-06-03 16:52:33 -07:00
Jim Rollenhagen
620f05eb33 Accept new parameters for prepare_image
The parameters sent to `prepare_image` changed in
https://review.openstack.org/#/c/86490/

This patch brings `prepare_image` up to date with that change.
It also changes the way configdrive is written to disk, to match
that Ironic is now allowing Nova to build an ISO partition and
send the raw image to the agent.

This patch also swaps out subprocess.call for processutils.execute
in the standby module, since the commands were being changed anyway.

Lastly, this patch changes the expected `hashes` dict to be a
string parameter called `checksum`, to match what glance returns.

Change-Id: Id8af9be920ba51e7e1ce60f4ffd1477e413582c9
2014-04-24 13:00:24 -07:00
Jim Rollenhagen
3c1d52cbb1 Use # instead of """ for copyright blocks
Reformats copyright messages to be comments rather than
docstring-style blocks.

Change-Id: I4d863f53b67bb49d03bda0952b9e6179b6d23c59
2014-04-10 07:14:06 -07:00
Josh Gachnang
5914e36b30 Replacing teeth/overlord with ipa/ironic 2014-03-19 16:19:52 -07:00
Josh Gachnang
b30d345c2e Renaming to IPA 2014-03-19 15:50:43 -07:00