You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by tb...@apache.org on 2014/04/30 21:24:04 UTC

git commit: AMBARI-5630 - Ambari SCOM .msi should detect HDP version dynamically (Ivan Malamen via tbeerbower

Repository: ambari
Updated Branches:
  refs/heads/trunk 89c72f3c8 -> 8490bae98


AMBARI-5630 - Ambari SCOM .msi should detect HDP version dynamically (Ivan Malamen via tbeerbower


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

Branch: refs/heads/trunk
Commit: 8490bae982a15448486f99b522afefd2d9c68c17
Parents: 89c72f3
Author: tbeerbower <tb...@hortonworks.com>
Authored: Wed Apr 30 15:22:15 2014 -0400
Committer: tbeerbower <tb...@hortonworks.com>
Committed: Wed Apr 30 15:22:15 2014 -0400

----------------------------------------------------------------------
 .../ambari-scom-server/conf/ambari.properties   |  2 +-
 .../ambari-winpkg/scripts/install.ps1           | 38 ++++++++++-
 .../ambari-winpkg/scripts/installApi.psm1       |  4 +-
 .../msi/src/GUI_Ambari/Form1.Designer.cs        | 67 ++++++++++++++++++--
 contrib/ambari-scom/msi/src/GUI_Ambari/Form1.cs | 36 +++++++++--
 5 files changed, 133 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8490bae9/contrib/ambari-scom/ambari-scom-server/conf/ambari.properties
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/ambari-scom-server/conf/ambari.properties b/contrib/ambari-scom/ambari-scom-server/conf/ambari.properties
index eab7310..c734b71 100644
--- a/contrib/ambari-scom/ambari-scom-server/conf/ambari.properties
+++ b/contrib/ambari-scom/ambari-scom-server/conf/ambari.properties
@@ -23,6 +23,6 @@ api.authenticate=false
 server.os_type=windows2012
 server.persistence.type=in-memory
 security.passwords.encryption.enabled=false
-scom.version.id=HDP-2.0.6
+scom.version.id=HDP-%version%
 scom.sink.db.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
 scom.sink.db.url=jdbc:sqlserver://[server]:[port];databaseName=[databaseName];user=[user];password=[password]

http://git-wip-us.apache.org/repos/asf/ambari/blob/8490bae9/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
index 8217020..1bdbecc 100644
--- a/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/install.ps1
+++ b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/install.ps1
@@ -148,7 +148,7 @@ function Main( $scriptDir )
 	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"
+   	Write-log "Pushing Ambari-SCOM and SQL Server JDBC to each node"
 	$current = @()
     $failed=@()
  	$failed_file = join-path $env:TMP "ambari_failed.txt"
@@ -179,7 +179,37 @@ function Main( $scriptDir )
 	Split_Hosts $ENV:ZOOKEEPER_HOSTS ([REF]$hosts)
 	Split_Hosts $ENV:FLUME_HOSTS ([REF]$hosts)
     Split_Hosts $ENV:CLIENT_HOSTS ([REF]$hosts)
-	Write-Log "Hosts list:"
+    if (-not (Test-Path ENV:HDP_VERSION))
+    {
+        Write-log "Detecting HDP version"
+        if ((Test-Path ENV:HADOOP_HOME) -and ($ENV:HADOOP_HOME -ne $null))
+        {
+            Write-log "Using local HDP version"
+            $hdpversion = $ENV:HADOOP_HOME.Split("-")[1].Substring(6)
+            $ENV:HDP_VERSION = $hdpversion.Substring(0,$hdpversion.Length-2)
+			Write-log $ENV:HDP_VERSION
+        }
+        else
+        {
+            Write-log "Fetching HDP version from $ENV:NAMENODE_HOST"
+            $out = Invoke-Command -ComputerName $ENV:NAMENODE_HOST -ScriptBlock {
+                    $hdpversion = $ENV:HADOOP_HOME.Split("-")[1].Substring(6)
+                    $hdpversion = $hdpversion.Substring(0,$hdpversion.Length-2)
+                    Write-HOST $hdpversion
+                    Write-Output $hdpversion
+            }
+            if ($out -eq $null)
+    		{
+    			Write-Log "Cannot detect HDP version. Please add correct HDP version into ambari.properties file"
+    		}
+			else 
+			{
+				$ENV:HDP_VERSION = $out
+				Write-log $ENV:HDP_VERSION
+			}
+        }
+    }
+    Write-Log "Hosts list:"
 	Write-log $hosts
 	Write-Log "Intalling data sink on each host"
 	foreach ($server in $hosts)
@@ -336,6 +366,10 @@ function Main( $scriptDir )
     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("'","")
+    if ((test-path ENV:HDP_VERSION) -and ($ENV:HDP_VERSION -ne $null))
+    {
+        ReplaceAmbariServiceXML $props "%version%" $ENV:HDP_VERSION
+    }
     Write-Log "Copying cluster.properties to ambari config"
     $clp = $ENV:HDP_LAYOUT
     $destination_conf = Join-Path $destination "$ambari_conf\conf\clusterproperties.txt"

http://git-wip-us.apache.org/repos/asf/ambari/blob/8490bae9/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
index abc2ea2..b7377fb 100644
--- a/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/installApi.psm1
+++ b/contrib/ambari-scom/msi/src/AmbariPackages/ambari-winpkg/scripts/installApi.psm1
@@ -20,7 +20,7 @@
 
 ### 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"
+                             "SQL_SERVER_NAME", "SQL_SERVER_LOGIN", "SQL_SERVER_PORT","SQL_JDBC_PATH","HDP_VERSION"
                              )
 
 ### Mandatory properties in AMB_LAYOUT file
@@ -29,7 +29,7 @@ $MANDATORY_LAYOUT_PROPERTIES = @("AMB_DATA_DIR", "SQL_SERVER_PASSWORD",
 $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")
+                             "FLUME_HOSTS","CLIENT_HOSTS")
 
 
 ### Helper routine that converts a $null object to nothing. Otherwise, iterating over

http://git-wip-us.apache.org/repos/asf/ambari/blob/8490bae9/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.Designer.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.Designer.cs b/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.Designer.cs
index 1ab6c4e..2645d79 100644
--- a/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.Designer.cs
+++ b/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.Designer.cs
@@ -65,11 +65,16 @@ namespace GUI_Ambari
             this.SQLDpath = new System.Windows.Forms.TextBox();
             this.Cstart = new System.Windows.Forms.CheckBox();
             this.DBdel = new System.Windows.Forms.CheckBox();
+            this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.Userdetect = new System.Windows.Forms.RadioButton();
+            this.Autodetect = new System.Windows.Forms.RadioButton();
+            this.MainVersion = new System.Windows.Forms.TextBox();
+            this.groupBox1.SuspendLayout();
             this.SuspendLayout();
             // 
             // Install
             // 
-            this.Install.Location = new System.Drawing.Point(136, 282);
+            this.Install.Location = new System.Drawing.Point(136, 348);
             this.Install.Name = "Install";
             this.Install.Size = new System.Drawing.Size(75, 23);
             this.Install.TabIndex = 0;
@@ -174,7 +179,7 @@ namespace GUI_Ambari
             // Cancel
             // 
             this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
-            this.Cancel.Location = new System.Drawing.Point(217, 282);
+            this.Cancel.Location = new System.Drawing.Point(217, 348);
             this.Cancel.Name = "Cancel";
             this.Cancel.Size = new System.Drawing.Size(75, 23);
             this.Cancel.TabIndex = 12;
@@ -184,7 +189,7 @@ namespace GUI_Ambari
             // 
             // Reset
             // 
-            this.Reset.Location = new System.Drawing.Point(298, 282);
+            this.Reset.Location = new System.Drawing.Point(298, 348);
             this.Reset.Name = "Reset";
             this.Reset.Size = new System.Drawing.Size(75, 23);
             this.Reset.TabIndex = 13;
@@ -266,7 +271,7 @@ namespace GUI_Ambari
             // Cstart
             // 
             this.Cstart.AutoSize = true;
-            this.Cstart.Location = new System.Drawing.Point(12, 283);
+            this.Cstart.Location = new System.Drawing.Point(12, 349);
             this.Cstart.Name = "Cstart";
             this.Cstart.Size = new System.Drawing.Size(92, 17);
             this.Cstart.TabIndex = 21;
@@ -285,14 +290,60 @@ namespace GUI_Ambari
             this.DBdel.Text = "Recreate DB";
             this.DBdel.UseVisualStyleBackColor = true;
             // 
+            // groupBox1
+            // 
+            this.groupBox1.Controls.Add(this.Userdetect);
+            this.groupBox1.Controls.Add(this.Autodetect);
+            this.groupBox1.Controls.Add(this.MainVersion);
+            this.groupBox1.Location = new System.Drawing.Point(15, 282);
+            this.groupBox1.Name = "groupBox1";
+            this.groupBox1.Size = new System.Drawing.Size(204, 61);
+            this.groupBox1.TabIndex = 23;
+            this.groupBox1.TabStop = false;
+            // 
+            // Userdetect
+            // 
+            this.Userdetect.AutoSize = true;
+            this.Userdetect.Location = new System.Drawing.Point(7, 34);
+            this.Userdetect.Name = "Userdetect";
+            this.Userdetect.Size = new System.Drawing.Size(123, 17);
+            this.Userdetect.TabIndex = 1;
+            this.Userdetect.TabStop = true;
+            this.Userdetect.Text = "Specify HDP version";
+            this.Userdetect.UseVisualStyleBackColor = true;
+            this.Userdetect.CheckedChanged += new System.EventHandler(this.Userdetect_CheckedChanged);
+            // 
+            // Autodetect
+            // 
+            this.Autodetect.AutoSize = true;
+            this.Autodetect.Checked = true;
+            this.Autodetect.Location = new System.Drawing.Point(7, 10);
+            this.Autodetect.Name = "Autodetect";
+            this.Autodetect.Size = new System.Drawing.Size(184, 17);
+            this.Autodetect.TabIndex = 0;
+            this.Autodetect.TabStop = true;
+            this.Autodetect.Text = "Detect HDP version automatically";
+            this.Autodetect.UseVisualStyleBackColor = true;
+            this.Autodetect.CheckedChanged += new System.EventHandler(this.Autodetect_CheckedChanged);
+            // 
+            // MainVersion
+            // 
+            this.MainVersion.Location = new System.Drawing.Point(134, 34);
+            this.MainVersion.MaxLength = 5;
+            this.MainVersion.Name = "MainVersion";
+            this.MainVersion.Size = new System.Drawing.Size(57, 20);
+            this.MainVersion.TabIndex = 24;
+            this.MainVersion.Visible = false;
+            // 
             // Form1
             // 
             this.AcceptButton = this.Install;
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.CancelButton = this.Cancel;
-            this.ClientSize = new System.Drawing.Size(381, 308);
+            this.ClientSize = new System.Drawing.Size(381, 378);
             this.ControlBox = false;
+            this.Controls.Add(this.groupBox1);
             this.Controls.Add(this.DBdel);
             this.Controls.Add(this.Cstart);
             this.Controls.Add(this.label6);
@@ -325,6 +376,8 @@ namespace GUI_Ambari
             this.Text = "Ambari-SCOM setup";
             this.TopMost = true;
             this.Load += new System.EventHandler(this.Form1_Load);
+            this.groupBox1.ResumeLayout(false);
+            this.groupBox1.PerformLayout();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -357,6 +410,10 @@ namespace GUI_Ambari
         private System.Windows.Forms.TextBox SQLDpath;
         private System.Windows.Forms.CheckBox Cstart;
         private System.Windows.Forms.CheckBox DBdel;
+        private System.Windows.Forms.GroupBox groupBox1;
+        private System.Windows.Forms.RadioButton Userdetect;
+        private System.Windows.Forms.RadioButton Autodetect;
+        private System.Windows.Forms.TextBox MainVersion;
        
     }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/8490bae9/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.cs
