#!/bin/bash
#author Xiaoweige
#todo: IP--> ingredient or ingredient--> IP
#todo: Get the IP of the given ingredient
function Ingredient_ip () {
#todo: Get the IP of the ingredient given
Mysql-uroot-pengine-e "SELECT * from ipandingredient.ipandingredient where env = ' $ ' and ingredient= '"
}
#todo: Not sure what's the ingredient is
function Search_ingredient () {
Mysql-uroot-pengine-e "Use ipandingredient; select * from ipandingredient where ingredient like '%${1}% '"
}
#todo: Get the IP of the ingredient given
function Ip_ingredient () {
Mysql-uroot-pengine-e "Use ipandingredient; SELECT * from Ipandingredient where env= ' $ ' and ip= ' $ '
}
function usage () {
echo "To get ingredient USAGE:./$0 IP"
echo "To get IP USAGE:./$0 ingredient"
echo "search ingredient./$0 sth"
}
function Main () {
If [$#-eq 0]
Then
Usage
elif [$#-eq 1]
Then
Search_ingredient $
elif [$#-eq 2]
Then
Argtype= ' echo $2|egrep [1-9+\.] `
If [-Z $argtype]
Then
INGREDIENT_IP $
Else
IP_INGREDIENT_IP $
Fi
Fi
}
Main $*
Querying cloud Platform components or IP simple scripts from the CMDB