summaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/openstack/cinder/write_data.sh
blob: 70f8275f165f85ad976204ba47e8704a55d90451 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh -e

# Copyright (c) 2018 Enea AB and others

# This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
#
# http://www.apache.org/licenses/LICENSE-2.0

DEST=$(mktemp -d)
VOL_DEV_NAME="$(lsblk -l -o NAME | grep -o "vdc\|sdc\b")"

echo "VOL_DEV_NAME: $VOL_DEV_NAME"

if [ ! -z $VOL_DEV_NAME ]; then
    sudo /usr/sbin/mkfs.ext4 -F /dev/$VOL_DEV_NAME
    sudo mount /dev/$VOL_DEV_NAME $DEST
    sudo touch $DEST/new_data
    if [ -f $DEST/new_data ]; then
        echo "New data added to the volume!"
        sudo umount $DEST
    fi
else
    echo "Failed to write data!"
    exit 1
fi