From: Janne Suominen Date: Tue, 21 May 2019 05:28:05 +0000 (+0300) Subject: Fix problem with installation X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ta%2Fipa-deployer.git;a=commitdiff_plain;h=d2b4155172229c89dfeb559948ed214bcf4d77cc Fix problem with installation The erasing is done also for loop devices which is wrong. Now also skipping the procedure in virtual environment since the disks are always empty. Change-Id: Iac6dabb3f4ea6d2fae2cb72f9c4edea71453e97f Signed-off-by: Janne Suominen --- diff --git a/work/dib-ipa-element/virtmedia-netconf/ironic-virtmedia-netconfig/bin/erase-oldfs.sh b/work/dib-ipa-element/virtmedia-netconf/ironic-virtmedia-netconfig/bin/erase-oldfs.sh index 006963e..0b65e7f 100755 --- a/work/dib-ipa-element/virtmedia-netconf/ironic-virtmedia-netconfig/bin/erase-oldfs.sh +++ b/work/dib-ipa-element/virtmedia-netconf/ironic-virtmedia-netconfig/bin/erase-oldfs.sh @@ -16,41 +16,55 @@ SYS_BLOCK="/sys/class/block" -function is_partition(){ - device=$1 - if [ -e $SYS_BLOCK/$device/partition ];then - return 0 - else - return 1 - fi -} - -function is_removable(){ - device=$1 - sysdev=$SYS_BLOCK/$device - if ( is_partition $device );then - removable=$(readlink -f $sysdev/..)/removable - else - removable=$sysdev/removable - fi - if [ -e $removable ] && [ $(cat $removable) -eq 1 ];then - return 0 - else +if ( grep -q "^flags.*hypervisor" /proc/cpuinfo ); then + echo "Not excuting in Virtual machine" +else + function is_partition(){ + device=$1 + if [ -e $SYS_BLOCK/$device/partition ];then + return 0 + else + return 1 + fi + } + + function is_removable(){ + device=$1 + sysdev=$SYS_BLOCK/$device + if ( is_partition $device );then + removable=$(readlink -f $sysdev/..)/removable + else + removable=$sysdev/removable + fi + if [ -e $removable ] && [ $(cat $removable) -eq 1 ];then + return 0 + else + return 1 + fi + + } + + function is_loop(){ + device=$1 + if [ -e $SYS_BLOCK/$device/loop ]; then + return 0 + fi return 1 - fi + } -} -device_list=$(ls $SYS_BLOCK) -read -r -a hd_devices <<< $device_list + device_list=$(ls $SYS_BLOCK) + read -r -a hd_devices <<< $device_list -for hd_dev in ${hd_devices[@]}; do - if [ -b /dev/$hd_dev ] && (( is_removable $hd_dev ) || ( is_partition $hd_dev )); then - echo "Removable or partition $hd_dev. Skipping..." - continue - fi - wipefs --all /dev/$hd_dev - sgdisk -Z -o /dev/$hd_dev - dd if=/dev/zero of=/dev/$hd_dev bs=1M count=200 -done + for hd_dev in ${hd_devices[@]}; do + if [ -b /dev/$hd_dev ] && (( is_removable $hd_dev ) || ( is_partition $hd_dev ) || ( is_loop $hd_dev )); then + echo "Removable or partition $hd_dev. Skipping..." + continue + fi + wipefs --all /dev/$hd_dev + sgdisk -Z -o /dev/$hd_dev + dd if=/dev/zero of=/dev/$hd_dev bs=1M count=200 + done + partprobe +fi diff --git a/work/dib-ipa-element/virtmedia-netconf/ironic-virtmedia-netconfig/src/virtmedia_netconfig/main.py b/work/dib-ipa-element/virtmedia-netconf/ironic-virtmedia-netconfig/src/virtmedia_netconfig/main.py index 06cfb04..03f95b9 100644 --- a/work/dib-ipa-element/virtmedia-netconf/ironic-virtmedia-netconfig/src/virtmedia_netconfig/main.py +++ b/work/dib-ipa-element/virtmedia-netconf/ironic-virtmedia-netconfig/src/virtmedia_netconfig/main.py @@ -342,6 +342,9 @@ def main(): # in a text file within the virtual media floppy. if params.get('boot_method') == 'vmedia': + LOG.debug("Erasing old filesystems") + utils.execute('/usr/bin/erase-oldfs.sh') + LOG.info("This node is booted with vmedia. Checking for available virtual media!!") wait_for_cd_device() check_cd_config() @@ -353,8 +356,6 @@ def main(): if os_net_config: _configure_static_net(os_net_config) - LOG.debug("Erasing old filesystems") - utils.execute('/usr/bin/erase-oldfs.sh') if __name__ == "__main__":