JIRA: BOTTLENECKS-29
[bottlenecks.git] / utils / infra_setup / heat_template / vstf_heat_template / scp.sh
diff --git a/utils/infra_setup/heat_template/vstf_heat_template/scp.sh b/utils/infra_setup/heat_template/vstf_heat_template/scp.sh
new file mode 100644 (file)
index 0000000..b3d6a27
--- /dev/null
@@ -0,0 +1,93 @@
+function scp_cmd()
+{
+    local ip=$1
+    local usr=$2
+    local passwd=$3
+    srcfile=$4
+    desfile=$5
+    opt=$6
+    case $opt in
+        file)
+                expect -c "
+            spawn scp -r $srcfile $usr@$ip:$desfile
+                set timeout  -1
+                expect {
+                        \"*no)?\"  {
+                                send \"yes\r\"
+                                exp_continue
+                        }
+                        \"*assword:*\"  {
+                                send \"$passwd\r\"
+                                exp_continue
+                        }
+                }
+                "
+        ;;
+        dir)
+            expect -c "
+                        spawn scp -r $srcfile $usr@$ip:$desfile
+                        set timeout  -1
+                        expect {
+                                \"*no)?\"  {
+                                        send \"yes\r\"
+                                        exp_continue
+                                }
+                                \"*assword:*\"  {
+                                        send \"$passwd\r\"
+                                        exp_continue
+                                }
+                        }
+                        "
+        ;;
+        *)
+            echo "err"
+        ;;
+    esac
+}
+
+function remote_scp_cmd()
+{
+    local ip=$1
+    local usr=$2
+    local passwd=$3
+    srcfile=$4
+    desfile=$5
+    opt=$6
+    case $opt in
+        file)
+                expect -c "
+                spawn scp -r $usr@$ip:$srcfile $desfile
+                set timeout  -1
+                expect {
+                        \"*no)?\"  {
+                                send \"yes\r\"
+                                exp_continue
+                        }
+                        \"*assword:*\"  {
+                                send \"$passwd\r\"
+                                exp_continue
+                        }
+                }
+                "
+        ;;
+        dir)
+            expect -c "
+                        spawn scp -r $usr@$ip:$srcfile $desfile
+                        set timeout  -1
+                        expect {
+                                \"*no)?\"  {
+                                        send \"yes\r\"
+                                        exp_continue
+                                }
+                                \"*assword:*\"  {
+                                        send \"$passwd\r\"
+                                        exp_continue
+                                }
+                        }
+                        "
+        ;;
+        *)
+            echo "err"
+        ;;
+    esac
+}