ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlun...@apache.org
Subject ambari git commit: AMBARI-17562 - Adding single stack, extension and service should be removed from management pack support (Tim Thorpe via jluniya)
Date Mon, 11 Jul 2016 17:24:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk ce2c123f9 -> 376ac4389


AMBARI-17562 - Adding single stack, extension and service should be removed from management
pack support (Tim Thorpe via jluniya)


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

Branch: refs/heads/trunk
Commit: 376ac438988bc32451ed030601ab13524692dc53
Parents: ce2c123
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Mon Jul 11 10:24:35 2016 -0700
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Mon Jul 11 10:24:35 2016 -0700

----------------------------------------------------------------------
 .../main/python/ambari_server/setupMpacks.py    | 136 +------------------
 ambari-server/src/test/python/TestMpacks.py     |   7 +-
 .../myservice-ambari-mpack-1.0.0.0/mpack.json   |  47 ++++---
 3 files changed, 29 insertions(+), 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/376ac438/ambari-server/src/main/python/ambari_server/setupMpacks.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/setupMpacks.py b/ambari-server/src/main/python/ambari_server/setupMpacks.py
index 5acc92c..86b4081 100644
--- a/ambari-server/src/main/python/ambari_server/setupMpacks.py
+++ b/ambari-server/src/main/python/ambari_server/setupMpacks.py
@@ -194,6 +194,7 @@ def create_symlink(src_dir, dest_dir, file_name, force=False):
   if force and os.path.islink(dest_link):
     sudo.unlink(dest_link)
   sudo.symlink(src_path, dest_link)
+  print_info_msg("Symlink: " + dest_link)
 
 def remove_symlinks(stack_location, service_definitions_location, staged_mpack_dir):
   """
@@ -287,35 +288,6 @@ def process_stack_definitions_artifact(artifact, artifact_source_dir,
options):
             else:
               create_symlink(src_stack_version_dir, dest_stack_version_dir, file, options.force)
 
-def process_stack_definition_artifact(artifact, artifact_source_dir, options):
-  """
-  Process stack-definition artifact
-  :param artifact: Artifact metadata
-  :param artifact_source_dir: Location of artifact in the management pack
-  :param options: Command line options
-  """
-  # Get ambari mpack properties
-  stack_location, extension_location, service_definitions_location, mpacks_staging_location
= get_mpack_properties()
-  stack_name = None
-  if "stack_name" in artifact:
-    stack_name = artifact.stack_name
-  if not stack_name:
-    print_error_msg("Must provide stack name for stack-definition artifact!")
-    raise FatalException(-1, 'Must provide stack name for stack-definition artifact!')
-  stack_version = None
-  if "stack_version" in artifact:
-    stack_version = artifact.stack_version
-  if not stack_version:
-    print_error_msg("Must provide stack version for stack-definition artifact!")
-    raise FatalException(-1, 'Must provide stack version for stack-definition artifact!')
-  stack_dir = os.path.join(stack_location, stack_name)
-  dest_link = os.path.join(stack_dir, stack_version)
-  if (not os.path.exists(stack_dir)):
-    sudo.makedir(stack_dir, 0755)
-  if options.force and os.path.islink(dest_link):
-    sudo.unlink(dest_link)
-  sudo.symlink(artifact_source_dir, dest_link)
-
 def process_extension_definitions_artifact(artifact, artifact_source_dir, options):
   """
   Process extension-definitions artifacts
