Demo view to manage Ambari via REST calls using some sample operations:
-
Export blueprint
-
Get status of components
-
Stop/Start services
-
Note: ALL requests are passing in 'X-Requested-By: ambari' header. This is why the requests will not work via the browser
Author: Ali Bajwa
- Download HDP 2.2 sandbox VM image (Sandbox_HDP_2.2_VMware.ova) from Hortonworks website
- Import Sandbox_HDP_2.2_VMware.ova into VMWare and set the VM memory size to 8GB
- Now start the VM
- After it boots up, find the IP address of the VM and add an entry into your machines hosts file e.g.
192.168.191.241 sandbox.hortonworks.com sandbox
- Connect to the VM via SSH (password hadoop) and start Ambari server
ssh root@sandbox.hortonworks.com
/root/start_ambari.sh
- Install Maven
mkdir /usr/share/maven
cd /usr/share/maven
wget http://mirrors.koehn.com/apache/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
tar xvzf apache-maven-3.2.5-bin.tar.gz
ln -s /usr/share/maven/apache-maven-3.2.5/ /usr/share/maven/latest
echo 'M2_HOME=/usr/share/maven/latest' >> ~/.bashrc
echo 'M2=$M2_HOME/bin' >> ~/.bashrc
echo 'PATH=$PATH:$M2' >> ~/.bashrc
export M2_HOME=/usr/share/maven/latest
export M2=$M2_HOME/bin
export PATH=$PATH:$M2
- To deploy the view, run below. On non-sandbox env, these steps should be run on node running Ambari server
#Pull code (pom.xml, view.xml, index.html)
cd
git clone https://github.com/abajwa-hw/blueprints-view.git
cd blueprints-view
#No longer needed - Tell maven to compile against ambari jar (double check that the jar exists in this location, first)
#mvn install:install-file -Dfile=/usr/lib/ambari-server/ambari-views-1.7.0.169.jar -DgroupId=org.apache.ambari -DartifactId=ambari-views -Dversion=1.3.0-SNAPSHOT -Dpackaging=jar
#Compile view
mvn clean package
#move jar to Ambari dir
cp target/*.jar /var/lib/ambari-server/resources/views
- Restart Ambari
#on HDP 2.2 sandbox
service ambari restart
#on non-sandbox
service ambari-server restart
- Now open Ambari and navigate to the Views and select 'Blueprint View' http://sandbox.hortonworks.com:8080
-
First check your cluster parameters:
- host/port (e.g. sandbox.hortonworks.com:8080). This is autodetected
- cluster name (e.g. Sandbox). This is autodetected
- Username/pass (e.g admin/admin)
-
Export cluster blueprint:
-
Stop HBase (assuming its already started):
-
After a few seconds, check HBase status:
-
Start HBase (assuming its stopped):
-
Check HBase status:
-
Notice that the status check APIs did not require a request body but the stop/start ones did
-
You can add your own operations by modifying the url_list JSON data in /var/lib/ambari-server/resources/views/work/BLUEPRINT_VIEW{1.0.0}/index.html containing the sample operations, and refreshing the view. This will add your HTTP request to the dropdown list
- Note the values of $host and $cluster will get replaced at runtime. Also the single quotes in the JSON body will be replaced by double quotes when displayed in the view
-
You can also update the default values of hostname and cluster name in the same file, in case the autodetection is not working for some reason
To update component configurations, see examples here