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 latest HDP sandbox VM image (e.g. Sandbox_HDP_2.3_VMware.ova) from Hortonworks website
- Import Sandbox_HDP_2.3_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)
- Install Maven
curl -o /etc/yum.repos.d/epel-apache-maven.repo https://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo
yum -y install apache-maven-3.2*
- 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/hortonworks-gallery/ambari-blueprints-view.git
cd ambari-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 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