Ver código fonte

AMBARI-11051: [WinTP2] Build choco package for ambari-metrics (jluniya)

Jayush Luniya 10 anos atrás
pai
commit
6dfa245508
25 arquivos alterados com 837 adições e 376 exclusões
  1. 2 1
      ambari-common/src/main/python/resource_management/core/providers/__init__.py
  2. 96 0
      ambari-common/src/main/python/resource_management/core/providers/package/choco.py
  3. 5 3
      ambari-common/src/main/python/resource_management/libraries/script/script.py
  4. 58 146
      ambari-metrics/ambari-metrics-assembly/pom.xml
  5. 51 0
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/collector-windows-choco.xml
  6. 1 7
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/collector-windows.xml
  7. 51 0
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows-choco.xml
  8. 1 7
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows.xml
  9. 51 0
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/sink-windows-choco.xml
  10. 1 5
      ambari-metrics/ambari-metrics-assembly/src/main/assembly/sink-windows.xml
  11. 26 0
      ambari-metrics/ambari-metrics-assembly/src/main/package/choco/collector/ambari-metrics-collector.nuspec
  12. 78 0
      ambari-metrics/ambari-metrics-assembly/src/main/package/choco/collector/chocolateyinstall.ps1
  13. 69 0
      ambari-metrics/ambari-metrics-assembly/src/main/package/choco/collector/chocolateyuninstall.ps1
  14. 26 0
      ambari-metrics/ambari-metrics-assembly/src/main/package/choco/monitor/ambari-metrics-monitor.nuspec
  15. 77 0
      ambari-metrics/ambari-metrics-assembly/src/main/package/choco/monitor/chocolateyinstall.ps1
  16. 69 0
      ambari-metrics/ambari-metrics-assembly/src/main/package/choco/monitor/chocolateyuninstall.ps1
  17. 26 0
      ambari-metrics/ambari-metrics-assembly/src/main/package/choco/sink/ambari-metrics-hadoop-sink.nuspec
  18. 75 0
      ambari-metrics/ambari-metrics-assembly/src/main/package/choco/sink/chocolateyinstall.ps1
  19. 69 0
      ambari-metrics/ambari-metrics-assembly/src/main/package/choco/sink/chocolateyuninstall.ps1
  20. 0 70
      ambari-metrics/ambari-metrics-assembly/src/main/package/msi/collector.wxs
  21. 0 70
      ambari-metrics/ambari-metrics-assembly/src/main/package/msi/monitor.wxs
  22. 0 63
      ambari-metrics/ambari-metrics-assembly/src/main/package/msi/sink.wxs
  23. 1 0
      ambari-metrics/pom.xml
  24. 1 1
      ambari-server/src/main/python/setupAgent.py
  25. 3 3
      ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/metainfo.xml

+ 2 - 1
ambari-common/src/main/python/resource_management/core/providers/__init__.py

