개선 #12946 » rename.sh
| 1 |
#!/bin/bash
|
|---|---|
| 2 |
|
| 3 |
if [ "$#" -ne 4 ]; then |
| 4 |
echo "Usage: $0 <IP> <VG> <OLD> <NEW>" |
| 5 |
exit 1
|
| 6 |
fi
|
| 7 |
|
| 8 |
IP="$1" |
| 9 |
VG="$2" |
| 10 |
OLD="$3" |
| 11 |
NEW="$4" |
| 12 |
|
| 13 |
TOKEN=$(< /tmp/api_token) |
| 14 |
|
| 15 |
if [ $TOKEN == '' ]; then |
| 16 |
echo "Please get api token" |
| 17 |
echo 1
|
| 18 |
fi
|
| 19 |
|
| 20 |
echo "Rename LV:" |
| 21 |
|
| 22 |
curl -X PUT \ |
| 23 |
-H "Authorization: Bearer $TOKEN" \ |
| 24 |
-H "Content-Type: application/json" \ |
| 25 |
-d "{ \"entity\": { \"memberOf\":\"$VG\", \"newName\":\"$NEW\"}}" \ |
| 26 |
http://$IP/api/lvm/lvs/$OLD/rename |
| 27 |
|
| 28 |
echo "DONE" |