----------------------------------------------------------------------
diff --git a/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.cs b/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.cs
index 3fd2d7b..e4d7dce 100644
--- a/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.cs
+++ b/contrib/ambari-scom/msi/src/GUI_Ambari/Form1.cs
@@ -93,6 +93,7 @@ namespace GUI_Ambari
 
         private void Install_Click(object sender, EventArgs e) 
         {
+            Regex rgx = new Regex(@"(\d+\.\d+\.\d+)");
             if (string.IsNullOrEmpty(AID.Text) || string.IsNullOrEmpty(Sname.Text) || string.IsNullOrEmpty(Sport.Text) || string.IsNullOrEmpty(Slogin.Text) || string.IsNullOrEmpty(Spassword.Text) || string.IsNullOrEmpty(SQLDpath.Text))
             {
                 MessageBox.Show("Please fill in all fields", "Error");
@@ -109,6 +110,10 @@ namespace GUI_Ambari
             {
                 MessageBox.Show("You are installing Ambari on separate node. Please enter correct cluster layout file path", "Error");
             }
+            else if (Userdetect.Checked && !rgx.IsMatch(MainVersion.Text))
+            {
+                MessageBox.Show("Please provide HDP version in correct format. For example 2.0.6", "Error");
+            }
             else
             {
                 //if (!(Sname.Text == Environment.GetEnvironmentVariable("computername")))
@@ -117,9 +122,9 @@ namespace GUI_Ambari
                 //}
                 //else
                 //{
-                    Generate_Ambari_Props();
+                Generate_Ambari_Props();
                 //}
-                
+
             }
         }
 
@@ -145,6 +150,7 @@ namespace GUI_Ambari
             SQLDpath.Clear();
             Cstart.Checked = false;
             DBdel.Checked = true;
+            Autodetect.Checked = true;
             CLP_Path();
         }
 