@@ -58,7 +58,8 @@ PROVIDERS = dict(
     ServiceConfig="resource_management.core.providers.windows.service.ServiceConfigProvider",
     Execute="resource_management.core.providers.windows.system.ExecuteProvider",
     File="resource_management.core.providers.windows.system.FileProvider",
-    Directory="resource_management.core.providers.windows.system.DirectoryProvider"
+    Directory="resource_management.core.providers.windows.system.DirectoryProvider",
+    Package="resource_management.core.providers.package.choco.ChocoProvider"
   ),
   default=dict(
     File="resource_management.core.providers.system.FileProvider",

+ 96 - 0
ambari-common/src/main/python/resource_management/core/providers/package/choco.py

@@ -0,0 +1,96 @@
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Ambari Agent
+
+"""
+
+from resource_management.core.providers.package import PackageProvider
+from resource_management.core.logger import Logger
+from ambari_commons.shell import shellRunner
+
+import os
+
+INSTALL_CMD = {
+  True: ['cmd', '/c', 'choco', 'install', '--pre', '-y', '-v'],
+  False: ['cmd', '/c', 'choco', 'install', '--pre', '-y'],
+}
+
+UPGRADE_CMD = {
+  True: ['cmd', '/c', 'choco', 'upgrade', '--pre', '-y', '-f', '-v'],
+  False: ['cmd', '/c', 'choco', 'upgrade', '--pre', '-y', '-f'],
+}
+
+REMOVE_CMD = {
+  True: ['cmd', '/c', 'choco', 'uninstall', '-y', '-v'],
+  False: ['cmd', '/c', 'choco', 'uninstall', '-y'],
+}
+
+CHECK_CMD = {
+  True: ['cmd', '/c', 'choco', 'list', '--pre', '--local-only', '-v'],
+  False: ['cmd', '/c', 'choco', 'list', '--pre', '-local-only'],
+}
+
+class ChocoProvider(PackageProvider):
+  def install_package(self, name, use_repos=[]):
+    if not self._check_existence(name) or use_repos:
+      cmd = INSTALL_CMD[self.get_logoutput()]
+      if use_repos:
+        enable_repo_option = '-s' + ",".join(use_repos)
+        cmd = cmd + [enable_repo_option]
+      cmd = cmd + [name]
+      cmdString = " ".join(cmd)
+      Logger.info("Installing package %s ('%s')" % (name, cmdString))
+      runner = shellRunner()
+      res = runner.run(cmd)
+      if res['exitCode'] != 0:
+        raise Exception("Error while installing choco package " + name + ". " + res['error'] + res['output'])
+    else:
+      Logger.info("Skipping installation of existing package %s" % (name))
+
+  def upgrade_package(self, name, use_repos=[]):
+    cmd = UPGRADE_CMD[self.get_logoutput()]
+    if use_repos:
+      enable_repo_option = '-s' + ",".join(use_repos)
+      cmd = cmd + [enable_repo_option]
+    cmd = cmd + [name]
+    cmdString = " ".join(cmd)
+    Logger.info("Upgrading package %s ('%s')" % (name, cmdString))
+    runner = shellRunner()
+    res = runner.run(cmd)
+    if res['exitCode'] != 0:
+      raise Exception("Error while upgrading choco package " + name + ". " + res['error'] + res['output'])
+
+  def remove_package(self, name):
+    if self._check_existence(name):
+      cmd = REMOVE_CMD[self.get_logoutput()] + [name]
+      cmdString = " ".join(cmd)
+      Logger.info("Removing package %s ('%s')" % (name, " ".join(cmd)))
+      runner = shellRunner()
+      res = runner.run(cmd)
+      if res['exitCode'] != 0:
+        raise Exception("Error while upgrading choco package " + name + ". " + res['error'] + res['output'])
+    else:
+      Logger.info("Skipping removal of non-existing package %s" % (name))
+
+  def _check_existence(self, name):
+    cmd = CHECK_CMD[self.get_logoutput()] + [name]
+    runner = shellRunner()
+    res = runner.run(cmd)
+    if name in res['output']:
+      return True
+    return False

+ 5 - 3
ambari-common/src/main/python/resource_management/libraries/script/script.py

@@ -359,10 +359,12 @@ class Script(object):
         for package in package_list:
           if not package['name'] in exclude_packages:
             name = package['name']
+            # HACK: On Windows, only install ambari-metrics packages using Choco Package Installer
+            # TODO: Update this once choco packages for hadoop are created. This is because, service metainfo.xml support
+            # <osFamily>any<osFamily> which would cause installation failure on Windows.
             if OSCheck.is_windows_family():
-              if name[-4:] == ".msi":
-                #TODO all msis must be located in resource folder of server, change it to repo later
-                Msi(name, http_source=os.path.join(config['hostLevelParams']['jdk_location']))
+              if "ambari-metrics" in name:
+                Package(name)
             else:
               Package(name)
     except KeyError:

+ 58 - 146
ambari-metrics/ambari-metrics-assembly/pom.xml

@@ -887,6 +887,9 @@
         <assemblydescriptor.collector>src/main/assembly/collector-windows.xml</assemblydescriptor.collector>
         <assemblydescriptor.monitor>src/main/assembly/monitor-windows.xml</assemblydescriptor.monitor>
         <assemblydescriptor.sink>src/main/assembly/sink-windows.xml</assemblydescriptor.sink>
+        <assemblydescriptor.collector.choco>src/main/assembly/collector-windows-choco.xml</assemblydescriptor.collector.choco>
+        <assemblydescriptor.monitor.choco>src/main/assembly/monitor-windows-choco.xml</assemblydescriptor.monitor.choco>
+        <assemblydescriptor.sink.choco>src/main/assembly/sink-windows-choco.xml</assemblydescriptor.sink.choco>
         <packagingFormat>jar</packagingFormat>
         <python.build.version>2.7</python.build.version>
       </properties>
@@ -913,7 +916,7 @@
       </properties>
     </profile>
     <profile>
-      <id>msi</id>
+      <id>choco</id>
       <activation>
         <os>
           <family>Windows</family>
@@ -921,202 +924,111 @@
       </activation>
       <build>
         <plugins>
-          <!-- msi creation -->
+          <!-- choco package creation -->
           <plugin>
-            <groupId>org.codehaus.mojo</groupId>
-            <artifactId>exec-maven-plugin</artifactId>
-            <version>1.2.1</version>
+            <artifactId>maven-assembly-plugin</artifactId>
             <executions>
               <execution>
-                <id>run-heat-collector</id>
+                <id>collector-choco-dir</id>
                 <phase>package</phase>
                 <goals>
-                  <goal>exec</goal>
+                  <goal>single</goal>
                 </goals>
                 <configuration>
-                  <executable>heat.exe</executable>
-                  <arguments>
-                    <argument>dir</argument>
-                    <argument>"."</argument>
-                    <argument>-dr</argument>
-                    <argument>"COLLECTOR_INSTALL_DIRECTORY"</argument>
-                    <argument>-platform</argument>
-                    <argument>Win64</argument>
-                    <argument>-cg</argument>
-                    <argument>"AmbariMetricsCollectorGroup"</argument>
-                    <argument>-gg</argument>
-                    <argument>-ke</argument>
-                    <argument>-srd</argument>
-                    <argument>-o</argument>
-                    <argument>".\..\collector-files.wxs"</argument>
-                  </arguments>
-                  <workingDirectory>${basedir}/target/ambari-metrics-collector-${project.version}</workingDirectory>
+                  <attach>false</attach>
+                  <finalName>ambari-metrics-collector-${project.version}-choco</finalName>
+                  <appendAssemblyId>false</appendAssemblyId>
+                  <descriptors>
+                    <descriptor>${assemblydescriptor.collector.choco}</descriptor>
+                  </descriptors>
+                  <tarLongFileMode>gnu</tarLongFileMode>
                 </configuration>
               </execution>
               <execution>
-                <id>run-candle-collector</id>
+                <id>monitor-choco-dir</id>
                 <phase>package</phase>
                 <goals>
-                  <goal>exec</goal>
+                  <goal>single</goal>
                 </goals>
                 <configuration>
-                  <executable>candle.exe</executable>
-                  <arguments>
-                    <argument>-arch</argument>
-                    <argument>x64</argument>
-                    <argument>collector.wxs</argument>
-                    <argument>collector-files.wxs</argument>
-                  </arguments>
-                  <workingDirectory>${basedir}/target</workingDirectory>
+                  <attach>false</attach>
+                  <finalName>ambari-metrics-monitor-${project.version}-choco</finalName>
+                  <appendAssemblyId>false</appendAssemblyId>
+                  <descriptors>
+                    <descriptor>${assemblydescriptor.monitor.choco}</descriptor>
+                  </descriptors>
+                  <tarLongFileMode>gnu</tarLongFileMode>
                 </configuration>
               </execution>
               <execution>
-                <id>run-light-collector</id>
+                <id>hadoop-sink-choco-dir</id>
                 <phase>package</phase>
                 <goals>
-                  <goal>exec</goal>
+                  <goal>single</goal>
                 </goals>
                 <configuration>
-                  <executable>light.exe</executable>
-                  <arguments>
-                    <argument>-ext</argument>
-                    <argument>WixUIExtension</argument>
-                    <argument>-b</argument>
-                    <argument>${basedir}/target/ambari-metrics-collector-${project.version}</argument>
-                    <argument>-o</argument>
-                    <argument>ambari-metrics-collector-${project.version}.msi</argument>
-                    <argument>collector.wixobj</argument>
-                    <argument>collector-files.wixobj</argument>
-                  </arguments>
-                  <workingDirectory>${basedir}/target</workingDirectory>
-                </configuration>
-              </execution>
-              <execution>
-                <id>run-heat-monitor</id>
-                <phase>package</phase>
-                <goals>
-                  <goal>exec</goal>
-                </goals>
-                <configuration>
-                  <executable>heat.exe</executable>
-                  <arguments>
-                    <argument>dir</argument>
-                    <argument>"."</argument>
-                    <argument>-dr</argument>
-                    <argument>"MONITOR_INSTALL_DIRECTORY"</argument>
-                    <argument>-platform</argument>
-                    <argument>Win64</argument>
-                    <argument>-cg</argument>
-                    <argument>"AmbariMetricsMonitorGroup"</argument>
-                    <argument>-gg</argument>
-                    <argument>-ke</argument>
-                    <argument>-srd</argument>
-                    <argument>-o</argument>
-                    <argument>".\..\monitor-files.wxs"</argument>
-                  </arguments>
-                  <workingDirectory>${basedir}/target/ambari-metrics-monitor-${project.version}</workingDirectory>
-                </configuration>
-              </execution>
-              <execution>
-                <id>run-candle-monitor</id>
-                <phase>package</phase>
-                <goals>
-                  <goal>exec</goal>
-                </goals>
-                <configuration>
-                  <executable>candle.exe</executable>
-                  <arguments>
-                    <argument>-arch</argument>
-                    <argument>x64</argument>
-                    <argument>monitor.wxs</argument>
-                    <argument>monitor-files.wxs</argument>
-                  </arguments>
-                  <workingDirectory>${basedir}/target</workingDirectory>
-                </configuration>
-              </execution>
-              <execution>
-                <id>run-light-monitor</id>
-                <phase>package</phase>
-                <goals>
-                  <goal>exec</goal>
-                </goals>
-                <configuration>
-                  <executable>light.exe</executable>
-                  <arguments>
-                    <argument>-ext</argument>
-                    <argument>WixUIExtension</argument>
-                    <argument>-b</argument>
-                    <argument>${basedir}/target/ambari-metrics-monitor-${project.version}</argument>
-                    <argument>-o</argument>
-                    <argument>ambari-metrics-monitor-${project.version}.msi</argument>
-                    <argument>monitor.wixobj</argument>
-                    <argument>monitor-files.wixobj</argument>
-                  </arguments>
-                  <workingDirectory>${basedir}/target</workingDirectory>
+                  <attach>false</attach>
+                  <finalName>ambari-metrics-hadoop-sink-${project.version}-choco</finalName>
+                  <appendAssemblyId>false</appendAssemblyId>
+                  <descriptors>
+                    <descriptor>${assemblydescriptor.sink.choco}</descriptor>
+                  </descriptors>
+                  <tarLongFileMode>gnu</tarLongFileMode>
                 </configuration>
               </execution>
+            </executions>
+          </plugin>
+          <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>1.2.1</version>
+            <executions>
               <execution>
-                <id>run-heat-sink</id>
+                <id>collector-choco-package</id>
                 <phase>package</phase>
                 <goals>
                   <goal>exec</goal>
                 </goals>
                 <configuration>
-                  <executable>heat.exe</executable>
+                  <executable>choco.exe</executable>
                   <arguments>
-                    <argument>dir</argument>
-                    <argument>"."</argument>
-                    <argument>-dr</argument>
-                    <argument>"SINK_INSTALL_DIRECTORY"</argument>
-                    <argument>-platform</argument>
-                    <argument>Win64</argument>
-                    <argument>-cg</argument>
-                    <argument>"AmbariMetricsSinkGroup"</argument>
-                    <argument>-gg</argument>
-                    <argument>-ke</argument>
-                    <argument>-srd</argument>
-                    <argument>-o</argument>
-                    <argument>".\..\sink-files.wxs"</argument>
+                    <argument>pack</argument>
+                    <argument>--version=${project.version}</argument>
+                    <argument>${basedir}/target/ambari-metrics-collector-${project.version}-choco/ambari-metrics-collector.nuspec</argument>
                   </arguments>
-                  <workingDirectory>${basedir}/target/ambari-metrics-hadoop-sink-${project.version}</workingDirectory>
+                  <workingDirectory>target/ambari-metrics-collector-${project.version}-choco</workingDirectory>
                 </configuration>
               </execution>
               <execution>
-                <id>run-candle-sink</id>
+                <id>monitor-choco-package</id>
                 <phase>package</phase>
                 <goals>
                   <goal>exec</goal>
                 </goals>
                 <configuration>
-                  <executable>candle.exe</executable>
+                  <executable>choco.exe</executable>
                   <arguments>
-                    <argument>-arch</argument>
-                    <argument>x64</argument>
-                    <argument>sink.wxs</argument>
-                    <argument>sink-files.wxs</argument>
+                    <argument>pack</argument>
+                    <argument>--version=${project.version}</argument>
+                    <argument>${basedir}/target/ambari-metrics-monitor-${project.version}-choco/ambari-metrics-monitor.nuspec</argument>
                   </arguments>
-                  <workingDirectory>${basedir}/target</workingDirectory>
+                  <workingDirectory>target/ambari-metrics-monitor-${project.version}-choco</workingDirectory>
                 </configuration>
               </execution>
               <execution>
-                <id>run-light-sink</id>
+                <id>hadoop-sink-choco-package</id>
                 <phase>package</phase>
                 <goals>
                   <goal>exec</goal>
                 </goals>
                 <configuration>
-                  <executable>light.exe</executable>
+                  <executable>choco.exe</executable>
                   <arguments>
-                    <argument>-ext</argument>
-                    <argument>WixUIExtension</argument>
-                    <argument>-b</argument>
-                    <argument>${basedir}/target/ambari-metrics-hadoop-sink-${project.version}</argument>
-                    <argument>-o</argument>
-                    <argument>ambari-metrics-hadoop-sink-${project.version}.msi</argument>
-                    <argument>sink.wixobj</argument>
-                    <argument>sink-files.wixobj</argument>
+                    <argument>pack</argument>
+                    <argument>--version=${project.version}</argument>
+                    <argument>${basedir}/target/ambari-metrics-hadoop-sink-${project.version}-choco/ambari-metrics-hadoop-sink.nuspec</argument>
                   </arguments>
-                  <workingDirectory>${basedir}/target</workingDirectory>
+                  <workingDirectory>target/ambari-metrics-hadoop-sink-${project.version}-choco</workingDirectory>
                 </configuration>
               </execution>
             </executions>

+ 51 - 0
ambari-metrics/ambari-metrics-assembly/src/main/assembly/collector-windows-choco.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<assembly>
+  <id>choco</id>
+  <formats>
+    <format>dir</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <files>
+    <file>
+      <source>${project.build.directory}/ambari-metrics-collector-${artifact.version}.zip</source>
+      <outputDirectory>content</outputDirectory>
+    </file>
+    <file>
+      <source>${basedir}/src/main/package/choco/collector/ambari-metrics-collector.nuspec</source>
+    </file>
+    <file>
+      <source>${basedir}/src/main/package/choco/collector/chocolateyinstall.ps1</source>
+      <outputDirectory>tools</outputDirectory>
+    </file>
+    <file>
+      <source>${basedir}/src/main/package/choco/collector/chocolateyuninstall.ps1</source>
+      <outputDirectory>tools</outputDirectory>
+    </file>
+  </files>
+  <fileSets>
+    <fileSet>
+      <directory>${basedir}/../../ambari-common/src/main/windows</directory>
+      <outputDirectory>modules</outputDirectory>
+      <includes>
+        <include>*.psm1</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>

+ 1 - 7
ambari-metrics/ambari-metrics-assembly/src/main/assembly/collector-windows.xml

@@ -22,6 +22,7 @@
   <id>collector</id>
   <formats>
     <format>dir</format>
+    <format>zip</format>
   </formats>
   <includeBaseDirectory>false</includeBaseDirectory>
   <fileSets>
@@ -79,13 +80,6 @@
       </includes>
     </fileSet>
   </fileSets>
-  <files>
-    <file>
-      <source>${basedir}/src/main/package/msi/collector.wxs</source>
-      <outputDirectory>../../</outputDirectory>
-      <filtered>true</filtered>
-    </file>
-  </files>
   <dependencySets>
     <dependencySet>
       <unpack>false</unpack>

+ 51 - 0
ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows-choco.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<assembly>
+  <id>choco</id>
+  <formats>
+    <format>dir</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <files>
+    <file>
+      <source>${project.build.directory}/ambari-metrics-monitor-${artifact.version}.zip</source>
+      <outputDirectory>content</outputDirectory>
+    </file>
+    <file>
+      <source>${basedir}/src/main/package/choco/monitor/ambari-metrics-monitor.nuspec</source>
+    </file>
+    <file>
+      <source>${basedir}/src/main/package/choco/monitor/chocolateyinstall.ps1</source>
+      <outputDirectory>tools</outputDirectory>
+    </file>
+    <file>
+      <source>${basedir}/src/main/package/choco/monitor/chocolateyuninstall.ps1</source>
+      <outputDirectory>tools</outputDirectory>
+    </file>
+  </files>
+  <fileSets>
+    <fileSet>
+      <directory>${basedir}/../../ambari-common/src/main/windows</directory>
+      <outputDirectory>modules</outputDirectory>
+      <includes>
+        <include>*.psm1</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>

+ 1 - 7
ambari-metrics/ambari-metrics-assembly/src/main/assembly/monitor-windows.xml

@@ -19,6 +19,7 @@
     <id>windows-dist</id>
   <formats>
     <format>dir</format>
+    <format>zip</format>
   </formats>
   <includeBaseDirectory>false</includeBaseDirectory>
   <fileSets>
@@ -70,13 +71,6 @@
       </includes>
     </fileSet>
   </fileSets>
-  <files>
-    <file>
-      <source>${basedir}/src/main/package/msi/monitor.wxs</source>
-      <outputDirectory>../../</outputDirectory>
-      <filtered>true</filtered>
-    </file>
-  </files>
   <dependencySets>
     <dependencySet>
       <useProjectArtifact>false</useProjectArtifact>

+ 51 - 0
ambari-metrics/ambari-metrics-assembly/src/main/assembly/sink-windows-choco.xml

@@ -0,0 +1,51 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<assembly>
+  <id>choco</id>
+  <formats>
+    <format>dir</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <files>
+    <file>
+      <source>${project.build.directory}/ambari-metrics-hadoop-sink-${artifact.version}.zip</source>
+      <outputDirectory>content</outputDirectory>
+    </file>
+    <file>
+      <source>${basedir}/src/main/package/choco/sink/ambari-metrics-hadoop-sink.nuspec</source>
+    </file>
+    <file>
+      <source>${basedir}/src/main/package/choco/sink/chocolateyinstall.ps1</source>
+      <outputDirectory>tools</outputDirectory>
+    </file>
+    <file>
+      <source>${basedir}/src/main/package/choco/sink/chocolateyuninstall.ps1</source>
+      <outputDirectory>tools</outputDirectory>
+    </file>
+  </files>
+  <fileSets>
+    <fileSet>
+      <directory>${basedir}/../../ambari-common/src/main/windows</directory>
+      <outputDirectory>modules</outputDirectory>
+      <includes>
+        <include>*.psm1</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>

+ 1 - 5
ambari-metrics/ambari-metrics-assembly/src/main/assembly/sink-windows.xml

@@ -22,6 +22,7 @@
   <id>hadoop-sink</id>
   <formats>
     <format>dir</format>
+    <format>zip</format>
   </formats>
   <includeBaseDirectory>false</includeBaseDirectory>
   <fileSets>
@@ -60,11 +61,6 @@
       <source>${kafka-sink.dir}/target/ambari-metrics-kafka-sink-with-common-${project.version}.jar</source>
       <outputDirectory>hadoop-sink</outputDirectory>
     </file>
-    <file>
-      <source>${basedir}/src/main/package/msi/sink.wxs</source>
-      <outputDirectory>../../</outputDirectory>
-      <filtered>true</filtered>
-    </file>
   </files>
 
 

+ 26 - 0
ambari-metrics/ambari-metrics-assembly/src/main/package/choco/collector/ambari-metrics-collector.nuspec

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+  <metadata>
+    <!-- Read this before publishing packages to chocolatey.org: https://github.com/chocolatey/chocolatey/wiki/CreatePackages -->
+    <id>ambari-metrics-collector</id>
+    <title>Ambari Metrics Collector</title>
+    <version>1.0</version>
+    <authors>Apache Ambari</authors>
+    <owners>Apache Ambari</owners>
+    <summary>Ambari Metrics Collector</summary>
+    <description>Ambari Metrics Collector
+    </description>
+    <projectUrl>http://ambari.apache.org</projectUrl>
+    <tags>ambari-metrics-collector</tags>
+    <copyright>https://github.com/apache/ambari/blob/trunk/NOTICE.txt</copyright>
+    <licenseUrl>https://github.com/apache/ambari/blob/trunk/LICENSE.txt</licenseUrl>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <releaseNotes></releaseNotes>
+  </metadata>
+  <files>
+    <file src="tools\**" target="tools" />
+    <file src="content\**" target="content" />
+    <file src="modules\**" target="modules" />
+  </files>
+</package>

+ 78 - 0
ambari-metrics/ambari-metrics-assembly/src/main/package/choco/collector/chocolateyinstall.ps1

@@ -0,0 +1,78 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+# Stop on all errors
+$ErrorActionPreference = 'Stop';
+
+# Package Name
+$packageName = $Env:chocolateyPackageName
+# Package Version
+$packageVersion = $Env:chocolateyPackageVersion
+# Package Folder
+$packageFolder = $Env:chocolateyPackageFolder
+# Package Parameters
+$packageParameters = $env:chocolateyPackageParameters
+
+$arguments = @{}
+$ambariRoot = "C:\ambari"
+$retries = 5
+# Parse the packageParameters
+#   /AmbariRoot:C:\ambari /Retries:5
+if ($packageParameters) {
+  $match_pattern = "\/(?<option>([a-zA-Z]+)):(?<value>([`"'])?([a-zA-Z0-9- _\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
+  $option_name = 'option'
+  $value_name = 'value'
+
+  if ($packageParameters -match $match_pattern ){
+    $results = $packageParameters | Select-String $match_pattern -AllMatches
+    $results.matches | % {
+      $arguments.Add(
+        $_.Groups[$option_name].Value.Trim(),
+        $_.Groups[$value_name].Value.Trim())
+    }
+  } else {
+    Throw "Package Parameters were found but were invalid (REGEX Failure)"
+  }
+  if ($arguments.ContainsKey("AmbariRoot")) {
+    Write-Debug "AmbariRoot Argument Found"
+    $ambariRoot = $arguments["AmbariRoot"]
+  }
+  if ($arguments.ContainsKey("Retries")) {
+    Write-Debug "Retries Argument Found"
+    $retries = $arguments["Retries"]
+  }
+} else {
+  Write-Debug "No Package Parameters Passed in"
+}
+
+$modulesFolder = "$(Join-Path $packageFolder modules)"
+$contentFolder = "$(Join-Path $packageFolder content)"
+$zipFile = "$(Join-Path $contentFolder $packageName-$packageVersion.zip)"
+$specificFolder = ""
+$link = "$ambariRoot\$packageName"
+$target = "$ambariRoot\$packageName-$packageVersion"
+$collectorHome = $link
+$collectorConfDir = "$link\conf"
+
+Import-Module "$modulesFolder\link.psm1"
+Import-Module "$modulesFolder\retry.psm1"
+
+Retry-Command -Command "Get-ChocolateyUnzip" -Arguments @{ FileFullPath = $zipFile; Destination = $target; SpecificFolder = $specificFolder; PackageName = $packageName} -Retries $retries
+Retry-Command -Command "Remove-Symlink-IfExists" -Arguments @{Link = $link} -Retries $retries
+Retry-Command -Command "New-Symlink" -Arguments @{ Link = $link; Target = $target } -Retries $retries
+
+[Environment]::SetEnvironmentVariable("COLLECTOR_HOME", $collectorHome, "Machine")
+[Environment]::SetEnvironmentVariable("COLLECTOR_CONF_DIR", $collectorConfDir, "Machine")
+

+ 69 - 0
ambari-metrics/ambari-metrics-assembly/src/main/package/choco/collector/chocolateyuninstall.ps1

@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+# Stop on all errors
+$ErrorActionPreference = 'Stop';
+
+# Package Name
+$packageName = $Env:chocolateyPackageName
+# Package Version
+$packageVersion = $Env:chocolateyPackageVersion
+# Package Folder
+$packageFolder = $Env:chocolateyPackageFolder
+# Package Parameters
+$packageParameters = $env:chocolateyPackageParameters
+
+$arguments = @{}
+$ambariRoot = "C:\ambari"
+$retries = 5
+# Parse the packageParameters
+#   /AmbariRoot:C:\ambari /Retries:5
+if ($packageParameters) {
+  $match_pattern = "\/(?<option>([a-zA-Z]+)):(?<value>([`"'])?([a-zA-Z0-9- _\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
+  $option_name = 'option'
+  $value_name = 'value'
+
+  if ($packageParameters -match $match_pattern ){
+    $results = $packageParameters | Select-String $match_pattern -AllMatches
+    $results.matches | % {
+      $arguments.Add(
+        $_.Groups[$option_name].Value.Trim(),
+        $_.Groups[$value_name].Value.Trim())
+    }
+  } else {
+    Throw "Package Parameters were found but were invalid (REGEX Failure)"
+  }
+  if ($arguments.ContainsKey("AmbariRoot")) {
+    Write-Debug "AmbariRoot Argument Found"
+    $ambariRoot = $arguments["AmbariRoot"]
+  }
+  if ($arguments.ContainsKey("Retries")) {
+    Write-Debug "Retries Argument Found"
+    $retries = $arguments["Retries"]
+  }
+} else {
+  Write-Debug "No Package Parameters Passed in"
+}
+
+$modulesFolder = "$(Join-Path $packageFolder modules)"
+$contentFolder = "$(Join-Path $packageFolder content)"
+$link = "$ambariRoot\$packageName"
+$target = "$ambariRoot\$packageName-$packageVersion"
+
+Import-Module "$modulesFolder\link.psm1"
+Import-Module "$modulesFolder\retry.psm1"
+
+Retry-Command -Command "Remove-Symlink-IfExists" -Arguments @{Link = $link} -Retries $retries
+Retry-Command -Command "Remove-Item" -Arguments @{ Path = $target; Recurse = $true; Force = $true }

+ 26 - 0
ambari-metrics/ambari-metrics-assembly/src/main/package/choco/monitor/ambari-metrics-monitor.nuspec

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+  <metadata>
+    <!-- Read this before publishing packages to chocolatey.org: https://github.com/chocolatey/chocolatey/wiki/CreatePackages -->
+    <id>ambari-metrics-monitor</id>
+    <title>Ambari Metrics Monitor</title>
+    <version>1.0</version>
+    <authors>Apache Ambari</authors>
+    <owners>Apache Ambari</owners>
+    <summary>Ambari Metrics Monitor</summary>
+    <description>Ambari Metrics Monitor
+    </description>
+    <projectUrl>http://ambari.apache.org</projectUrl>
+    <tags>ambari-metrics-monitor</tags>
+    <copyright>https://github.com/apache/ambari/blob/trunk/NOTICE.txt</copyright>
+    <licenseUrl>https://github.com/apache/ambari/blob/trunk/LICENSE.txt</licenseUrl>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <releaseNotes></releaseNotes>
+  </metadata>
+  <files>
+    <file src="tools\**" target="tools" />
+    <file src="content\**" target="content" />
+    <file src="modules\**" target="modules" />
+  </files>
+</package>

+ 77 - 0
ambari-metrics/ambari-metrics-assembly/src/main/package/choco/monitor/chocolateyinstall.ps1

@@ -0,0 +1,77 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+# Stop on all errors
+$ErrorActionPreference = 'Stop';
+
+# Package Name
+$packageName = $Env:chocolateyPackageName
+# Package Version
+$packageVersion = $Env:chocolateyPackageVersion
+# Package Folder
+$packageFolder = $Env:chocolateyPackageFolder
+# Package Parameters
+$packageParameters = $env:chocolateyPackageParameters
+
+$arguments = @{}
+$ambariRoot = "C:\ambari"
+$retries = 5
+# Parse the packageParameters
+#   /AmbariRoot:C:\ambari /Retries:5
+if ($packageParameters) {
+  $match_pattern = "\/(?<option>([a-zA-Z]+)):(?<value>([`"'])?([a-zA-Z0-9- _\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
+  $option_name = 'option'
+  $value_name = 'value'
+
+  if ($packageParameters -match $match_pattern ){
+    $results = $packageParameters | Select-String $match_pattern -AllMatches
+    $results.matches | % {
+      $arguments.Add(
+        $_.Groups[$option_name].Value.Trim(),
+        $_.Groups[$value_name].Value.Trim())
+    }
+  } else {
+    Throw "Package Parameters were found but were invalid (REGEX Failure)"
+  }
+  if ($arguments.ContainsKey("AmbariRoot")) {
+    Write-Debug "AmbariRoot Argument Found"
+    $ambariRoot = $arguments["AmbariRoot"]
+  }
+  if ($arguments.ContainsKey("Retries")) {
+    Write-Debug "Retries Argument Found"
+    $retries = $arguments["Retries"]
+  }
+} else {
+  Write-Debug "No Package Parameters Passed in"
+}
+
+$modulesFolder = "$(Join-Path $packageFolder modules)"
+$contentFolder = "$(Join-Path $packageFolder content)"
+$zipFile = "$(Join-Path $contentFolder $packageName-$packageVersion.zip)"
+$specificFolder = ""
+$link = "$ambariRoot\$packageName"
+$target = "$ambariRoot\$packageName-$packageVersion"
+$monitorHome = $link
+$monitorConfDir = "$link\conf"
+
+Import-Module "$modulesFolder\link.psm1"
+Import-Module "$modulesFolder\retry.psm1"
+
+Retry-Command -Command "Get-ChocolateyUnzip" -Arguments @{ FileFullPath = $zipFile; Destination = $target; SpecificFolder = $specificFolder; PackageName = $packageName} -Retries $retries
+Retry-Command -Command "Remove-Symlink-IfExists" -Arguments @{Link = $link} -Retries $retries
+Retry-Command -Command "New-Symlink" -Arguments @{ Link = $link; Target = $target } -Retries $retries
+
+[Environment]::SetEnvironmentVariable("MONITOR_HOME", $monitorHome, "Machine")
+[Environment]::SetEnvironmentVariable("MONITOR_CONF_DIR", $monitorConfDir, "Machine")

+ 69 - 0
ambari-metrics/ambari-metrics-assembly/src/main/package/choco/monitor/chocolateyuninstall.ps1

@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+# Stop on all errors
+$ErrorActionPreference = 'Stop';
+
+# Package Name
+$packageName = $Env:chocolateyPackageName
+# Package Version
+$packageVersion = $Env:chocolateyPackageVersion
+# Package Folder
+$packageFolder = $Env:chocolateyPackageFolder
+# Package Parameters
+$packageParameters = $env:chocolateyPackageParameters
+
+$arguments = @{}
+$ambariRoot = "C:\ambari"
+$retries = 5
+# Parse the packageParameters
+#   /AmbariRoot:C:\ambari /Retries:5
+if ($packageParameters) {
+  $match_pattern = "\/(?<option>([a-zA-Z]+)):(?<value>([`"'])?([a-zA-Z0-9- _\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
+  $option_name = 'option'
+  $value_name = 'value'
+
+  if ($packageParameters -match $match_pattern ){
+    $results = $packageParameters | Select-String $match_pattern -AllMatches
+    $results.matches | % {
+      $arguments.Add(
+        $_.Groups[$option_name].Value.Trim(),
+        $_.Groups[$value_name].Value.Trim())
+    }
+  } else {
+    Throw "Package Parameters were found but were invalid (REGEX Failure)"
+  }
+  if ($arguments.ContainsKey("AmbariRoot")) {
+    Write-Debug "AmbariRoot Argument Found"
+    $ambariRoot = $arguments["AmbariRoot"]
+  }
+  if ($arguments.ContainsKey("Retries")) {
+    Write-Debug "Retries Argument Found"
+    $retries = $arguments["Retries"]
+  }
+} else {
+  Write-Debug "No Package Parameters Passed in"
+}
+
+$modulesFolder = "$(Join-Path $packageFolder modules)"
+$contentFolder = "$(Join-Path $packageFolder content)"
+$link = "$ambariRoot\$packageName"
+$target = "$ambariRoot\$packageName-$packageVersion"
+
+Import-Module "$modulesFolder\link.psm1"
+Import-Module "$modulesFolder\retry.psm1"
+
+Retry-Command -Command "Remove-Symlink-IfExists" -Arguments @{Link = $link} -Retries $retries
+Retry-Command -Command "Remove-Item" -Arguments @{ Path = $target; Recurse = $true; Force = $true }

+ 26 - 0
ambari-metrics/ambari-metrics-assembly/src/main/package/choco/sink/ambari-metrics-hadoop-sink.nuspec

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+  <metadata>
+    <!-- Read this before publishing packages to chocolatey.org: https://github.com/chocolatey/chocolatey/wiki/CreatePackages -->
+    <id>ambari-metrics-hadoop-sink</id>
+    <title>Ambari Metrics Hadoop Sink</title>
+    <version>1.0</version>
+    <authors>Apache Ambari</authors>
+    <owners>Apache Ambari</owners>
+    <summary>Ambari Metrics Hadoop Sink</summary>
+    <description>Ambari Metrics Hadoop Sink
+    </description>
+    <projectUrl>http://ambari.apache.org</projectUrl>
+    <tags>ambari-metrics-hadoop-sink</tags>
+    <copyright>https://github.com/apache/ambari/blob/trunk/NOTICE.txt</copyright>
+    <licenseUrl>https://github.com/apache/ambari/blob/trunk/LICENSE.txt</licenseUrl>
+    <requireLicenseAcceptance>false</requireLicenseAcceptance>
+    <releaseNotes></releaseNotes>
+  </metadata>
+  <files>
+    <file src="tools\**" target="tools" />
+    <file src="content\**" target="content" />
+    <file src="modules\**" target="modules" />
+  </files>
+</package>

+ 75 - 0
ambari-metrics/ambari-metrics-assembly/src/main/package/choco/sink/chocolateyinstall.ps1

@@ -0,0 +1,75 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+# Stop on all errors
+$ErrorActionPreference = 'Stop';
+
+# Package Name
+$packageName = $Env:chocolateyPackageName
+# Package Version
+$packageVersion = $Env:chocolateyPackageVersion
+# Package Folder
+$packageFolder = $Env:chocolateyPackageFolder
+# Package Parameters
+$packageParameters = $env:chocolateyPackageParameters
+
+$arguments = @{}
+$ambariRoot = "C:\ambari"
+$retries = 5
+# Parse the packageParameters
+#   /AmbariRoot:C:\ambari /Retries:5
+if ($packageParameters) {
+  $match_pattern = "\/(?<option>([a-zA-Z]+)):(?<value>([`"'])?([a-zA-Z0-9- _\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
+  $option_name = 'option'
+  $value_name = 'value'
+
+  if ($packageParameters -match $match_pattern ){
+    $results = $packageParameters | Select-String $match_pattern -AllMatches
+    $results.matches | % {
+      $arguments.Add(
+        $_.Groups[$option_name].Value.Trim(),
+        $_.Groups[$value_name].Value.Trim())
+    }
+  } else {
+    Throw "Package Parameters were found but were invalid (REGEX Failure)"
+  }
+  if ($arguments.ContainsKey("AmbariRoot")) {
+    Write-Debug "AmbariRoot Argument Found"
+    $ambariRoot = $arguments["AmbariRoot"]
+  }
+  if ($arguments.ContainsKey("Retries")) {
+    Write-Debug "Retries Argument Found"
+    $retries = $arguments["Retries"]
+  }
+} else {
+  Write-Debug "No Package Parameters Passed in"
+}
+
+$modulesFolder = "$(Join-Path $packageFolder modules)"
+$contentFolder = "$(Join-Path $packageFolder content)"
+$zipFile = "$(Join-Path $contentFolder $packageName-$packageVersion.zip)"
+$specificFolder = ""
+$link = "$ambariRoot\$packageName"
+$target = "$ambariRoot\$packageName-$packageVersion"
+$sinkHome = $link
+
+Import-Module "$modulesFolder\link.psm1"
+Import-Module "$modulesFolder\retry.psm1"
+
+Retry-Command -Command "Get-ChocolateyUnzip" -Arguments @{ FileFullPath = $zipFile; Destination = $target; SpecificFolder = $specificFolder; PackageName = $packageName} -Retries $retries
+Retry-Command -Command "Remove-Symlink-IfExists" -Arguments @{Link = $link} -Retries $retries
+Retry-Command -Command "New-Symlink" -Arguments @{ Link = $link; Target = $target } -Retries $retries
+
+[Environment]::SetEnvironmentVariable("SINK_HOME", $sinkHome, "Machine")

+ 69 - 0
ambari-metrics/ambari-metrics-assembly/src/main/package/choco/sink/chocolateyuninstall.ps1

@@ -0,0 +1,69 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You 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
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+# Stop on all errors
+$ErrorActionPreference = 'Stop';
+
+# Package Name
+$packageName = $Env:chocolateyPackageName
+# Package Version
+$packageVersion = $Env:chocolateyPackageVersion
+# Package Folder
+$packageFolder = $Env:chocolateyPackageFolder
+# Package Parameters
+$packageParameters = $env:chocolateyPackageParameters
+
+$arguments = @{}
+$ambariRoot = "C:\ambari"
+$retries = 5
+# Parse the packageParameters
+#   /AmbariRoot:C:\ambari /Retries:5
+if ($packageParameters) {
+  $match_pattern = "\/(?<option>([a-zA-Z]+)):(?<value>([`"'])?([a-zA-Z0-9- _\\:\.]+)([`"'])?)|\/(?<option>([a-zA-Z]+))"
+  $option_name = 'option'
+  $value_name = 'value'
+
+  if ($packageParameters -match $match_pattern ){
+    $results = $packageParameters | Select-String $match_pattern -AllMatches
+    $results.matches | % {
+      $arguments.Add(
+        $_.Groups[$option_name].Value.Trim(),
+        $_.Groups[$value_name].Value.Trim())
+    }
+  } else {
+    Throw "Package Parameters were found but were invalid (REGEX Failure)"
+  }
+  if ($arguments.ContainsKey("AmbariRoot")) {
+    Write-Debug "AmbariRoot Argument Found"
+    $ambariRoot = $arguments["AmbariRoot"]
+  }
+  if ($arguments.ContainsKey("Retries")) {
+    Write-Debug "Retries Argument Found"
+    $retries = $arguments["Retries"]
+  }
+} else {
+  Write-Debug "No Package Parameters Passed in"
+}
+
+$modulesFolder = "$(Join-Path $packageFolder modules)"
+$contentFolder = "$(Join-Path $packageFolder content)"
+$link = "$ambariRoot\$packageName"
+$target = "$ambariRoot\$packageName-$packageVersion"
+
+Import-Module "$modulesFolder\link.psm1"
+Import-Module "$modulesFolder\retry.psm1"
+
+Retry-Command -Command "Remove-Symlink-IfExists" -Arguments @{Link = $link} -Retries $retries
+Retry-Command -Command "Remove-Item" -Arguments @{ Path = $target; Recurse = $true; Force = $true }

+ 0 - 70
ambari-metrics/ambari-metrics-assembly/src/main/package/msi/collector.wxs

@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You 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
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-  <?define Version = "${package-version}" ?>
-  <Product Id="0b8d60bc-e702-42ea-8321-a6d627aba444" Name="Ambari Metrics Collector $(var.Version)" Language="1033"
-           Version="$(var.Version)" Manufacturer="Apache Software Foundation">
-    <Package Description="Ambari Metrics Collector for Windows" Comments="Ambari Metrics Collector" InstallerVersion="200"
-             Compressed="yes" Platform="x64"/>
-
-    <Media Id="1" Cabinet="simple.cab" EmbedCab="yes"/>
-    <Directory Id="TARGETDIR" Name="SourceDir" >
-      <Directory Id="AmbariDirectory" Name="ambari">
-        <Directory Id="COLLECTOR_INSTALL_DIRECTORY" Name="ambari-metrics-collector-$(var.Version)">
-          <Component Id="ENV_VARS" Guid="{eb0843bd-2bdc-4aa0-99f1-23b54c7840a7}">
-            <!--we need this to allow reference on SINK_INSTALL_DIRECTORY-->
-            <CreateFolder/>
-            <Environment Id="COLLECTOR_HOME_ENV_VAR"
-                         Action="set"
-                         Part="all"
-                         Name="COLLECTOR_HOME"
-                         Permanent="no"
-                         System="yes"
-                         Value="[COLLECTOR_INSTALL_DIRECTORY]" />
-            <Environment Id="COLLECTOR_CONF_DIR_ENV_VAR"
-                         Action="set"
-                         Part="all"
-                         Name="COLLECTOR_CONF_DIR"
-                         Permanent="no"
-                         System="yes"
-                         Value="[COLLECTOR_INSTALL_DIRECTORY]conf" />
-          </Component>
-        </Directory>
-      </Directory>
-    </Directory>
-
-    <Feature Id="DefaultFeature" Title="Main Feature" Level="1">
-      <ComponentGroupRef Id="AmbariMetricsCollectorGroup"/>
-      <ComponentRef Id="ENV_VARS" />
-    </Feature>
-    <Property Id="WIXUI_INSTALLDIR" Value="COLLECTOR_INSTALL_DIRECTORY"/>
-    <UI>
-      <UIRef Id="WixUI_InstallDir" />
-      <Publish Dialog="WelcomeDlg"
-               Control="Next"
-               Event="NewDialog"
-               Value="InstallDirDlg"
-               Order="2">1</Publish>
-      <Publish Dialog="InstallDirDlg"
-               Control="Back"
-               Event="NewDialog"
-               Value="WelcomeDlg"
-               Order="2">1</Publish>
-    </UI>
-  </Product>
-</Wix>

+ 0 - 70
ambari-metrics/ambari-metrics-assembly/src/main/package/msi/monitor.wxs

@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You 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
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-  <?define Version = "${package-version}" ?>
-  <Product Id="8f6f5126-2bca-4f62-9940-fb7934477d01" Name="Ambari Metrics Monitor $(var.Version)" Language="1033"
-           Version="$(var.Version)" Manufacturer="Apache Software Foundation">
-    <Package Description="Ambari Metrics Monitor for Windows" Comments="Ambari Metrics Monitor" InstallerVersion="200"
-             Compressed="yes" Platform="x64"/>
-
-    <Media Id="1" Cabinet="simple.cab" EmbedCab="yes"/>
-    <Directory Id="TARGETDIR" Name="SourceDir" >
-      <Directory Id="AmbariDirectory" Name="ambari">
-        <Directory Id="MONITOR_INSTALL_DIRECTORY" Name="ambari-metrics-monitor-$(var.Version)">
-          <Component Id="ENV_VARS" Guid="{a13efdb1-8afb-4c7d-a424-c44d4e7f36ad}">
-            <!--we need this to allow reference on SINK_INSTALL_DIRECTORY-->
-            <CreateFolder/>
-            <Environment Id="MONITOR_HOME_ENV_VAR"
-                         Action="set"
-                         Part="all"
-                         Name="MONITOR_HOME"
-                         Permanent="no"
-                         System="yes"
-                         Value="[MONITOR_INSTALL_DIRECTORY]" />
-            <Environment Id="MONITOR_CONF_DIR_ENV_VAR"
-                         Action="set"
-                         Part="all"
-                         Name="MONITOR_CONF_DIR"
-                         Permanent="no"
-                         System="yes"
-                         Value="[MONITOR_INSTALL_DIRECTORY]conf" />
-          </Component>
-        </Directory>
-      </Directory>
-    </Directory>
-
-    <Feature Id="DefaultFeature" Title="Main Feature" Level="1">
-      <ComponentGroupRef Id="AmbariMetricsMonitorGroup"/>
-      <ComponentRef Id="ENV_VARS" />
-    </Feature>
-    <Property Id="WIXUI_INSTALLDIR" Value="MONITOR_INSTALL_DIRECTORY"/>
-    <UI>
-      <UIRef Id="WixUI_InstallDir" />
-      <Publish Dialog="WelcomeDlg"
-               Control="Next"
-               Event="NewDialog"
-               Value="InstallDirDlg"
-               Order="2">1</Publish>
-      <Publish Dialog="InstallDirDlg"
-               Control="Back"
-               Event="NewDialog"
-               Value="WelcomeDlg"
-               Order="2">1</Publish>
-    </UI>
-  </Product>
-</Wix>

+ 0 - 63
ambari-metrics/ambari-metrics-assembly/src/main/package/msi/sink.wxs

@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You 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
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
-  <?define Version = "${package-version}" ?>
-  <Product Id="be90762d-4036-45ab-8b40-e73601eb898b" Name="Ambari Metrics Hadoop Sink $(var.Version)" Language="1033"
-           Version="$(var.Version)" Manufacturer="Apache Software Foundation">
-    <Package Description="Ambari Metrics Hadoop Sink for Windows" Comments="Ambari Metrics Hadoop Sink" InstallerVersion="200"
-             Compressed="yes" Platform="x64"/>
-
-    <Media Id="1" Cabinet="simple.cab" EmbedCab="yes"/>
-    <Directory Id="TARGETDIR" Name="SourceDir" >
-      <Directory Id="AmbariDirectory" Name="ambari">
-        <Directory Id="SINK_INSTALL_DIRECTORY" Name="ambari-metrics-hadoop-sink-$(var.Version)">
-          <Component Id="ENV_VARS" Guid="{2a531dad-2d1f-4d1d-a344-63b6d2e57684}">
-            <!--we need this to allow reference on SINK_INSTALL_DIRECTORY-->
-            <CreateFolder/>
-            <Environment Id="SINK_HOME_ENV_VAR"
-                         Action="set"
-                         Part="all"
-                         Name="SINK_HOME"
-                         Permanent="no"
-                         System="yes"
-                         Value="[SINK_INSTALL_DIRECTORY]" />
-          </Component>
-        </Directory>
-      </Directory>
-    </Directory>
-
-    <Feature Id="DefaultFeature" Title="Main Feature" Level="1">
-      <ComponentGroupRef Id="AmbariMetricsSinkGroup"/>
-      <ComponentRef Id="ENV_VARS" />
-    </Feature>
-    <Property Id="WIXUI_INSTALLDIR" Value="SINK_INSTALL_DIRECTORY"/>
-    <UI>
-      <UIRef Id="WixUI_InstallDir" />
-      <Publish Dialog="WelcomeDlg"
-               Control="Next"
-               Event="NewDialog"
-               Value="InstallDirDlg"
-               Order="2">1</Publish>
-      <Publish Dialog="InstallDirDlg"
-               Control="Back"
-               Event="NewDialog"
-               Value="WelcomeDlg"
-               Order="2">1</Publish>
-    </UI>
-  </Product>
-</Wix>

+ 1 - 0
ambari-metrics/pom.xml

@@ -214,6 +214,7 @@
           <excludes>
             <exclude>pass.txt</exclude>
             <exclude>derby.log</exclude>
+            <exclude>**/*.nuspec</exclude>
           </excludes>
         </configuration>
         <executions>

+ 1 - 1
ambari-server/src/main/python/setupAgent.py

@@ -258,7 +258,7 @@ def isAgentPackageAlreadyInstalled(projectVersion):
     if OSCheck.is_ubuntu_family():
       Command = ["bash", "-c", "dpkg-query -W -f='${Status} ${Version}\n' ambari-agent | grep -v deinstall | grep " + projectVersion]
     elif OSCheck.is_windows_family():
-      Command = ["cmd", "/c", "choco list ambari-agent --local-only | findstr ambari-agent"]
+      Command = ["cmd", "/c", "choco list ambari-agent --local-only | findstr ambari-agent | findstr " + projectVersion]
     else:
       Command = ["bash", "-c", "rpm -qa | grep ambari-agent-"+projectVersion]
     ret = execOsCommand(Command)

+ 3 - 3
ambari-server/src/main/resources/common-services/AMBARI_METRICS/0.1.0/metainfo.xml

@@ -96,13 +96,13 @@
           <osFamily>winsrv6</osFamily>
           <packages>
             <package>
-              <name>ambari-metrics-collector.msi</name>
+              <name>ambari-metrics-collector</name>
             </package>
             <package>
-              <name>ambari-metrics-monitor.msi</name>
+              <name>ambari-metrics-monitor</name>
             </package>
             <package>
-              <name>ambari-metrics-hadoop-sink.msi</name>
+              <name>ambari-metrics-hadoop-sink</name>
             </package>
           </packages>
         </osSpecific>