summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcarey.xu <carey.xuhan@huawei.com>2015-10-26 23:47:19 +0800
committercarey.xu <carey.xuhan@huawei.com>2015-10-27 17:07:08 +0800
commitdcd8ebd9d8da04c91650f596ae78f92115f8a97b (patch)
tree6e8d86d9dbfa86e094b3303c1845fbcc06b48e9c
parent4d2673fbf7dc77113309c2ce50eaa2b850c7825e (diff)
cinder volume space is too small
JIRA: COMPASS-116 Change-Id: I26553b6e56bbe46138e8dec4ee3af1aed7093bc4 Signed-off-by: carey.xu <carey.xuhan@huawei.com>
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/files/create_img.sh3
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/files/get_var_size.sh6
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/files/losetup.sh7
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/tasks/loop.yml20
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml40
-rw-r--r--deploy/adapters/ansible/roles/cinder-volume/tasks/real.yml10
6 files changed, 51 insertions, 35 deletions
diff --git a/deploy/adapters/ansible/roles/cinder-volume/files/create_img.sh b/deploy/adapters/ansible/roles/cinder-volume/files/create_img.sh
new file mode 100644
index 00000000..b69db0ed
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/files/create_img.sh
@@ -0,0 +1,3 @@
+if [[ ! -f /var/cinder.img ]]; then
+ dd if=/dev/zero of=/var/cinder.img bs=1 count=1 seek=$1
+fi
diff --git a/deploy/adapters/ansible/roles/cinder-volume/files/get_var_size.sh b/deploy/adapters/ansible/roles/cinder-volume/files/get_var_size.sh
new file mode 100644
index 00000000..9670da12
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/files/get_var_size.sh
@@ -0,0 +1,6 @@
+size=`df /var | awk '$3 ~ /[0-9]+/ { print $4 }'`;
+if [[ $size -gt 2000000000 ]]; then
+ echo -n 2000000000000;
+else
+ echo -n $((size * 1000));
+fi
diff --git a/deploy/adapters/ansible/roles/cinder-volume/files/losetup.sh b/deploy/adapters/ansible/roles/cinder-volume/files/losetup.sh
new file mode 100644
index 00000000..d0e6c776
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/files/losetup.sh
@@ -0,0 +1,7 @@
+loop_dev=`losetup -a |grep "/var/cinder.img"|awk -F':' '{print $1}'`
+if [[ -z $loop_dev ]]; then
+ losetup -f --show /var/cinder.img
+else
+ echo $loop_dev
+fi
+
diff --git a/deploy/adapters/ansible/roles/cinder-volume/tasks/loop.yml b/deploy/adapters/ansible/roles/cinder-volume/tasks/loop.yml
new file mode 100644
index 00000000..b44253c4
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/tasks/loop.yml
@@ -0,0 +1,20 @@
+---
+- include_vars: "{{ ansible_os_family }}.yml"
+
+- name: get available /var partition size
+ script: get_var_size.sh
+ register: part_size
+
+- name: create cinder file if not exitst
+ script: create_img.sh {{ part_size.stdout }}
+
+- name: do a losetup on /mnt/cinder-volumes
+ script: losetup.sh
+ register: loop_device
+
+- name: debug loop device
+ debug: msg={{ loop_device.stdout }}
+
+- name: create physical and group volumes
+ lvg: vg=cinder-volumes pvs={{ loop_device.stdout }}
+ vg_options=--force
diff --git a/deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml b/deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml
index b64024da..a258a0cf 100644
--- a/deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml
+++ b/deploy/adapters/ansible/roles/cinder-volume/tasks/main.yml
@@ -13,43 +13,13 @@
stat: path={{ physical_device }}
register: status
-- name: replace physical_device if st is false
- local_action: copy src=loop.yml dest=/tmp/loop.yml
- when: status.stat.exists == False
-
- name: load loop.yml
- include_vars: /tmp/loop.yml
- when: status.stat.exists == False
-
-- name: check if cinder-volumes is mounted
- shell: ls /mnt
- register: cindervolumes
-
-- name: get available partition size
- shell: df / | awk '$3 ~ /[0-9]+/ { print $4 }'
- register: partition_size
-
-- name: if not mounted, mount it
- shell: dd if=/dev/zero of=/mnt/cinder-volumes
- bs=1 count=0 seek={{ partition_size.stdout }}
- when: cindervolumes.stdout != 'cinder-volumes'
-
-- name: get first lo device
- shell: losetup -f
- register: first_lo
- when: cindervolumes.stdout != 'cinder-volumes'
-
-- name: do a losetup on /mnt/cinder-volumes
- shell: losetup {{ first_lo.stdout }} /mnt/cinder-volumes
- when: cindervolumes.stdout != 'cinder-volumes'
-
-- name: destroy GPT lable
- shell: dd if=/dev/urandom of=/dev/sdb bs=4M count=1
- ignore_errors: True
+ include: loop.yml
+ when: status.stat.isblk == False
-- name: create physical and group volumes
- lvg: vg=cinder-volumes pvs={{ physical_device }}
- vg_options=--force
+- name: load real.yml
+ include: real.yml
+ when: status.stat.isblk == True
- name: upload cinder-volume configuration
template: src=cinder.conf dest=/etc/cinder/cinder.conf
diff --git a/deploy/adapters/ansible/roles/cinder-volume/tasks/real.yml b/deploy/adapters/ansible/roles/cinder-volume/tasks/real.yml
new file mode 100644
index 00000000..19ef828b
--- /dev/null
+++ b/deploy/adapters/ansible/roles/cinder-volume/tasks/real.yml
@@ -0,0 +1,10 @@
+---
+- include_vars: "{{ ansible_os_family }}.yml"
+
+- name: destroy GPT lable
+ shell: dd if=/dev/urandom of={{ physical_device }} bs=4M count=1
+ ignore_errors: True
+
+- name: create physical and group volumes
+ lvg: vg=cinder-volumes pvs={{ physical_device }}
+ vg_options=--force