| #! /bin/sh |
| # |
| # $Id:$ |
| # |
| # This program takes two args: |
| # register_automate <svg_tag|mac_addr> <"location"|"switchinfo"|"pduinfo""> |
| # |
| |
| # 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. |
| |
| # Based on the the service tag or the mac address of the machine, it returns |
| # the intented location, hostname, or IP address of the machine, respectively. |
| # It is intented to short-circuit the question phase of registration. |
| # |
| # 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. |
| |
| # Example Chassis r2r1c1 : note, the line must begin with a "#" |
| # tag|mac|uuid location switchname:portnum pduname:portnum |
| # hostname is set to the location of the physical machine. Your naming convention may differ. |
| # r2r1c1b9 - row 2, rack 1, chassis 1, blade 9 |
| |
| # XXX Don't FORGET!!! the line must begin with a "#" |
| |
| #XXXXXXX r2r1c1b9 sw0-r2r1c1:1 drac-r2r1c1:1 x86_64-tashi_nm |
| #XXXXXX1 r1r2u29 sw0-r1r2:16 pdu1-r1r2:9 x86_64-default |
| |
| #6h30lm1 r1r2u29 sw0-r1r2:16 pdu1-r1r2:9 zoni-register-64 |
| #8q0nfk1 rgass-desk sw0-r1r2:17 pdu1-r1r2:15 zoni-register-64 |
| |
| |
| |
| SVC_TAG=$1 |
| REQUEST=$2 |
| |
| res="" |
| if [ "$REQUEST" = "location" ]; then |
| res=`cat /register_automate | grep -i "^#$SVC_TAG" | awk '{print $2}'` |
| elif [ "$REQUEST" = "switchinfo" ]; then |
| res=`cat /register_automate | grep -i "^#$SVC_TAG" | awk '{print $3}'` |
| elif [ "$REQUEST" = "pduinfo" ]; then |
| res=`cat /register_automate | grep -i "^#$SVC_TAG" | awk '{print $4}'` |
| elif [ "$REQUEST" = "image" ]; then |
| res=`cat /register_automate | grep -i "^#$SVC_TAG" | awk '{print $5}'` |
| fi |
| |
| if [ `echo -n $res | wc -c` -gt 1 ]; then |
| echo $res |
| exit 0 |
| else |
| echo "No entry found" >&2 |
| exit 1 |
| fi |