You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2018/06/29 18:11:37 UTC

[ambari] branch branch-feature-AMBARI-14714 updated: [AMBARI-24196] Mpack Instance Manager Produces Bad JSON and Doesn't Li… (#1637)

This is an automated email from the ASF dual-hosted git repository.

jluniya pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by this push:
     new 3c35230  [AMBARI-24196] Mpack Instance Manager Produces Bad JSON and Doesn't Li… (#1637)
3c35230 is described below

commit 3c35230fbf0a96dfd3ea54ca770d52b1e5cd5039
Author: sduan <sd...@hortonworks.com>
AuthorDate: Fri Jun 29 11:11:34 2018 -0700

    [AMBARI-24196] Mpack Instance Manager Produces Bad JSON and Doesn't Li… (#1637)
    
    * AMBARI-24196: Mpack Instance Manager Produces Bad JSON and Doesn't List Versions
    
    * AMBARI-24196: Mpack Instance Manager Produces Bad JSON and Doesn't List Versions
---
 .../libraries/functions/mpack_manager_helper.py    |  2 +-
 .../python/instance_manager/instance_manager.py    | 14 +++++++++--
 .../instance_manager/test_instance_manager.py      | 28 ++++++++++++++++------
 3 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/mpack_manager_helper.py b/ambari-common/src/main/python/resource_management/libraries/functions/mpack_manager_helper.py
index 83bf635..c79402e 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/mpack_manager_helper.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/mpack_manager_helper.py
@@ -25,7 +25,7 @@ from instance_manager import create_mpack, set_mpack_instance, get_conf_dir, get
 CONFIG_DIR_KEY_NAME = 'config_dir'
 LOG_DIR_KEY_NAME = 'log_dir'
 RUN_DIR_KEY_NAME = 'run_dir'
-PATH_KEY_NAME = 'path'
+PATH_KEY_NAME = 'mpack_path'
 COMPONENTS_PLURAL_KEY_NAME = 'components'
 COMPONENT_INSTANCES_PLURAL_KEY_NAME = 'component-instances'
 
diff --git a/mpack-instance-manager/src/main/python/instance_manager/instance_manager.py b/mpack-instance-manager/src/main/python/instance_manager/instance_manager.py
index 0a9ed83..5d6ca16 100644
--- a/mpack-instance-manager/src/main/python/instance_manager/instance_manager.py
+++ b/mpack-instance-manager/src/main/python/instance_manager/instance_manager.py
@@ -339,7 +339,7 @@ class MetaMpack:
     if not self.mpack_json:
       return None
     for module in self.mpack_json['modules']:
-      result[module['id']] = module['category']
+      result[module['id']] = str(module['category'])
 
     return result
 
@@ -597,6 +597,9 @@ class ComponentInstance(Instance):
     self.name = name
     self.component_path = component_path
     self.path_exec = path_exec
+    self.module_path = os.readlink(path_exec)
+    self.mpack_version = os.path.basename(os.path.dirname(path_exec))
+    self.module_version = os.path.basename(self.module_path)
 
   def set_new_version(self, mpack_name, mpack_version, component_type):
     mpack_path = os.path.join(ROOT_FOLDER_PATH, MPACKS_FOLDER_NAME, mpack_name, mpack_version, component_type)
@@ -686,5 +689,12 @@ class ComponentInstance(Instance):
     if output_run_dir:
       result['run_dir'] = os.path.join(self.component_path, RUN_DIRECTORY_NAME)
     if output_path:
-      result['path'] = self.path_exec
+      result['mpack_path'] = self.path_exec
+      result['module_path'] = self.module_path
+      result['instance_path'] = os.path.join(self.component_path, CURRENT_SOFTLINK_NAME)
+      result['config_dir'] = os.path.join(self.component_path, CONFIGS_DIRECTORY_NAME)
+      result['log_dir'] = os.path.join(self.component_path, LOG_DIRECTORY_NAME)
+      result['run_dir'] = os.path.join(self.component_path, RUN_DIRECTORY_NAME)
+      result['mpack_version'] = self.mpack_version
+      result['module_version'] = self.module_version
     return result
