Make /dockerdata-nfs a ZFS volume with compression

Issue-ID: INT-1117
Signed-off-by: Gary Wu <gary.wu@futurewei.com>
Change-Id: I2b5cdb332702a3599b2faa4d180f68decb7a199b
diff --git a/deployment/heat/onap-rke/nfs_vm_entrypoint.sh b/deployment/heat/onap-rke/nfs_vm_entrypoint.sh
index 9dada99..b307023 100644
--- a/deployment/heat/onap-rke/nfs_vm_entrypoint.sh
+++ b/deployment/heat/onap-rke/nfs_vm_entrypoint.sh
@@ -20,7 +20,9 @@
 printenv
 
 mkdir -p /opt/config
+echo "__nfs_volume_id__" > /opt/config/nfs_volume_id.txt
 echo "__nfs_ip_addr__" > /opt/config/nfs_ip_addr.txt
+echo "__nfs_private_ip_addr__" > /opt/config/nfs_private_ip_addr.txt
 echo "__k8s_vm_ips__" > /opt/config/k8s_vm_ips.txt
 echo "__k8s_private_ips__" > /opt/config/k8s_private_ips.txt
 echo "__public_net_id__" > /opt/config/public_net_id.txt
@@ -83,11 +85,15 @@
 
 while ! hash jq &> /dev/null; do
     apt-get -y update
-    apt-get -y install curl jq make nfs-kernel-server moreutils
+    apt-get -y install curl jq make nfs-kernel-server moreutils zfsutils-linux
     sleep 10
 done
 
-mkdir -p /dockerdata-nfs
+nfs_volume_dev="/dev/disk/by-id/virtio-$(echo "__nfs_volume_id__" | cut -c -20)"
+
+zpool create -f -m /dockerdata-nfs dockerdata-nfs $nfs_volume_dev
+zfs set compression=lz4 dockerdata-nfs
+zfs set sharenfs="rw=*" dockerdata-nfs
 
 # update and initialize git
 git config --global user.email root@nfs
@@ -102,11 +108,6 @@
 git add -A
 git commit -m "initial commit"
 
-# export NFS mount
-echo "/dockerdata-nfs *(rw,fsid=1,async,no_root_squash,no_subtree_check)" | tee /etc/exports
-exportfs -a
-systemctl restart nfs-kernel-server
-
 
 
 cd ~
diff --git a/deployment/heat/onap-rke/onap-oom.yaml b/deployment/heat/onap-rke/onap-oom.yaml
index 075ed66..f3f82ef 100644
--- a/deployment/heat/onap-rke/onap-oom.yaml
+++ b/deployment/heat/onap-rke/onap-oom.yaml
@@ -198,6 +198,17 @@
     properties:
       floating_network_id: { get_param: public_net_id }
       port_id: { get_resource: nfs_private_port }
+  nfs_volume:
+    type: OS::Cinder::Volume
+    properties:
+      size: 200
+
+  nfs_volume_att:
+    type: OS::Cinder::VolumeAttachment
+    properties:
+      instance_uuid: { get_resource: nfs_vm }
+      volume_id: { get_resource: nfs_volume }
+
   nfs_vm:
     type: OS::Nova::Server
     properties:
@@ -214,6 +225,7 @@
           template:
             get_file: nfs_vm_entrypoint.sh
           params:
+            __nfs_volume_id__: { get_resource: nfs_volume }
             __docker_proxy__: { get_param: docker_proxy }
             __apt_proxy__: { get_param: apt_proxy }
             __nfs_ip_addr__: { get_attr: [nfs_floating_ip, floating_ip_address] }
diff --git a/deployment/heat/onap-rke/scripts/gen-onap-oom-yaml.sh b/deployment/heat/onap-rke/scripts/gen-onap-oom-yaml.sh
index 32fe147..733aa20 100755
--- a/deployment/heat/onap-rke/scripts/gen-onap-oom-yaml.sh
+++ b/deployment/heat/onap-rke/scripts/gen-onap-oom-yaml.sh
@@ -30,6 +30,17 @@
 cat $PARTS_DIR/onap-oom-1.yaml
 
 cat <<EOF
+  nfs_volume:
+    type: OS::Cinder::Volume
+    properties:
+      size: 200
+
+  nfs_volume_att:
+    type: OS::Cinder::VolumeAttachment
+    properties:
+      instance_uuid: { get_resource: nfs_vm }
+      volume_id: { get_resource: nfs_volume }
+
   nfs_vm:
     type: OS::Nova::Server
     properties:
@@ -46,6 +57,7 @@
           template:
             get_file: nfs_vm_entrypoint.sh
           params:
+            __nfs_volume_id__: { get_resource: nfs_volume }
             __docker_proxy__: { get_param: docker_proxy }
             __apt_proxy__: { get_param: apt_proxy }
             __nfs_ip_addr__: { get_attr: [nfs_floating_ip, floating_ip_address] }