You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2013/10/18 02:25:26 UTC

[04/30] AMBARI-3266. Contribute Ambari-SCOM. (Tom Beerbower via mahadev)

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/resources/winpkg.utils.psm1
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/resources/winpkg.utils.psm1 b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/resources/winpkg.utils.psm1
new file mode 100644
index 0000000..8ff3276
--- /dev/null
+++ b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/resources/winpkg.utils.psm1
@@ -0,0 +1,273 @@
+### 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.
+
+
+### NOTE: This file is common across the Windows installer projects for Hadoop Core, Hive, and Pig.
+### This dependency is currently managed by convention.
+### If you find yourself needing to change something in this file, it's likely that you're
+### either doing something that's more easily done outside this file or is a bigger change
+### that likely has wider ramifications. Work intentionally.
+
+
+param( [parameter( Position=0, Mandatory=$true)]
+       [String]  $ComponentName )
+
+function Write-Log ($message, $level, $pipelineObj )
+{
+    $message = SanitizeString $message
+    switch($level)
+    {
+        "Failure" 
+        {
+            $message = "$ComponentName FAILURE: $message"
+            Write-Error $message 
+            break;
+        }
+
+        "Info"
+        {
+            $message = "${ComponentName}: $message"
+            Write-Host $message
+            break;
+        }
+
+        default
+        {
+            $message = "${ComponentName}: $message"
+            Write-Host "$message"
+        }
+    }
+
+    
+    Out-File -FilePath $ENV:WINPKG_LOG -InputObject "$message" -Append -Encoding "UTF8"
+
+    if( $pipelineObj -ne $null )
+    {
+        Out-File -FilePath $ENV:WINPKG_LOG -InputObject $pipelineObj.InvocationInfo.PositionMessage -Append -Encoding "UTF8"
+    }
+}
+
+function Write-LogRecord( $source, $record )
+{
+    if( $record -is [Management.Automation.ErrorRecord])
+    {
+        $message = "$ComponentName-$source FAILURE: " + $record.Exception.Message
+        $message = SanitizeString $message
+
+        if( $message.EndsWith( [Environment]::NewLine ))
+        {
+            Write-Host $message -NoNewline
+            [IO.File]::AppendAllText( "$ENV:WINPKG_LOG", "$message", [Text.Encoding]::UTF8 )
+        }
+        else
+        {
+            Write-Host $message
+            Out-File -FilePath $ENV:WINPKG_LOG -InputObject $message -Append -Encoding "UTF8"
+        }
+    }
+    else
+    {
+        $message = $record
+        $message = SanitizeString $message
+        Write-Host $message
+        Out-File -FilePath $ENV:WINPKG_LOG -InputObject "$message" -Append -Encoding "UTF8"
+    }
+}
+
+function SanitizeString($s)
+{
+    $s -replace "-password([a-z0-9]*) (\S*)", '-password$1 ****'
+}
+
+function Invoke-Cmd ($command)
+{
+    Write-Log $command
+    $out = cmd.exe /C "$command" 2>&1
+    $out | ForEach-Object { Write-LogRecord "CMD" $_ }
+    return $out
+}
+
+function Invoke-CmdChk ($command)
+{
+    Write-Log $command
+    $out = cmd.exe /C "$command" 2>&1
+    $out | ForEach-Object { Write-LogRecord "CMD" $_ }
+    if (-not ($LastExitCode  -eq 0))
+    {
+        throw "Command `"$out`" failed with exit code $LastExitCode "
+    }
+    return $out
+}
+
+function Invoke-Ps ($command)
+{
+    Write-Log $command
+    $out = powershell.exe -InputFormat none -Command "$command" 2>&1
+    #$out | ForEach-Object { Write-LogRecord "PS" $_ }
+    return $out
+}
+
+function Invoke-PsChk ($command)
+{
+    Write-Log $command
+    $out = powershell.exe -InputFormat none -Command $command 2>&1
+    $captureExitCode = $LastExitCode
+	$out | ForEach-Object { Write-LogRecord "PS" $_ }
+	if (-not ($captureExitCode  -eq 0))
+    {
+        throw "Command `"$command`" failed with exit code  $captureExitCode. Output is  `"$out`" "
+    }
+    return $out
+}
+
+
+function Test-JavaHome
+{
+    if( -not (Test-Path $ENV:JAVA_HOME\bin\java.exe))
+    {
+        throw "JAVA_HOME not set properly; $ENV:JAVA_HOME\bin\java.exe does not exist"
+    }
+}
+
+### Add service control permissions to authenticated users.
+### Reference:
+### http://stackoverflow.com/questions/4436558/start-stop-a-windows-service-from-a-non-administrator-user-account 
+### http://msmvps.com/blogs/erikr/archive/2007/09/26/set-permissions-on-a-specific-service-windows.aspx
+
+function Set-ServiceAcl ($service)
+{
+    $cmd = "sc sdshow $service"
+    $sd = Invoke-Cmd $cmd
+
+    Write-Log "Current SD: $sd"
+
+    ## A;; --- allow
+    ## RP ---- SERVICE_START
+    ## WP ---- SERVICE_STOP
+    ## CR ---- SERVICE_USER_DEFINED_CONTROL    
+    ## ;;;AU - AUTHENTICATED_USERS
+
+    $sd = [String]$sd
+    $sd = $sd.Replace( "S:(", "(A;;RPWPCR;;;AU)S:(" )
+    Write-Log "Modifying SD to: $sd"
+
+    $cmd = "sc sdset $service $sd"
+    Invoke-Cmd $cmd
+}
+
+function Expand-String([string] $source)
+{
+    return $ExecutionContext.InvokeCommand.ExpandString((($source -replace '"', '`"') -replace '''', '`'''))
+}
+
+function Copy-XmlTemplate( [string][parameter( Position=1, Mandatory=$true)] $Source,
+       [string][parameter( Position=2, Mandatory=$true)] $Destination,
+       [hashtable][parameter( Position=3 )] $TemplateBindings = @{} )
+{
+
+    ### Import template bindings
+    Push-Location Variable:
+
+    foreach( $key in $TemplateBindings.Keys )
+    {
+        $value = $TemplateBindings[$key]
+        New-Item -Path $key -Value $ExecutionContext.InvokeCommand.ExpandString( $value ) | Out-Null
+    }
+
+    Pop-Location
+
+    ### Copy and expand
+    $Source = Resolve-Path $Source
+
+    if( Test-Path $Destination -PathType Container )
+    {
+        $Destination = Join-Path $Destination ([IO.Path]::GetFilename( $Source ))
+    }
+
+    $DestinationDir = Resolve-Path (Split-Path $Destination -Parent)
+    $DestinationFilename = [IO.Path]::GetFilename( $Destination )
+    $Destination = Join-Path $DestinationDir $DestinationFilename
+
+    if( $Destination -eq $Source )
+    {
+        throw "Destination $Destination and Source $Source cannot be the same"
+    }
+
+    $template = [IO.File]::ReadAllText( $Source )
+    $expanded = Expand-String( $template )
+    ### Output xml files as ANSI files (same as original)
+    write-output $expanded | out-file -encoding ascii $Destination
+}
+
+# Convenience method for processing command-line credential objects
+# Assumes $credentialsHash is a hash with one of the following being true:
+#  - keys "username" and "password"/"passwordBase64" are set to strings
+#  - key "credentialFilePath" is set to the path of a serialized PSCredential object
+function Get-HadoopUserCredentials($credentialsHash)
+{
+    if($credentialsHash["username"])
+    {
+        Write-Log "Using provided credentials for username $($credentialsHash["username"])" | Out-Null
+        $username = $credentialsHash["username"]
+        if($username -notlike "*\*")
+        {
+            $username = "$ENV:COMPUTERNAME\$username"
+        }
+        if($credentialsHash["passwordBase64"])
+        {
+            $base64Password = $credentialsHash["passwordBase64"]
+            $decoded = [System.Convert]::FromBase64String($base64Password);
+            $decodedPassword = [System.Text.Encoding]::UTF8.GetString($decoded);
+            $securePassword = $decodedPassword | ConvertTo-SecureString -AsPlainText -Force
+        }
+        else
+        {
+            $securePassword = $credentialsHash["password"] | ConvertTo-SecureString -AsPlainText -Force
+        }
+    }
+    else
+    {
+        Write-Log "Reading credentials from $($credentialsHash['credentialFilePath'])" | Out-Null
+        $import = Import-Clixml -Path $credentialsHash["credentialFilePath"]
+        $username = $import.Username
+        $securePassword = $import.Password | ConvertTo-SecureString
+    }
+
+    $creds = New-Object System.Management.Automation.PSCredential $username, $securePassword
+    return $creds
+}
+
+function Check-Drive($path, $message){
+    if($path -cnotlike "*:*"){
+        Write-Warning "Target path doesn't contains drive identifier, checking skipped"
+        return
+    }
+    $pathvolume = $path.Split(":")[0] + ":"
+    if (! (Test-Path ($pathvolume + '\')) ) {
+        throw "Target volume for $message $pathvolume doesn't exist"
+    }
+}
+
+Export-ModuleMember -Function Copy-XmlTemplate
+Export-ModuleMember -Function Get-HadoopUserCredentials
+Export-ModuleMember -Function Initialize-WinpkgEnv
+Export-ModuleMember -Function Initialize-InstallationEnv
+Export-ModuleMember -Function Invoke-Cmd
+Export-ModuleMember -Function Invoke-CmdChk
+Export-ModuleMember -Function Invoke-Ps
+Export-ModuleMember -Function Invoke-PsChk
+Export-ModuleMember -Function Set-ServiceAcl
+Export-ModuleMember -Function Test-JavaHome
+Export-ModuleMember -Function Write-Log

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/install.ps1
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/install.ps1 b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/install.ps1
new file mode 100644
index 0000000..09b38d1
--- /dev/null
+++ b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/install.ps1
@@ -0,0 +1,349 @@
+### 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.
+
+param($skipCredsFile = $true)
+function Split_Hosts ($var,$hosts)
+{
+	Write-Log "Started split of $var"
+	if ($var -like "*,*")
+	{
+		$split_hosts = $var -split ","
+		foreach ($server in $split_hosts)
+		{
+			$hosts.Value += $server
+		}
+	}
+	else
+	{ 
+		$hosts.Value += $var
+	}
+
+}
+function CreateURL ($url, $name)
+{
+	$objShell = New-Object -ComObject ("WScript.Shell")
+	$objShortCut = $objShell.CreateShortcut($env:USERPROFILE + "\Desktop\" + $name)
+	$objShortCut.TargetPath = $url.Replace("'","")
+	$objShortCut.Save()
+}
+function Invoke-Winpkg ($arguments)
+{
+    $command = "$ENV:WINPKG_BIN\winpkg.ps1 $arguments"
+    Write-Log "Invoke-Winpkg: $command"
+    $out = powershell.exe -InputFormat none -Command "$command" 2>&1
+    if( $lastexitcode -ne 0 )
+    {
+        Write-Log "Invoke-Winpkg Failed to execute: $command"
+        throw $out
+    }
+    Write-Log "Invoke-Winpkg Complete: $command"
+}
+
+function modify_xml($name)
+{
+	$xml_file= Join-Path $hdp_home "bin\$name.xml"
+	if (Test-Path $xml_file)
+	{
+		[xml]$xml = Get-Content $xml_file
+		$arguments = ($xml.service.arguments).split(" ")
+		for ($i = 0; $i -lt $arguments.length; $i++){
+			if ($arguments[$i] -clike "-classpath")
+			{
+				$flag = $true
+			}
+			if (($arguments[$i] -cnotlike "-classpath") -and $flag)
+			{
+				$txt = $arguments[$i]
+				$arguments[$i] = "$txt;$destination\$ambari_metrics;$destination\sqljdbc4.jar"
+				$flag = $false
+			}
+		}
+		$arguments = $arguments -join " "
+		$xml.service.arguments = $arguments
+		$xml.Save($xml_file)
+	}
+}
+function GetName($name,$param)
+{
+	if ($param -ieq "full")
+	{
+		$name = Get-Item $name
+		return $name.FullName
+	}
+	elseif ($param -ieq "short")
+	{
+		$name = Get-Item $name
+		return $name.Name
+	}
+}
+function PushInstall-Files( $node,$source_path,$target_path)
+{
+	# tag output with node name:
+    write-log ("" + $node + ":")
+	$current_host = gc env:computername
+	$all_files = "*"
+	if (-not (($node -ieq $current_host) -and ($source_path -ieq $target_path)))  {
+		# convert $target_path into the corresponding admin share path, so we can
+		# push the files to the node
+		$tgtDir = '\\' + ($node) + '\' +  $target_path.ToString().Replace(':', '$')
+
+		# attempt to create the target install directory on the remote node,
+		# if it doesn't already exist
+		if(! (Test-Path "$tgtDir")) { $r = mkdir "$tgtDir" }
+
+		# validate that the $tgtDir admin share exists and is accessible on the remote node
+		if (! (Test-Path "$tgtDir") ) {
+			write-error "$target_path on $node is not accessible by admin share.  Skipping."
+			return
+		}
+		# push the files to each node.  Skip node if any errors.
+		pushd "$source_path"
+		cp $all_files "$tgtDir" -ErrorAction Stop
+		popd
+		if (! $?) {
+			write-error "Some files could not be pushed to $node.  Skipping."
+			return
+		}
+	}
+}
+function Main( $scriptDir )
+{
+	Write-Log "INSTALLATION started"
+    Write-Log "Reading Ambari layout from $ENV:AMB_LAYOUT"
+    if ( -not (Test-Path $ENV:AMB_LAYOUT))
+    {
+        throw "No Ambari Properties file found, make sure the file $ENV:AMB_LAYOUT exists and contains the current cluster layout"
+    }
+    Export-ClusterLayoutIntoEnv $ENV:AMB_LAYOUT "amb"
+	Export-ClusterLayoutIntoEnv $ENV:HDP_LAYOUT "hdp"
+	$destination= $env:AMB_DATA_DIR
+	[Environment]::SetEnvironmentVariable("AMB_DATA_DIR", $destination, "Machine")
+	if (!(test-path $destination)) {New-Item -path $destination -ItemType directory}
+	$path = [Environment]::CurrentDirectory
+	$Package_trim =  Split-Path -Path $path -Parent
+	Write-Log "Copying Ambari-Scom.Jar"
+	$jar = Join-Path $Package_trim "resources\ambari-scom-*.jar"
+	Copy-Item -Force $jar $destination
+	$ambari_scom = Getname $jar "short"
+	Write-Log "Copying Ambari Metrics Jar"
+	$jar = Join-Path $Package_trim "resources\metrics-sink-*.jar"
+	Copy-Item -Force $jar $destination
+	$ambari_metrics = Getname $jar "short"
+	Write-Log "Copying SQL JDBC driver"
+	$jar =  $env:SQL_JDBC_PATH 
+	Copy-Item -Force $jar $destination
+	Write-log "Copuing SQL query"
+	$jar = Join-Path $Package_trim "resources\Hadoop-Metrics-SQLServer-CREATE.ddl"
+	Copy-Item -Force $jar $destination
+	Write-log "Pushing Ambari-SCOM and SQL Server JDBC to each node"
+	$current = @()
+	$SQL_SERVER_NAME = $env:SQL_SERVER_NAME
+	if (($SQL_SERVER_NAME  -ieq "localhost") -or ($SQL_SERVER_NAME  -ieq "127.0.0.1"))
+	{
+		$SQL_SERVER_NAME= $env:COMPUTERNAME
+	}
+	$SQL_SERVER_PORT = $env:SQL_SERVER_PORT
+	$SQL_SERVER_LOGIN = $env:SQL_SERVER_LOGIN
+	$SQL_SERVER_PASSWORD= $env:SQL_SERVER_PASSWORD
+	$START_SERVICES = $ENV:START_SERVICES
+	Write-log "Start services flag is $START_SERVICES"
+	$hosts= @($SQL_SERVER_NAME,$ENV:NAMENODE_HOST,$ENV:SECONDARY_NAMENODE_HOST,$ENV:JOBTRACKER_HOST,$ENV:HIVE_SERVER_HOST,$ENV:OOZIE_SERVER_HOST,
+	$ENV:WEBHCAT_HOST,$ENV:HBASE_MASTER)
+	Split_Hosts $ENV:SLAVE_HOSTS ([REF]$hosts)
+	Split_Hosts $ENV:ZOOKEEPER_HOSTS ([REF]$hosts)
+	Split_Hosts $ENV:FLUME_HOSTS ([REF]$hosts)
+	Write-Log "Hosts list:"
+	Write-log $hosts
+	Write-Log "Intalling data sink on each host"
+	foreach ($server in $hosts)
+	{
+		if (($current -notcontains $server) -and ($server -ne $null))
+		{
+			Write-Log "Pushing files to each node"
+			PushInstall-Files $server $destination $destination
+			Write-Log "Executing data sink installation"
+			$out = Invoke-Command -ComputerName $server -ScriptBlock {
+				param( $server,$SQL_SERVER_NAME,$SQL_SERVER_PORT,$SQL_SERVER_LOGIN,$SQL_SERVER_PASSWORD,$destination,$ambari_metrics,$START_SERVICES )
+				$log = Join-Path $destination "ambari_install.log"
+				function Invoke-Cmd ($command)
+				{
+					Out-File -FilePath $log -InputObject "$command" -Append -Encoding "UTF8"
+				    Write-Host $command
+				    $out = cmd.exe /C "$command" 2>&1
+ 					$out | ForEach-Object { Write-Host "CMD" $_ }
+				    return $out
+				}
+				function modify_xml($name)
+				{
+					$xml_file= Join-Path $hdp_home "bin\$name.xml"
+					if (Test-Path $xml_file)
+					{
+						Out-File -FilePath $log -InputObject "Modifying $name.xml" -Append -Encoding "UTF8"
+						Write-Host "Modifying $name.xml"
+						[xml]$xml = Get-Content $xml_file
+						$arguments = ($xml.service.arguments).split(" ")
+						for ($i = 0; $i -lt $arguments.length; $i++){
+							if ($arguments[$i] -like "-classpath")
+							{
+								$flag = $true
+							}
+							if (($arguments[$i] -notlike "-classpath") -and $flag)
+							{
+								$txt = $arguments[$i]
+								$arguments[$i] = "$txt;$destination\$ambari_metrics;$destination\sqljdbc4.jar"
+								$flag = $false
+							}
+						}
+						$arguments = $arguments -join " "
+						$xml.service.arguments = $arguments
+						$xml.Save($xml_file)
+					}
+				}
+				function modify_value ($name)
+				{
+					$value = "$name.sink.sql.databaseUrl=jdbc:sqlserver://$SQL_SERVER_NAME':$SQL_SERVER_PORT;databaseName=HadoopMetrics;user=$SQL_SERVER_LOGIN;password=$SQL_SERVER_PASSWORD"
+					Add-Content $metrics $value.Replace("'","")
+				}
+				if ($server -ieq $SQL_SERVER_NAME)
+				{
+					Out-File -FilePath $log -InputObject "Creating MonitoringDatabase environment" -Append -Encoding "UTF8"
+					Write-HOST "Creating MonitoringDatabase environment"
+					$sql_path = Join-Path $destination "\Hadoop-Metrics-SQLServer-CREATE.ddl"
+					$cmd ="sqlcmd -s $SQL_SERVER_NAME -i $sql_path"
+					invoke-cmd $cmd 
+				}
+				$hdp_home = [Environment]::GetEnvironmentVariable("HADOOP_HOME","Machine")
+				if ($hdp_home -ne $null)
+				{
+					Out-File -FilePath $log -InputObject "Installing data sink on $server" -Append -Encoding "UTF8"
+					Write-Host "Installing data sink on $server"
+					$metrics = Join-Path $hdp_home "bin\hadoop-metrics2.properties"
+					if (-not (test-path $metrics))
+					{
+						$metrics = Join-Path $hdp_home "conf\hadoop-metrics2.properties"
+					}
+					Add-Content $metrics "*.sink.sql.class=org.apache.hadoop.metrics2.sink.SqlServerSink"
+					$names = @("namenode","datanode","jobtracker","tasktracker","maptask","reducetask")
+					foreach ($name in $names)
+					{
+						modify_value $name
+					}
+					Out-File -FilePath $log -InputObject "Modifying CLASSPATH" -Append -Encoding "UTF8"
+					Write-Host "Modifying CLASSPATH"
+					$names = @("namenode","secondarynamenode","datanode","historyserver","jobtracker","tasktracker")
+					foreach ($name in $names)
+					{
+						modify_xml $name
+					}
+					Write-Host "Start services flag is $START_SERVICES"
+					if ($START_SERVICES -like "*yes*")
+					{
+						Write-Host "Starting services"
+						Out-File -FilePath $log -InputObject "Starting HDP services" -Append -Encoding "UTF8"
+						$hdp_root= [Environment]::GetEnvironmentVariable("HADOOP_NODE_INSTALL_ROOT","Machine")
+						$cmd = Join-Path $hdp_root "start_local_hdp_services.cmd"
+						Invoke-Cmd $cmd
+					}
+				}
+				elseif (($hdp_home -eq $null) -and ($server -ieq $SQL_SERVER_NAME))
+				{	
+					Out-File -FilePath $log -InputObject "Cleaning things on SQL server" -Append -Encoding "UTF8"
+					Write-Host "Cleaning things on SQL server"
+					$log_new = Join-Path $ENV:TMP "ambari_install.log"
+					Copy-Item $log $log_new
+					Remove-Item $Destination -force -Recurse
+				}
+			} -ArgumentList ($server,$SQL_SERVER_NAME,$SQL_SERVER_PORT,$SQL_SERVER_LOGIN,$SQL_SERVER_PASSWORD,$destination,$ambari_metrics,$START_SERVICES)
+			if ($out -eq $null)
+			{
+				Write-Log "Installation on $server failed. Please check host availability"
+			}
+			else
+			{
+				Write-Log "Installation on $server finished."
+			}
+			$current +=$server
+		}
+	}
+	Write-Log "Unpacking ambari-server-conf"
+	$package = Join-Path $Package_trim "resources\ambari-scom-*-conf.zip"
+	$ambari_conf = GetName $package "short"
+	$ambari_conf = $ambari_conf -replace ".zip"
+	$package = GetName $package "full"
+	$winpkg = Join-Path $Package_trim "resources\winpkg.ps1"
+	$command = "$winpkg $Package unzip $destination"
+	Invoke-Pschk $command
+	Write-Log "Unpacking ambari-server-lib"
+	$package = Join-Path $Package_trim "resources\ambari-scom-*-lib.zip"
+	$ambari_lib = GetName $package "short"
+	$ambari_lib = $ambari_lib -replace ".zip"
+	$package = GetName $package "full"
+	$command = "$winpkg $Package unzip $destination"
+	Invoke-Pschk $command
+	Write-Log "Modifiying ambari.properties"
+	$props = Join-Path $destination "$ambari_conf\conf\ambari.properties"
+	Add-Content $props "scom.sink.db.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver"
+	$value = "scom.sink.db.url=jdbc:sqlserver://$env:SQL_SERVER_NAME':$env:SQL_SERVER_PORT;databaseName=HadoopMetrics;user=$env:SQL_SERVER_LOGIN;password=$env:SQL_SERVER_PASSWORD"
+	Add-Content $props $value.Replace("'","")
+	Write-Log "Copying cluster.properties to ambari config"
+	$clp = $ENV:HDP_LAYOUT
+	$destination_conf = Join-Path $destination "$ambari_conf\conf\clusterproperties.txt"
+	Copy-Item -Force $clp $destination_conf
+	$destination = Join-Path $destination "clusterproperties.txt"
+	Copy-Item -Force $clp $destination
+	Write-Log "Creating shortcut to start Ambari"
+	$objShell = New-Object -ComObject ("WScript.Shell")
+	$objShortCut = $objShell.CreateShortcut($env:USERPROFILE + "\Desktop" + "\Start Ambari SCOM Server.lnk")
+	$classpath = "$env:AMB_DATA_DIR\$ambari_conf\conf\;$env:AMB_DATA_DIR\sqljdbc4.jar;$env:AMB_DATA_DIR\$ambari_scom;$env:AMB_DATA_DIR\$ambari_lib\lib\*"
+	$targetpath = "$ENV:JAVA_HOME\bin\java"
+	$arguments = "-server -XX:NewRatio=3 -XX:+UseConcMarkSweepGC -XX:-UseGCOverheadLimit -XX:CMSInitiatingOccupancyFraction=60  -cp $classpath org.apache.ambari.scom.AmbariServer"
+	$objShortCut.TargetPath = $targetpath
+	$objShortCut.Arguments = $arguments
+	$objShortCut.Description = "Start Ambari"
+	$objShortCut.Save()
+	CreateUrl "http://$ENV:COMPUTERNAME':8080/api/v1/clusters" "Browse Ambari API.url"
+	CreateUrl "http://$ENV:COMPUTERNAME':8080/api/v1/clusters/ambari/services/HDFS/components/NAMENODE" "Browse Ambari Metrics.url"
+	Write-Log "Copying ambari properties file"
+	Copy-Item $ENV:AMB_LAYOUT "$env:AMB_DATA_DIR\ambariproperties.txt"
+	[Environment]::SetEnvironmentVariable("HDP_LAYOUT","","Machine")
+	[Environment]::SetEnvironmentVariable("START_SERVICES","","Machine")
+	Write-Log "INSTALLATION COMPLETE" 
+
+	
+}
+
+try
+{
+    $scriptDir = Resolve-Path (Split-Path $MyInvocation.MyCommand.Path)
+    $utilsModule = Import-Module -Name "$scriptDir\..\resources\Winpkg.Utils.psm1" -ArgumentList ("AMB") -PassThru
+    $apiModule = Import-Module -Name "$scriptDir\InstallApi.psm1" -PassThru
+	Main $scriptDir
+}
+catch
+{
+	Write-Log $_.Exception.Message "Failure" $_
+	exit 1
+}
+finally
+{
+    if( $apiModule -ne $null )
+    {
+        Remove-Module $apiModule
+    }
+    if( $utilsModule -ne $null )
+    {
+        Remove-Module $utilsModule
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/installApi.psm1
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/installApi.psm1 b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/installApi.psm1
new file mode 100644
index 0000000..ddc9b9b
--- /dev/null
+++ b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/installApi.psm1
@@ -0,0 +1,281 @@
+### 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.
+
+###
+### A set of basic PowerShell routines that can be used to install and
+### configure AMB components on a windows node.
+###
+
+### Valid properties in AMB_LAYOUT file
+$VALID_LAYOUT_PROPERTIES = @("AMB_DATA_DIR", "SQL_SERVER_PASSWORD",
+                             "SQL_SERVER_NAME", "SQL_SERVER_LOGIN", "SQL_SERVER_PORT","SQL_JDBC_PATH"
+                             )
+
+### Mandatory properties in AMB_LAYOUT file
+$MANDATORY_LAYOUT_PROPERTIES = @("AMB_DATA_DIR", "SQL_SERVER_PASSWORD",
+                             "SQL_SERVER_NAME", "SQL_SERVER_LOGIN", "SQL_SERVER_PORT","SQL_JDBC_PATH")
+$HDP_LAYOUT_PROPERTIES = @( "NAMENODE_HOST", "SECONDARY_NAMENODE_HOST", "JOBTRACKER_HOST",
+                             "HIVE_SERVER_HOST", "OOZIE_SERVER_HOST", "WEBHCAT_HOST",
+                             "SLAVE_HOSTS","ZOOKEEPER_HOSTS", "HBASE_MASTER",
+                             "FLUME_HOSTS")
+
+
+### Helper routine that converts a $null object to nothing. Otherwise, iterating over
+### a $null object with foreach results in a loop with one $null element.
+function empty-null($obj)
+{
+   if ($obj -ne $null) { $obj }
+}
+
+### Helper routine that updates the given fileName XML file with the given
+### key/value configuration values. The XML file is expected to be in the
+### Hadoop format. For example:
+### <configuration>
+###   <property>
+###     <name.../><value.../>
+###   </property>
+### </configuration>
+function UpdateXmlConfig(
+    [string]
+    [parameter( Position=0, Mandatory=$true )]
+    $fileName, 
+    [hashtable]
+    [parameter( Position=1 )]
+    $config = @{} )
+{
+    $xml = New-Object System.Xml.XmlDocument
+    $xml.PreserveWhitespace = $true
+    $xml.Load($fileName)
+
+    foreach( $key in empty-null $config.Keys )
+    {
+        $value = $config[$key]
+        $found = $False
+        $xml.SelectNodes('/configuration/property') | ? { $_.name -eq $key } | % { $_.value = $value; $found = $True }
+        if ( -not $found )
+        {
+            $newItem = $xml.CreateElement("property")
+            $newItem.AppendChild($xml.CreateSignificantWhitespace("`r`n    ")) | Out-Null
+            $newItem.AppendChild($xml.CreateElement("name")) | Out-Null
+            $newItem.AppendChild($xml.CreateSignificantWhitespace("`r`n    ")) | Out-Null
+            $newItem.AppendChild($xml.CreateElement("value")) | Out-Null
+            $newItem.AppendChild($xml.CreateSignificantWhitespace("`r`n  ")) | Out-Null
+            $newItem.name = $key
+            $newItem.value = $value
+            $xml["configuration"].AppendChild($xml.CreateSignificantWhitespace("`r`n  ")) | Out-Null
+            $xml["configuration"].AppendChild($newItem) | Out-Null
+            $xml["configuration"].AppendChild($xml.CreateSignificantWhitespace("`r`n")) | Out-Null
+        }
+    }
+    
+    $xml.Save($fileName)
+    $xml.ReleasePath
+}
+
+### Helper routine to return the IPAddress given a hostname
+function GetIPAddress($hostname)
+{
+    try
+    {
+        $remote_host = [System.Net.Dns]::GetHostAddresses($hostname) | ForEach-Object { if ($_.AddressFamily -eq "InterNetwork") { $_.IPAddressToString } }
+		Test-Connection $remote_host -ErrorAction Stop
+		
+    }
+    catch
+    {
+        throw "Error resolving IPAddress for host '$hostname'"
+    }
+}
+
+### Helper routine to check if two hosts are the same
+function IsSameHost(
+    [string]
+    [parameter( Position=0, Mandatory=$true )]
+    $host1,
+    [array]
+    [parameter( Position=1, Mandatory=$false )]
+    $host2ips = ((GetIPAddress $ENV:COMPUTERNAME) -as [array]))
+{
+    $host1ips = ((GetIPAddress $host1) -as [array])
+    $heq = Compare-Object $host1ips $host2ips -ExcludeDifferent -IncludeEqual
+    return ($heq -ne $null)
+}
+
+### Helper routine to normalize the directory path
+function NormalizePath($path)
+{
+    [IO.Path]::GetFullPath($path.ToLower() + [IO.Path]::DirectorySeparatorChar)
+}
+
+### Helper routine to read a Java style properties file and return a hashtable
+function Read-ClusterLayout($filepath,$VALID_LAYOUT_PROPERTIES,$MANDATORY_LAYOUT_PROPERTIES)
+{
+    $properties = @{}
+    $propfile = Get-Content $filepath
+    foreach ($line in $propfile)
+    {
+        $line=$line.Trim()
+        if (($line) -and (-not $line.StartsWith("#")))
+        {
+            $prop = @($line.split("=", 2))
+            $propkey = $prop[0].Trim()
+            if ($VALID_LAYOUT_PROPERTIES -contains $propkey)
+            {
+                $propval = $prop[1].Trim()
+                if ($propval)
+                {
+                    $properties.Add($propkey, $propval)
+                }
+                else
+                {
+                    throw "Property '$propkey' value cannot be left blank"
+                }
+            }
+        }
+    }
+ 	if ($MANDATORY_LAYOUT_PROPERTIES)
+	{
+	    ### Check the required properties
+	    foreach ($prop in $MANDATORY_LAYOUT_PROPERTIES)
+	    {
+	        if ( -not ($properties.Contains($prop)) )
+	        {
+	            throw "Required property '$prop' not found in $filepath"
+	        }
+	    }
+	}
+    return $properties
+}
+
+### Helper routine to read a Java style properties file and import the properties into process' environment
+function Export-ClusterLayoutIntoEnv($filepath,$type)
+{
+    ### Read the cluster layout file
+	if ($type -ieq "amb")
+	{
+    	$properties = Read-ClusterLayout $filepath $VALID_LAYOUT_PROPERTIES $MANDATORY_LAYOUT_PROPERTIES
+		### Abort install if AMB_DATA_DIR is invalid or is in the amb install root
+		$ambDataDirs = [String]$properties["AMB_DATA_DIR"]
+	    foreach ($folder in $ambDataDirs.Split(","))
+	    {
+	        $folder = $folder.Trim()
+			
+	        Check-Drive $folder "AMB_DATA_DIR"
+			
+	        if (-not $folder)
+	        {
+	            throw "Invalid AMB_DATA_DIR: $ambDataDirs"
+	        }
+
+	        if ($folder.IndexOf(" ") -ne -1)
+	        {
+	            throw "AMB_DATA_DIR ($folder) path cannot have spaces"
+	        }
+
+	        if (-not (Test-Path -IsValid $folder))
+	        {
+	            throw "AMB_DATA_DIR ($folder) is invalid"
+	        }
+		}
+	}
+	elseif ($type -ieq "hdp")
+	{
+		$properties = Read-ClusterLayout $filepath $HDP_LAYOUT_PROPERTIES
+	}
+   
+   
+
+    Write-Log "Following properties will be exported into the environment"
+    Write-Log ("{0,-30}{1,-60}" -f "Property","Value")
+    Write-Log ("{0,-30}{1,-60}" -f "--------","-----")
+    foreach ($key in $properties.Keys)
+    {
+        $value = [String]$properties[$key]
+        Write-Log ("{0,-30}{1,-60}" -f "$key","$value")
+        [Environment]::SetEnvironmentVariable($key, $properties[$key], [EnvironmentVariableTarget]::Process)
+    }
+
+}
+
+### Helper routine to emulate which
+function Which($command)
+{
+    (Get-Command $command | Select-Object -first 1).Path
+}
+
+### Function to append a sub-path to a list of paths
+function Get-AppendedPath(
+    [String]
+    [Parameter( Position=0, Mandatory=$true )]
+    $pathList,
+    [String]
+    [Parameter( Position=1, Mandatory=$true )]
+    $subPath,
+    [String]
+    [Parameter( Position=2, Mandatory=$false )]
+    $delimiter = ",")
+{
+    $newPath = @()
+    foreach ($path in $pathList.Split($delimiter))
+    {
+        $path = $path.Trim()
+        if ($path -ne $null)
+        {
+            $apath = Join-Path $path $subPath
+            $newPath = $newPath + $apath
+        }
+    }
+    return ($newPath -Join $delimiter)
+}
+
+### Check validity of drive for $path
+function Check-Drive($path, $message){
+    if($path -cnotlike "*:*"){
+        Write-Warning "Target path doesn't contains drive identifier, checking skipped"
+        return
+    }
+    $pathvolume = $path.Split(":")[0] + ":"
+    if (! (Test-Path ($pathvolume + '\')) ) {
+        throw "Target volume for $message $pathvolume doesn't exist"
+    }
+}
+
+### Gives full permissions on the folder to the given user
+function GiveFullPermissions(
+    [String]
+    [Parameter( Position=0, Mandatory=$true )]
+    $folder,
+    [String]
+    [Parameter( Position=1, Mandatory=$true )]
+    $username,
+    [bool]
+    [Parameter( Position=2, Mandatory=$false )]
+    $recursive = $false)
+{
+    Write-Log "Giving user/group `"$username`" full permissions to `"$folder`""
+    $cmd = "icacls `"$folder`" /grant:r ${username}:(OI)(CI)F"
+    if ($recursive) {
+        $cmd += " /T"
+    }
+    Invoke-CmdChk $cmd
+}
+
+Export-ModuleMember -Function UpdateXmlConfig
+Export-ModuleMember -Function GetIPAddress
+Export-ModuleMember -Function IsSameHost
+Export-ModuleMember -Function Export-ClusterLayoutIntoEnv
+Export-ModuleMember -Function Which
+Export-ModuleMember -Function Get-AppendedPath
+Export-ModuleMember -Function GiveFullPermissions

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/uninstall.cmd
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/uninstall.cmd b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/uninstall.cmd
new file mode 100644
index 0000000..22388b1
--- /dev/null
+++ b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/uninstall.cmd
@@ -0,0 +1,19 @@
+@echo off
+@rem Licensed to the Apache Software Foundation (ASF) under one or more
+@rem contributor license agreements.  See the NOTICE file distributed with
+@rem this work for additional information regarding copyright ownership.
+@rem The ASF licenses this file to You under the Apache License, Version 2.0
+@rem (the "License"); you may not use this file except in compliance with
+@rem the License.  You may obtain a copy of the License at
+@rem
+@rem     http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+
+powershell.exe -NoProfile -InputFormat none -ExecutionPolicy unrestricted -File %~dp0uninstall.ps1 %* -Verbose
+goto :eof
+

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/uninstall.ps1
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/uninstall.ps1 b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/uninstall.ps1
new file mode 100644
index 0000000..10a403f
--- /dev/null
+++ b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/uninstall.ps1
@@ -0,0 +1,200 @@
+### 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.
+function Split_Hosts ($var,$hosts)
+{
+	Write-Log "Started split of $var"
+	if ($var -like "*,*")
+	{
+		$split_hosts = $var -split ","
+		foreach ($server in $split_hosts)
+		{
+			$hosts.Value += $server
+		}
+	}
+	else
+	{ 
+		$hosts.Value += $var
+	}
+
+}
+function GetName($name,$param)
+{
+	if ($param -ieq "full")
+	{
+		$name = Get-Item $name
+		return $name.FullName
+	}
+	elseif ($param -ieq "short")
+	{
+		$name = Get-Item $name
+		return $name.Name
+	}
+}
+function Main( $scriptDir )
+{
+    Write-Log "UNINSTALLATION STARTED"
+	Write-Log "Reading Ambari and HDP layout"
+	$destination= [Environment]::GetEnvironmentVariable("AMB_DATA_DIR","Machine")
+	$ENV:AMB_LAYOUT = Join-Path $destination "ambariproperties.txt"
+	$ENV:HDP_LAYOUT = Join-Path $destination "clusterproperties.txt"
+	Export-ClusterLayoutIntoEnv $ENV:AMB_LAYOUT "amb"
+	Export-ClusterLayoutIntoEnv $ENV:HDP_LAYOUT "hdp"
+	$jar = Join-Path $destination "\metrics-sink-*.jar"
+	$ambari_metrics = Getname $jar "short"
+	$current = @()
+	$SQL_SERVER_NAME = $env:SQL_SERVER_NAME
+	$hosts= @($SQL_SERVER_NAME,$ENV:NAMENODE_HOST,$ENV:SECONDARY_NAMENODE_HOST,$ENV:JOBTRACKER_HOST,$ENV:HIVE_SERVER_HOST,$ENV:OOZIE_SERVER_HOST,
+	$ENV:WEBHCAT_HOST,$ENV:HBASE_MASTER)
+	Split_Hosts $ENV:SLAVE_HOSTS ([REF]$hosts)
+	Split_Hosts $ENV:ZOOKEEPER_HOSTS ([REF]$hosts)
+	Split_Hosts $ENV:FLUME_HOSTS ([REF]$hosts)
+	Write-Log "Hosts list:"
+	Write-log $hosts
+	Write-Log "Uninstalling from each host"
+	$failed=@()
+	$failed_file = join-path $env:TMP "ambari_failed.txt"
+		if (Test-Path $failed_file)
+		{
+			Remove-Item $failed_file -Force
+		}
+	foreach ($server in $hosts)
+	{
+		if (($current -notcontains $server) -and ($server -ne $null))
+		{
+			Write-Log "Executing uninstallation on $server"
+			$out = Invoke-Command -ComputerName $server -ScriptBlock {
+				param( $server,$SQL_SERVER_NAME,$destination,$ambari_metrics)
+				$log = Join-Path $env:tmp "ambari_uninstall.log"
+				function Invoke-Cmd ($command)
+				{
+					Out-File -FilePath $log -InputObject "$command" -Append -Encoding "UTF8"
+				    Write-Host $command
+				    $out = cmd.exe /C "$command" 2>&1
+ 					$out | ForEach-Object { Write-Host "CMD" $_ }
+				    return $out
+				}
+				$hdp_home = [Environment]::GetEnvironmentVariable("HADOOP_HOME","Machine")
+				if ($hdp_home -ne $null)
+				{
+					Out-File -FilePath $log -InputObject "Starting Ambari removal" -Append -Encoding "UTF8"
+					Out-File -FilePath $log -InputObject "Cleaning up Ambari folder" -Append -Encoding "UTF8"
+					$out = Remove-Item $destination -Force -Recurse 2>&1
+					if ($out -like "*Cannot remove*")
+					{
+						Write-Output "Failed"
+					}
+					else
+					{
+						Write-Output "Succeeded"
+					}
+					Out-File -FilePath $log -InputObject "Cleaning up metrics" -Append -Encoding "UTF8"
+					$metrics = Join-Path $hdp_home "bin\hadoop-metrics2.properties"
+					if (-not (test-path $metrics))
+					{
+						$metrics = Join-Path $hdp_home "conf\hadoop-metrics2.properties"
+					}
+					$result=@()
+					$file = Get-Content $metrics
+					foreach ($string in $file)
+					{
+						if (($string -cnotlike "*sink.sql.class*") -and ($string -cnotlike "*.sink.sql.databaseUrl*"))
+					 	{
+							$result+=$string
+						}
+					}
+					Set-Content -Path $metrics -Value $result
+					Out-File -FilePath $log -InputObject "Cleaning up xml's" -Append -Encoding "UTF8"
+					$names = @("namenode","secondarynamenode","datanode","historyserver","jobtracker","tasktracker")
+					foreach ($name in $names)
+					{
+						$xml_file= Join-Path $hdp_home "bin\$name.xml"
+						Out-File -FilePath $log -InputObject "Cleaning up $xml_file" -Append -Encoding "UTF8"
+						(Get-Content $xml_file)|ForEach-Object {
+						$_.Replace(";$destination\$ambari_metrics;$destination\sqljdbc4.jar","")
+						}|Set-Content $xml_file
+					}
+					
+				}
+				if  (($server -ieq $SQL_SERVER_NAME) -and ($hdp_home -eq $null))
+				{	
+#					Out-File -FilePath $log -InputObject "Cleaning up HadoopMetrics database" -Append -Encoding "UTF8"
+#					$cmd ="sqlcmd -s $SQL_SERVER_NAME -q 'drop database HadoopMetrics'"
+#					invoke-cmd $cmd 
+					if (Test-Path $destination)
+					{
+						$out = Remove-Item $destination -Force -Recurse 2>&1
+						if ($out -like "*Cannot remove*")
+						{
+							Write-Output "Failed"
+						}
+						else
+						{
+							Write-Output "Succeeded"
+						}
+					}
+					else
+					{
+						Write-Output "Succeeded"
+					}
+				}
+			} -ArgumentList ($server,$SQL_SERVER_NAME,$destination,$ambari_metrics)
+			if (($out -like "*failed*") -or ($out -eq $null))
+			{
+				$failed+=$server
+				Write-Log "Uninstallation on $server does not finished. Please remove existing items manually"
+			}
+			else
+			{
+			Write-Log "Uninstallation on $server finished."
+			}
+			$current +=$server
+		}
+	}
+	if ($failed.length -gt 0)
+	{
+		foreach ($server in $failed)
+		{
+			Out-File -FilePath $failed_file -InputObject $server -Append -Encoding "UTF8"
+		}
+		
+	}
+	Write-Log "Removing Ambari folder"
+	Remove-Item $destination -force -Recurse
+	Write-Log "Removing shortcut"
+	Remove-Item "$env:USERPROFILE\Desktop\Start Ambari SCOM Server.lnk" -Force
+	Remove-Item "$env:USERPROFILE\Desktop\Browse Ambari API.url" -Force
+	Remove-Item "$env:USERPROFILE\Desktop\Browse Ambari Metrics.url" -Force
+	[Environment]::SetEnvironmentVariable("AMB_DATA_DIR", "", "Machine")
+    Write-Log "UNINSTALLATION COMPLETE "
+}
+
+try
+{
+    $scriptDir = Resolve-Path (Split-Path $MyInvocation.MyCommand.Path)
+    $utilsModule = Import-Module -Name "$scriptDir\..\resources\Winpkg.Utils.psm1" -ArgumentList ("AMB") -PassThru
+    $apiModule = Import-Module -Name "$scriptDir\InstallApi.psm1" -PassThru
+    Main $scriptDir
+}
+finally
+{
+    if( $apiModule -ne $null )
+    {
+        Remove-Module $apiModule
+    }
+    if( $utilsModule -ne $null )
+    {
+        Remove-Module $utilsModule
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/msi/src/AmbariSetupTools/bootstrap_install.cmd
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/AmbariSetupTools/bootstrap_install.cmd b/contrib/ambari-scom/msi/src/AmbariSetupTools/bootstrap_install.cmd
new file mode 100644
index 0000000..dc17eda
--- /dev/null
+++ b/contrib/ambari-scom/msi/src/AmbariSetupTools/bootstrap_install.cmd
@@ -0,0 +1,23 @@
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+
+echo "BOOTSTRAP: Setting WINPKG_LOG to %1ambari.winpkg.install.log"
+echo y|winrm qc
+SET WINPKG_LOG=%1ambari.winpkg.install.log
+echo "BOOTSTRAP: Setting WINPKG_BIN to %1"
+SET WINPKG_BIN=%1
+call %1\winpkg.cmd "%1\..\AmbariPackages\ambari-winpkg.zip" install -Verbose
+exit /b %ERRORLEVEL%

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/msi/src/AmbariSetupTools/bootstrap_uninstall.cmd
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/AmbariSetupTools/bootstrap_uninstall.cmd b/contrib/ambari-scom/msi/src/AmbariSetupTools/bootstrap_uninstall.cmd
new file mode 100644
index 0000000..4c6369a
--- /dev/null
+++ b/contrib/ambari-scom/msi/src/AmbariSetupTools/bootstrap_uninstall.cmd
@@ -0,0 +1,23 @@
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+
+echo "BOOTSTRAP: Setting WINPKG_LOG to %1ambari.winpkg.uninstall.log"
+SET WINPKG_LOG=%1ambari.winpkg.uninstall.log
+echo "BOOTSTRAP: Setting WINPKG_BIN to %1"
+SET WINPKG_BIN=%1
+echo y|winrm qc
+call %1\winpkg.cmd "%1\..\AmbariPackages\ambari-winpkg.zip" uninstall -Verbose
+exit /b %ERRORLEVEL%

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/873b3502/contrib/ambari-scom/msi/src/AmbariSetupTools/winpkg.cmd
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/AmbariSetupTools/winpkg.cmd b/contrib/ambari-scom/msi/src/AmbariSetupTools/winpkg.cmd
new file mode 100644
index 0000000..e87ee90
--- /dev/null
+++ b/contrib/ambari-scom/msi/src/AmbariSetupTools/winpkg.cmd
@@ -0,0 +1,33 @@
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+@echo off
+@rem Licensed to the Apache Software Foundation (ASF) under one or more
+@rem contributor license agreements.  See the NOTICE file distributed with
+@rem this work for additional information regarding copyright ownership.
+@rem The ASF licenses this file to You under the Apache License, Version 2.0
+@rem (the "License"); you may not use this file except in compliance with
+@rem the License.  You may obtain a copy of the License at
+@rem
+@rem     http://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+
+powershell.exe -NoProfile -InputFormat none -ExecutionPolicy unrestricted -command %~dp0winpkg.ps1 %*
+goto :eof