XenServer: change install script for new install process

Change-Id: Iee64e19fb21c1c633b5a2df7c4c154702f2a4526
diff --git a/tools/xen/scripts/install-os-vpx.sh b/tools/xen/scripts/install-os-vpx.sh
index d45c370..14240a7 100755
--- a/tools/xen/scripts/install-os-vpx.sh
+++ b/tools/xen/scripts/install-os-vpx.sh
@@ -38,7 +38,7 @@
 cat << EOF
 
   Usage: $0 [-f FILE_PATH] [-d DISK_SIZE] [-v BRIDGE_NAME] [-m BRIDGE_NAME] [-p BRIDGE_NAME]
-            [-k PARAMS] [-r RAM] [-i|-c] [-w] [-b] [-l NAME_LABEL]
+            [-k PARAMS] [-r RAM] [-i|-c] [-w] [-b] [-l NAME_LABEL] [-t TEMPLATE_NW_INSTALL]
 
   Installs XenServer OpenStack VPX.
 
@@ -61,6 +61,7 @@
      -r MiB       Specifies RAM used by the VPX, in MiB.
                   By default it will take the value from the XVA.
      -l name      Specifies the name label for the VM.
+     -t template  Network install an openstack domU from this template
 
   EXAMPLES:
 
@@ -88,7 +89,7 @@
 
 get_params()
 {
-  while getopts "hicwbf:d:v:m:p:k:r:l:" OPTION;
+  while getopts "hicwbf:d:v:m:p:k:r:l:t:" OPTION;
   do
     case $OPTION in
       h) usage
@@ -127,9 +128,12 @@
       v)
          BRIDGE_V=$OPTARG
          ;;
-     l)
+      l)
          NAME_LABEL=$OPTARG
          ;;
+      t)
+         TEMPLATE_NAME=$OPTARG
+         ;;
       ?)
          usage
          exit
@@ -422,6 +426,16 @@
 
   destroy_vifs "$vm_uuid"
   set_all "$vm_uuid"
+elif [ "$TEMPLATE_NAME" ]
+then
+  echo $TEMPLATE_NAME
+  vm_uuid=$(xe_min vm-install template="$TEMPLATE_NAME" new-name-label="DevstackOSDomu")
+  destroy_vifs "$vm_uuid"
+  set_auto_start "$vm_uuid"
+  create_gi_vif "$vm_uuid"
+  create_vm_vif "$vm_uuid"
+  create_management_vif "$vm_uuid"
+  create_public_vif "$vm_uuid"
 else
   if [ ! -f "$VPX_FILE" ]
   then