You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2016/06/06 23:48:19 UTC

ambari git commit: AMBARI-17067. Microsoft-r install script should use Ambari libraries instead of direct shell calls (Balázs Bence Sári via srimanth)

Repository: ambari
Updated Branches:
  refs/heads/trunk cd9332109 -> edc3ac538


AMBARI-17067. Microsoft-r install script should use Ambari libraries instead of direct shell calls (Bal�zs Bence S�ri via srimanth)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/edc3ac53
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/edc3ac53
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/edc3ac53

Branch: refs/heads/trunk
Commit: edc3ac53833a3e212b0567cc683353275667b9f6
Parents: cd93321
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Mon Jun 6 16:47:21 2016 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Mon Jun 6 16:47:27 2016 -0700

----------------------------------------------------------------------
 .../8.0.0/package/scripts/microsoft_r.py        | 80 ++++++--------------
 .../src/main/resources/mpack.json               | 16 ++++
 2 files changed, 41 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/edc3ac53/contrib/management-packs/microsoft-r_mpack/src/main/resources/common-services/MICROSOFT_R/8.0.0/package/scripts/microsoft_r.py
----------------------------------------------------------------------
diff --git a/contrib/management-packs/microsoft-r_mpack/src/main/resources/common-services/MICROSOFT_R/8.0.0/package/scripts/microsoft_r.py b/contrib/management-packs/microsoft-r_mpack/src/main/resources/common-services/MICROSOFT_R/8.0.0/package/scripts/microsoft_r.py
index 5b6e482..61ea96b 100644
--- a/contrib/management-packs/microsoft-r_mpack/src/main/resources/common-services/MICROSOFT_R/8.0.0/package/scripts/microsoft_r.py
+++ b/contrib/management-packs/microsoft-r_mpack/src/main/resources/common-services/MICROSOFT_R/8.0.0/package/scripts/microsoft_r.py
@@ -17,67 +17,37 @@ See the License for the specific language governing permissions and
 limitations under the License.
 
 """
+from resource_management.libraries.script import Script
+from resource_management.core.logger import Logger
+from resource_management.core.source import DownloadSource
+from resource_management.core.resources import File, Package
 
-import sys
-from resource_management import *
-import shutil, tempfile, subprocess, traceback
-from resource_management.core import shell
-
-openr_location = 'http://104.196.87.250/msft-r/'
-rserver_location = 'http://104.196.87.250/msft-r/'
-#openr_location = '/ambari/contrib/msr/'
-#rserver_location = '/ambari/contrib/msr/'
+rpm_location = 'http://104.196.87.250/msft-r/8.1/'
+rpms = ['microsoft-r-server-mro-8.0.rpm',
+        'microsoft-r-server-intel-mkl-8.0.rpm',
+        'microsoft-r-server-packages-8.0.rpm',
+        'microsoft-r-server-hadoop-8.0.rpm']
 
 class MicrosoftR(Script):
   def install(self, env):
-    print 'Install R Server'
-    tmp_dir = tempfile.mkdtemp()
-    print 'Using temp dir: ' + tmp_dir
-    try:
-      print 'Download R Open'
-      if "http" in openr_location:
-        subprocess.call(['wget', openr_location + 'MRO-for-MRS-8.0.0.el6.x86_64.rpm'], cwd=tmp_dir)
-      else:
-        shell.call('cp ' + openr_location + '/MRO-for-MRS-8.0.0.el6.x86_64.rpm ' + tmp_dir)
-
-      print 'Install R Open'
-      subprocess.call(['yum', 'install', '-y', 'MRO-for-MRS-8.0.0.el6.x86_64.rpm'], cwd=tmp_dir)
-
-      print 'Download R Server'
-      if "http" in rserver_location:
-        subprocess.call(['wget', rserver_location + 'Microsoft-R-Server-8.0.0-RHEL6.tar.gz'], cwd=tmp_dir)
-      else:
-        shell.call('cp ' + rserver_location + 'Microsoft-R-Server-8.0.0-RHEL6.tar.gz ' + tmp_dir)
-
-      print 'Install R Server'
-      subprocess.call(['tar', '-xzvf', 'Microsoft-R-Server-8.0.0-RHEL6.tar.gz'], cwd=tmp_dir)
-      subprocess.call([tmp_dir + '/rrent/install.sh', '-a', '-y', '-p', '/usr/lib64/MRO-for-MRS-8.0.0/R-3.2.2'], cwd = tmp_dir + '/rrent')
-
-      print 'Create symlink to hadoop library'
-      _, libhdfs = shell.call('find /usr/hdp/ -name libhdfs.so')
-      shell.call('ln -s ' + libhdfs + ' /usr/lib64/libhdfs.so')
-
-      print 'Create /share on hadoop' # This is not strictly required, but needed to run the example
-      shell.call('sudo -u hdfs hadoop fs -mkdir -p /share')
-      shell.call('sudo -u hdfs hadoop fs -chmod uog+rwx /share')
-
-      print 'Configure R Server for the ambari-qa user'
-      shell.call('sudo -u hdfs hadoop fs -mkdir -p /user/RevoShare/ambari-qa')
-      shell.call('sudo -u hdfs hadoop fs -chmod uog+rwx /user/RevoShare/ambari-qa')
-      shell.call('mkdir -p /var/RevoShare/ambari-qa')
-      shell.call('chmod oug+rwx /var/RevoShare/ambari-qa')
-      shell.call('sudo -u ambari-qa echo ". /usr/lib64/MRS-8.0/scripts/RevoHadoopEnvVars.site" >> ~ambari-qa/.bashrc')
-
-      print 'Installed R Server'
-    except Exception as ex:
-      print "An error occured while installing Microsoft R"
-      traceback.print_exc()
-    finally:
-      print 'Cleaning up'
-      shutil.rmtree(tmp_dir)
+    Logger.info('Installing R Server Client...')
+    tmp_dir = Script.tmp_dir
+    Logger.debug('Using temp dir: {0}'.format(tmp_dir))
+    Logger.info("Will download and install the following rpm's from {0}: {1}".format(rpm_location, rpms))
+
+    for rpm in rpms:
+      Logger.info('Downloading {0}'.format(rpm))
+      rpmFile = '{0}/{1}'.format(tmp_dir, rpm)
+      File(rpmFile, \
+           content = DownloadSource(rpm_location + rpm), \
+           mode = 0644)
+      Logger.info('Installing {0}'.format(rpm))
+      Package(rpmFile)
+
+    Logger.info('Installed R Server')
 
   def configure(self, env):
-    print 'Configure R Server. Nothing to do.'
+    Logger.info('Configure R Server. Nothing to do.')
 
 if __name__ == "__main__":
   MicrosoftR().execute()

http://git-wip-us.apache.org/repos/asf/ambari/blob/edc3ac53/contrib/management-packs/microsoft-r_mpack/src/main/resources/mpack.json
----------------------------------------------------------------------
diff --git a/contrib/management-packs/microsoft-r_mpack/src/main/resources/mpack.json b/contrib/management-packs/microsoft-r_mpack/src/main/resources/mpack.json
index 17c2f54..a6544c3 100644
--- a/contrib/management-packs/microsoft-r_mpack/src/main/resources/mpack.json
+++ b/contrib/management-packs/microsoft-r_mpack/src/main/resources/mpack.json
@@ -29,7 +29,23 @@
           "applicable_stacks" : [
             {
               "stack_name" : "HDP",
+              "stack_version" : "1.3"
+            },
+            {
+              "stack_name" : "HDP",
+              "stack_version" : "2.0"
+            },
+            {
+              "stack_name" : "HDP",
+              "stack_version" : "2.1"
+            },
+            {
+              "stack_name" : "HDP",
               "stack_version" : "2.2"
+            },
+            {
+              "stack_name" : "HDP",
+              "stack_version" : "2.3"
             }
           ]
         }