@@ -343,40 +315,6 @@ def process_extension_definitions_artifact(artifact, artifact_source_dir,
option
       for file in sorted(os.listdir(src_extension_dir)):
         create_symlink(src_extension_dir, dest_extension_dir, file, options.force)
 
-def process_extension_definition_artifact(artifact, artifact_source_dir, options):
-  """
-  Process extension-definition artifact
-  Creates a link from <extension_location>/<extension_name>/<extension_version>
-  to the artifact_source_dir.
-  Ex: resources/extensions/EXT/1.0 -> resources/mpacks/myext/extensions/EXT/1.0
-  :param artifact: Artifact metadata
-  :param artifact_source_dir: Location of artifact in the management pack
-  :param options: Command line options
-  """
-  # Get ambari mpack properties
-  stack_location, extension_location, service_definitions_location, mpacks_staging_location
= get_mpack_properties()
-  extension_name = None
-  if "extension_name" in artifact:
-    extension_name = artifact.extension_name
-  if not extension_name:
-    print_error_msg("Must provide extension name for extension-definition artifact!")
-    raise FatalException(-1, 'Must provide extension name for extension-definition artifact!')
-  extension_version = None
-  if "extension_version" in artifact:
-    extension_version = artifact.extension_version
-  if not extension_version:
-    print_error_msg("Must provide extension version for extension-definition artifact!")
-    raise FatalException(-1, 'Must provide extension version for extension-definition artifact!')
-  extension_dir = os.path.join(extension_location, extension_name)
-  dest_link = os.path.join(extension_dir, extension_version)
-  if (not os.path.exists(extension_location)):
-    sudo.makedir(extension_location, 0755)
-  if (not os.path.exists(extension_dir)):
-    sudo.makedir(extension_dir, 0755)
-  if options.force and os.path.islink(dest_link):
-    sudo.unlink(dest_link)
-  sudo.symlink(artifact_source_dir, dest_link)
-
 def process_service_definitions_artifact(artifact, artifact_source_dir, options):
   """
   Process service-definitions artifact
@@ -394,35 +332,6 @@ def process_service_definitions_artifact(artifact, artifact_source_dir,
options)
     for file in sorted(os.listdir(src_service_definitions_dir)):
       create_symlink(src_service_definitions_dir, dest_service_definitions_dir, file, options.force)
 
-def process_service_definition_artifact(artifact, artifact_source_dir, options):
-  """
-  Process service-definition artifact
-  :param artifact: Artifact metadata
-  :param artifact_source_dir: Location of artifact in the management pack
-  :param options: Command line options
-  """
-  # Get ambari mpack properties
-  stack_location, extension_location, service_definitions_location, mpacks_staging_location
= get_mpack_properties()
-  service_name = None
-  if "service_name" in artifact:
-    service_name = artifact.service_name
-  if not service_name:
-    print_error_msg("Must provide service name for service-definition artifact!")
-    raise FatalException(-1, 'Must provide service name for service-definition artifact!')
-  service_version = None
-  if "service_version" in artifact:
-    service_version = artifact.service_version
-  if not service_version:
-    print_error_msg("Must provide service version for service-definition artifact!")
-    raise FatalException(-1, 'Must provide service version for service-definition artifact!')
-  dest_service_definition_dir = os.path.join(service_definitions_location, service_name)
-  if not os.path.exists(dest_service_definition_dir):
-    sudo.makedir(dest_service_definition_dir, 0755)
-  dest_link = os.path.join(dest_service_definition_dir, service_version)
-  if options.force and os.path.islink(dest_link):
-    sudo.unlink(dest_link)
-  sudo.symlink(artifact_source_dir, dest_link)
-
 def process_stack_addon_service_definitions_artifact(artifact, artifact_source_dir, options):
   """
   Process stack addon service definitions artifact
@@ -459,41 +368,6 @@ def process_stack_addon_service_definitions_artifact(artifact, artifact_source_d
                 sudo.unlink(dest_link)
               sudo.symlink(source_service_version_path, dest_link)
 
-def process_stack_addon_service_definition_artifact(artifact, artifact_source_dir, options):
-  """
-  Process stack addon service definition artifact
-  :param artifact: Artifact metadata
-  :param artifact_source_dir: Location of artifact in the management pack
-  :param options: Command line options
-  """
-  # Get ambari mpack properties
-  stack_location, extension_location, service_definitions_location, mpacks_staging_location
= get_mpack_properties()
-  service_name = None
-  if "service_name" in artifact:
-    service_name = artifact.service_name
-  if not service_name:
-    print_error_msg("Must provide service name for stack-addon-service-definition artifact!")
-    raise FatalException(-1, 'Must provide service name for stack-addon-service-definition
artifact!')
-  applicable_stacks = None
-  if "applicable_stacks" in artifact:
-    applicable_stacks = artifact.applicable_stacks
-  if not applicable_stacks:
-    print_error_msg("Must provide applicable stacks for stack-addon-service-definition artifact!")
-    raise FatalException(-1, 'Must provide applicable stacks for stack-addon-service-definition
artifact!')
-  for applicable_stack in applicable_stacks:
-    stack_name = applicable_stack.stack_name
-    stack_version = applicable_stack.stack_version
-    dest_stack_path = os.path.join(stack_location, stack_name)
-    dest_stack_version_path = os.path.join(dest_stack_path, stack_version)
-    dest_stack_services_path = os.path.join(dest_stack_version_path, "services")
-    dest_link = os.path.join(dest_stack_services_path, service_name)
-    if os.path.exists(dest_stack_path) and os.path.exists(dest_stack_version_path):
-      if not os.path.exists(dest_stack_services_path):
-        sudo.makedir(dest_stack_services_path, 0755)
-      if options.force and os.path.islink(dest_link):
-        sudo.unlink(dest_link)
-      sudo.symlink(artifact_source_dir, dest_link)
-
 def search_mpacks(mpack_name, max_mpack_version=None):
   """
   Search for all "mpack_name" management packs installed.
@@ -699,20 +573,12 @@ def _install_mpack(options, replay_mode=False):
             artifact_name, artifact_type, artifact_source_dir))
     if artifact.type == "stack-definitions":
       process_stack_definitions_artifact(artifact, artifact_source_dir, options)
-    elif artifact.type == "stack-definition":
-      process_stack_definition_artifact(artifact, artifact_source_dir, options)
     elif artifact.type == "extension-definitions":
       process_extension_definitions_artifact(artifact, artifact_source_dir, options)
-    elif artifact.type == "extension-definition":
-      process_extension_definition_artifact(artifact, artifact_source_dir, options)
     elif artifact.type == "service-definitions":
       process_service_definitions_artifact(artifact, artifact_source_dir, options)
-    elif artifact.type == "service-definition":
-      process_service_definition_artifact(artifact, artifact_source_dir, options)
     elif artifact.type == "stack-addon-service-definitions":
       process_stack_addon_service_definitions_artifact(artifact, artifact_source_dir, options)
-    elif artifact.type == "stack-addon-service-definition":
-      process_stack_addon_service_definition_artifact(artifact, artifact_source_dir, options)
     else:
       print_info_msg("Unknown artifact {0} of type {1}".format(artifact_name, artifact_type))
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/376ac438/ambari-server/src/test/python/TestMpacks.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestMpacks.py b/ambari-server/src/test/python/TestMpacks.py
index 0995280..028c461 100644
--- a/ambari-server/src/test/python/TestMpacks.py
+++ b/ambari-server/src/test/python/TestMpacks.py
@@ -404,9 +404,11 @@ class TestMpacks(TestCase):
     os_mkdir_calls = [
       call(os.path.join(common_services_directory, "MYSERVICE"))
     ]
+    create_symlink_calls = [
+      call(os.path.join(mpacks_staging_directory, "common-services/MYSERVICE"),
+           os.path.join(common_services_directory, "MYSERVICE"), "1.0.0", None)
+    ]
     os_symlink_calls = [
-      call(os.path.join(mpacks_staging_directory, "common-services/MYSERVICE/1.0.0"),
-           os.path.join(common_services_directory, "MYSERVICE/1.0.0")),
       call(os.path.join(mpacks_staging_directory, "custom-services/MYSERVICE/1.0.0"),
            os.path.join(stacks_directory, "MYSTACK/1.0/services/MYSERVICE")),
       call(os.path.join(mpacks_staging_directory, "custom-services/MYSERVICE/2.0.0"),
@@ -415,6 +417,7 @@ class TestMpacks(TestCase):
 
     self.assertFalse(purge_stacks_and_mpacks_mock.called)
     os_mkdir_mock.assert_has_calls(os_mkdir_calls)
+    create_symlink_mock.assert_has_calls(create_symlink_calls)
     os_symlink_mock.assert_has_calls(os_symlink_calls)
     self.assertTrue(add_replay_log_mock.called)
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/376ac438/ambari-server/src/test/python/mpacks/myservice-ambari-mpack-1.0.0.0/mpack.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/mpacks/myservice-ambari-mpack-1.0.0.0/mpack.json
b/ambari-server/src/test/python/mpacks/myservice-ambari-mpack-1.0.0.0/mpack.json
index 0af6949..c1736db 100644
--- a/ambari-server/src/test/python/mpacks/myservice-ambari-mpack-1.0.0.0/mpack.json
+++ b/ambari-server/src/test/python/mpacks/myservice-ambari-mpack-1.0.0.0/mpack.json
@@ -14,35 +14,34 @@
   },
   "artifacts": [
     {
-      "name" : "MYSERVICE-service-definition",
-      "type" : "service-definition",
-      "source_dir" : "common-services/MYSERVICE/1.0.0",
-      "service_name" : "MYSERVICE",
-      "service_version" : "1.0.0"
+      "name" : "MYSERVICE-service-definitions",
+      "type" : "service-definitions",
+      "source_dir" : "common-services"
     },
     {
       "name" : "MYSERVICE-1.0.0",
-      "type" : "stack-addon-service-definition",
-      "source_dir": "custom-services/MYSERVICE/1.0.0",
-      "service_name" : "MYSERVICE",
-      "service_version" : "1.0.0",
-      "applicable_stacks" : [
+      "type" : "stack-addon-service-definitions",
+      "source_dir": "custom-services",
+      "service_versions_map": [
         {
-          "stack_name" : "MYSTACK",
-          "stack_version" : "1.0"
-        }
-      ]
-    },
-    {
-      "name" : "MYSERVICE-2.0.0",
-      "type" : "stack-addon-service-definition",
-      "source_dir": "custom-services/MYSERVICE/2.0.0",
-      "service_name" : "MYSERVICE",
-      "service_version" : "2.0.0",
-      "applicable_stacks" : [
+          "service_name" : "MYSERVICE",
+          "service_version" : "1.0.0",
+          "applicable_stacks" : [
+            {
+              "stack_name" : "MYSTACK",
+              "stack_version" : "1.0"
+            }
+          ]
+        },
         {
-          "stack_name" : "MYSTACK",
-          "stack_version" : "2.0"
+          "service_name" : "MYSERVICE",
+          "service_version" : "2.0.0",
+          "applicable_stacks" : [
+            {
+              "stack_name" : "MYSTACK",
+              "stack_version" : "2.0"
+            }
+          ]
         }
       ]
     }


Mime
View raw message