← Back to team overview

bigdata-dev team mailing list archive

[Merge] lp:~johnsca/charms/trusty/apache-hadoop-plugin/venv-fix into lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk

 

Cory Johns has proposed merging lp:~johnsca/charms/trusty/apache-hadoop-plugin/venv-fix into lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk.

Requested reviews:
  Juju Big Data Development (bigdata-dev)

For more details, see:
https://code.launchpad.net/~johnsca/charms/trusty/apache-hadoop-plugin/venv-fix/+merge/279341

Fixed previous MP to create a separate venv for charm-benchmark, as an update to that was causing charm-helpers to be upgraded in the plugin's venv.
-- 
Your team Juju Big Data Development is requested to review the proposed merge of lp:~johnsca/charms/trusty/apache-hadoop-plugin/venv-fix into lp:~bigdata-dev/charms/trusty/apache-hadoop-plugin/trunk.
=== modified file 'actions/parseTerasort.py'
--- actions/parseTerasort.py	2015-08-18 17:02:01 +0000
+++ actions/parseTerasort.py	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 """
 Simple script to parse cassandra-stress' transaction results
 and reformat them as JSON for sending back to juju

=== modified file 'actions/teragen'
--- actions/teragen	2015-08-24 22:59:45 +0000
+++ actions/teragen	2015-12-02 20:02:38 +0000
@@ -5,7 +5,7 @@
 
 # The plugin uses a venv to avoid conflicting with system bits; ensure our
 # venv is activated.
-. ${CHARM_DIR}/.venv/bin/activate
+. ${CHARM_DIR}/.venvs/benchmark/bin/activate
 
 benchmark-start
 

=== modified file 'actions/terasort'
--- actions/terasort	2015-08-24 22:59:45 +0000
+++ actions/terasort	2015-12-02 20:02:38 +0000
@@ -25,9 +25,9 @@
 # from this outer scope
 su ubuntu << EOF
 . /etc/environment
-# The plugin uses a venv to avoid conflicting with system bits; ensure our
+# We use a venv to avoid conflicting with other libs; ensure our
 # venv is activated.
-. ${CHARM_DIR}/.venv/bin/activate
+. ${CHARM_DIR}/.venvs/benchmark/bin/activate
 
 mkdir -p /opt/terasort/results/$run
 
@@ -48,4 +48,4 @@
 EOF
 PATH=$OLDPATH
 
-`cat /opt/terasort/results/$run/terasort.log | $CHARM_DIR/.venv/bin/python $CHARM_DIR/actions/parseTerasort.py`
+`cat /opt/terasort/results/$run/terasort.log | $CHARM_DIR/.venvs/benchmark/bin/python $CHARM_DIR/actions/parseTerasort.py`

=== modified file 'hooks/common.py'
--- hooks/common.py	2015-09-15 17:25:15 +0000
+++ hooks/common.py	2015-12-02 20:02:38 +0000
@@ -1,4 +1,3 @@
-#!.venv/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -25,7 +24,7 @@
 # (venv is used to ensure library versions needed by plugin
 # don't conflict with the charm the plugin is supporting)
 os.environ['PATH'] = os.pathsep.join([
-    os.path.join(hookenv.charm_dir(), '.venv/bin'),
+    os.path.join(hookenv.charm_dir(), '.venvs/plugin/bin'),
     os.environ['PATH']])
 
 
@@ -44,7 +43,10 @@
             ', '.join(missing),
         ))
         return False
-    jujuresources.install(['pathlib', 'jujubigdata', 'charm-benchmark'])
+    jujuresources.install(['pathlib', 'jujubigdata'])
+    execfile('.venvs/benchmark//bin/activate_this.py', {'__file__': '.venvs/benchmark/bin/activate_this.py'})
+    jujuresources.install(['charm-benchmark'])
+    execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
     unitdata.kv().set('charm.bootstrapped', True)
     return True
 

=== modified file 'hooks/config-changed'
--- hooks/config-changed	2015-06-25 18:53:49 +0000
+++ hooks/config-changed	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -11,5 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
 common.manage()

=== modified file 'hooks/hadoop-plugin-relation-changed'
--- hooks/hadoop-plugin-relation-changed	2015-06-25 18:53:49 +0000
+++ hooks/hadoop-plugin-relation-changed	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -11,5 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
 common.manage()

=== modified file 'hooks/hadoop-plugin-relation-departed'
--- hooks/hadoop-plugin-relation-departed	2015-08-10 22:55:53 +0000
+++ hooks/hadoop-plugin-relation-departed	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -11,5 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
 common.manage()

=== modified file 'hooks/install'
--- hooks/install	2015-02-09 18:13:28 +0000
+++ hooks/install	2015-12-02 20:02:38 +0000
@@ -13,5 +13,7 @@
 import setup
 setup.pre_install()
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
 common.manage()

=== modified file 'hooks/namenode-relation-changed'
--- hooks/namenode-relation-changed	2015-06-25 18:53:49 +0000
+++ hooks/namenode-relation-changed	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -11,6 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
-
 common.manage()

=== modified file 'hooks/namenode-relation-departed'
--- hooks/namenode-relation-departed	2015-08-10 22:55:53 +0000
+++ hooks/namenode-relation-departed	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -11,6 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
-
 common.manage()

=== modified file 'hooks/resourcemanager-relation-changed'
--- hooks/resourcemanager-relation-changed	2015-06-25 18:53:49 +0000
+++ hooks/resourcemanager-relation-changed	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -11,6 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
-
 common.manage()

=== modified file 'hooks/resourcemanager-relation-departed'
--- hooks/resourcemanager-relation-departed	2015-08-10 22:55:53 +0000
+++ hooks/resourcemanager-relation-departed	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -11,6 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
-
 common.manage()

=== modified file 'hooks/setup.py'
--- hooks/setup.py	2015-06-25 18:53:49 +0000
+++ hooks/setup.py	2015-12-02 20:02:38 +0000
@@ -18,20 +18,21 @@
     """
     Do any setup required before the install hook.
     """
-    setup_venv()
-    install_bundled_resources()
-
-
-def setup_venv():
-    if not os.path.exists('.venv/bin/python'):
-        subprocess.check_call(['apt-get', 'install', '-yq', 'python-virtualenv'])
-        subprocess.check_call(['virtualenv', '.venv'])
-    execfile('.venv/bin/activate_this.py', {'__file__': '.venv/bin/activate_this.py'})
-
-
-def install_bundled_resources():
+    subprocess.check_call(['apt-get', 'install', '-yq', 'python-virtualenv'])
+    for venv in ('plugin', 'benchmark'):
+        venv = os.path.join('.venvs', venv)
+        setup_venv(venv)
+        install_bundled_resources(venv)
+
+
+def setup_venv(venv):
+    if not os.path.exists(os.path.join(venv, 'bin/python')):
+        subprocess.check_call(['virtualenv', venv])
+
+
+def install_bundled_resources(venv):
     """
     Install the bundled resources libraries.
     """
     archives = glob('resources/python/*')
-    subprocess.check_call(['.venv/bin/pip', 'install'] + archives)
+    subprocess.check_call([os.path.join(venv, 'bin/pip'), 'install'] + archives)

=== modified file 'hooks/start'
--- hooks/start	2015-06-25 18:53:49 +0000
+++ hooks/start	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -11,5 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
 common.manage()

=== modified file 'hooks/stop'
--- hooks/stop	2015-06-25 18:53:49 +0000
+++ hooks/stop	2015-12-02 20:02:38 +0000
@@ -1,4 +1,4 @@
-#!.venv/bin/python
+#!/usr/bin/python
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
@@ -11,5 +11,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+execfile('.venvs/plugin/bin/activate_this.py', {'__file__': '.venvs/plugin/bin/activate_this.py'})
+
 import common
 common.manage()