@@ -190,7 +196,7 @@ namespace GUI_Ambari
                 {
                     Environment.SetEnvironmentVariable("START_SERVICES", "no", EnvironmentVariableTarget.Machine);
                 }
-                if (DBdel.Checked == true)
+                if (DBdel.Checked)
                 {
                     Environment.SetEnvironmentVariable("RECREATE_DB", "yes", EnvironmentVariableTarget.Machine);
                 }
@@ -198,7 +204,11 @@ namespace GUI_Ambari
                 {
                     Environment.SetEnvironmentVariable("RECREATE_DB", "no", EnvironmentVariableTarget.Machine);
                 }
-            }
+                if (Userdetect.Checked == true)
+                {
+                    sw.WriteLine("HDP_VERSION=" + MainVersion.Text);
+                }
+             }
             Environment.SetEnvironmentVariable("HDP_LAYOUT", Cpath.Text, EnvironmentVariableTarget.Machine);
             Environment.Exit(0);
         }
@@ -301,5 +311,23 @@ namespace GUI_Ambari
                 SQLDpath.Text = OpenFile.FileName.ToString();
             }
         }
+
+        private void Userdetect_CheckedChanged(object sender, EventArgs e)
+        {
+            if (Userdetect.Checked)
+            {
+                MainVersion.Visible = true;
+            }
+        }
+
+        private void Autodetect_CheckedChanged(object sender, EventArgs e)
+        {
+            if (Autodetect.Checked)
+            {
+                MainVersion.Visible = false;
+                MainVersion.Clear();
+            }
+        }
+
     }
 }