[autotest] Add virtualenv bootstrap stuff

This commit adds the common bootstrap for virtualenv

BUG=chromium:703264
TEST=Run new monitor_db locally

Change-Id: Ia86ec44dc368c03a25eb330b3f0f72d8f06a8404
Reviewed-on: https://chromium-review.googlesource.com/457424
Commit-Ready: Aviv Keshet <akeshet@chromium.org>
Tested-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/bin/find_virtualenv.sh b/bin/find_virtualenv.sh
new file mode 100644
index 0000000..76151f6
--- /dev/null
+++ b/bin/find_virtualenv.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Copyright 2017 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Find the virtualenv repo to use.
+#
+# This is meant to be sourced in scripts that need virtualenv.  The
+# sourcing script should cd into the directory containing this script
+# first.  This script defines functions for performing common tasks:
+#
+# exec_python -- Execute Python module inside of virtualenv
+set -eu
+
+if [ -d  ../../../../../infra_virtualenv ]; then
+    readonly virtualenv_dir=../../../../../infra_virtualenv
+elif [ -d ~chromeos-test/chromiumos/infra_virtualenv ]; then
+    readonly virtualenv_dir=~chromeos-test/chromiumos/infra_virtualenv
+elif [ -d  /opt/infra_virtualenv ]; then
+    readonly virtualenv_dir=/opt/infra_virtualenv
+else
+    echo "$0: virtualenv repo not found" >&2
+    exit 1
+fi
+
+readonly venv_dir=../venv/.venv
+readonly reqs_file=../venv/requirements.txt
+
+_create_venv() {
+    "$virtualenv_dir/create_venv" "$venv_dir" "$reqs_file" >&2
+}
+
+exec_python_module() {
+    _create_venv
+    export PYTHONPATH='../venv'
+    exec "$venv_dir/bin/python" -m "$@"
+}
diff --git a/bin/monitor_db b/bin/monitor_db
new file mode 100755
index 0000000..19c01ed
--- /dev/null
+++ b/bin/monitor_db
@@ -0,0 +1,8 @@
+#!/bin/sh
+# Copyright 2017 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+set -eu
+cd "$(dirname "$(readlink -f "$0")")"
+. ./find_virtualenv.sh
+exec_python_module autotest_lib.scheduler.monitor_db "$@"
diff --git a/venv/.gitignore b/venv/.gitignore
new file mode 100644
index 0000000..ef81b1e
--- /dev/null
+++ b/venv/.gitignore
@@ -0,0 +1 @@
+/.venv/
diff --git a/venv/autotest_lib b/venv/autotest_lib
new file mode 120000
index 0000000..a96aa0e
--- /dev/null
+++ b/venv/autotest_lib
@@ -0,0 +1 @@
+..
\ No newline at end of file
diff --git a/venv/requirements.txt b/venv/requirements.txt
new file mode 100644
index 0000000..a701a31
--- /dev/null
+++ b/venv/requirements.txt
@@ -0,0 +1,33 @@
+# chromite deps
+enum34==1.1.6
+funcsigs==1.0.2
+future==0.15.2
+futures==3.0.5
+gax-google-logging-v2==0.8.1
+gax-google-pubsub-v1==0.8.1
+gcloud==0.18.1
+gitdb2==2.0.0
+GitPython==2.1.1
+google-gax==0.12.5
+googleapis-common-protos==1.3.3
+grpc-google-logging-v2==0.8.1
+grpc-google-pubsub-v1==0.8.1
+grpcio==1.0.0
+httplib2==0.9.2
+mock==2.0.0
+mox==0.5.3
+MySQL-python==1.2.5
+numpy==1.11.1
+oauth2client==3.0.0
+pbr==1.10.0
+ply==3.8
+protobuf==3.0.0
+psutil==4.3.1
+pyasn1==0.1.9
+pyasn1-modules==0.0.8
+pyparsing==2.1.8
+PyYAML==3.12
+rsa==3.4.2
+six==1.10.0
+smmap2==2.0.1
+SQLAlchemy==1.0.15