diff --git a/mpack-instance-manager/src/test/python/instance_manager/test_instance_manager.py b/mpack-instance-manager/src/test/python/instance_manager/test_instance_manager.py
index db5c521..1eaed9e 100644
--- a/mpack-instance-manager/src/test/python/instance_manager/test_instance_manager.py
+++ b/mpack-instance-manager/src/test/python/instance_manager/test_instance_manager.py
@@ -344,8 +344,15 @@ class TestInstanceManager(TestCase):
                         "hdfs_server": {
                           "component-instances": {
                             "server1": {
-                              "path": "/tmp/instance_manager_test/mpacks/hdpcore/1.0.0-b1/hdfs_server",
-                              "name": "server1"
+                              "run_dir": "/tmp/instance_manager_test/instances/hdpcore/Production/default/hdfs/hdfs_server/server1/run",
+                              "module_version": "3.1.0.0-b1",
+                              "name": "server1",
+                              "mpack_path": "/tmp/instance_manager_test/mpacks/hdpcore/1.0.0-b1/hdfs_server",
+                              "mpack_version": "1.0.0-b1",
+                              "instance_path": "/tmp/instance_manager_test/instances/hdpcore/Production/default/hdfs/hdfs_server/server1/current",
+                              "log_dir": "/tmp/instance_manager_test/instances/hdpcore/Production/default/hdfs/hdfs_server/server1/log",
+                              "module_path": "/tmp/instance_manager_test/modules/hdfs/3.1.0.0-b1",
+                              "config_dir": "/tmp/instance_manager_test/instances/hdpcore/Production/default/hdfs/hdfs_server/server1/conf"
                             }
                           }
                         }
@@ -357,10 +364,17 @@ class TestInstanceManager(TestCase):
                         "hdfs_client": {
                           "component-instances": {
                             "default": {
-                              "path": "/tmp/instance_manager_test/mpacks/hdpcore/1.0.0-b1/hdfs_client",
-                              "name": "default"
+                              "run_dir": "/tmp/instance_manager_test/instances/hdpcore/Production/default/hdfs_client/run",
+                              "module_version": "3.1.0.0-b1",
+                              "name": "default",
+                              "mpack_path": "/tmp/instance_manager_test/mpacks/hdpcore/1.0.0-b1/hdfs_client",
+                              "mpack_version": "1.0.0-b1",
+                              "instance_path": "/tmp/instance_manager_test/instances/hdpcore/Production/default/hdfs_client/current",
+                              "log_dir": "/tmp/instance_manager_test/instances/hdpcore/Production/default/hdfs_client/log",
+                              "module_path": "/tmp/instance_manager_test/modules/hdfs-clients/3.1.0.0-b1",
+                              "config_dir": "/tmp/instance_manager_test/instances/hdpcore/Production/default/hdfs_client/conf"
                             }
-                           }
+                          }
                         }
                       },
                       "name": "hdfs-clients"
@@ -373,7 +387,7 @@ class TestInstanceManager(TestCase):
         }
       }
     }
-    self.assertEqual(conf_dir_json, expected_json)
+    self.assertDictEqual(conf_dir_json, expected_json)
 
   def test_granularity(self):
     create_mpack_with_defaults()
@@ -438,7 +452,7 @@ class TestInstanceManager(TestCase):
     expected_filter_result = {'mpacks': {'edw': {'mpack-instances': {'eCommerce': {'name': 'eCommerce', 'subgroups': {
       'default': {'modules': {'hdfs': {'category': 'SERVER', 'name': 'hdfs', 'components': {'hdfs_server': {
         'component-instances': {
-          'server2': {'path': '/tmp/instance_manager_test/mpacks/edw/1.0.0-b1/hdfs_server', 'name': 'server2'}}}}}}}}}}}}}
+          'server2': {'run_dir': '/tmp/instance_manager_test/instances/edw/eCommerce/default/hdfs/hdfs_server/server2/run', 'module_version': '3.1.0.0-b1', 'name': 'server2', 'mpack_path': '/tmp/instance_manager_test/mpacks/edw/1.0.0-b1/hdfs_server', 'mpack_version': '1.0.0-b1', 'instance_path': '/tmp/instance_manager_test/instances/edw/eCommerce/default/hdfs/hdfs_server/server2/current', 'log_dir': '/tmp/instance_manager_test/instances/edw/eCommerce/default/hdfs/hdfs_server/server2/log' [...]
     self.assertEquals(expected_filter_result, filter_by_component_instance_name_json)
 
   def test_validation(self):