common.sh parsing for api10 arguments
authorGuido Trotter <ultrotter@google.com>
Thu, 16 Oct 2008 09:20:26 +0000 (09:20 +0000)
committerGuido Trotter <ultrotter@google.com>
Thu, 16 Oct 2008 09:20:26 +0000 (09:20 +0000)
If OS_API_VERSION has value 10 we'll check and parse the arguments using
the version 10 style, as described by the relevant design doc, and save
them to the old names we used before. This makes the create and rename
scripts version 6 compatible (except for bugs, that is), while import
and export will need some more work.

Reviewed-by: iustinp

common.sh

index cfc913a..c541aa1 100644 (file)
--- a/common.sh
+++ b/common.sh
@@ -33,5 +33,33 @@ get_api5_arguments() {
   fi
 }
 
-get_api5_arguments
+get_api10_arguments() {
+  if [ -z "$INSTANCE" -o -z "$HYPERVISOR" -o -z "$DISK_COUNT" ]; then
+    echo "Missing OS API Variable"
+    exit 1
+  fi
+  instance=$INSTANCE
+  if [ $DISK_COUNT -lt 1 -o -z "$DISK_0_PATH" ]; then
+    echo "At least one disk is needed"
+    exit 1
+  fi
+  blockdev=$DISK_0_PATH
+  if [ "$0" = "rename" -a -z "$NEW_INSTANCE_NAME" ]; then
+    echo "Missing OS API Variable"
+  fi
+  new_name=$NEW_INSTANCE_NAME
+}
 
+if [ -z "$OS_API_VERSION" -o "$OS_API_VERSION" = "5" ]; then
+  OS_API_VERSION=5
+  get_api5_arguments
+elif [ "$OS_API_VERSION" = "10" ]; then
+  get_api10_arguments
+  if [ $0 = "import" -o $0 = "export" ]; then
+    echo "import/export still not compatible with API version 10"
+    exit 1
+  fi
+else
+  echo "Unknown OS API VERSION $OS_API_VERSION"
+  exit 1
+fi