====== Tömeges VLAN interfész generáló szkript ====== #!/bin/bash #A konfig fajl strukturaja: #OVS Szulo_interface VLAN_ID IP_cim Netmask LOGFILE="ovm_create_vlan_interfaces.log" . ovm_functions.sh kulcs_ellenorzes [[ -e $1 ]] || { echo "Add meg a konfig fajlt parameterkent."; exit 1; } while read LINE; do OVS_NAME=$(echo $LINE | cut -d' ' -f 1) IFACE_NAME=$(echo $LINE | cut -d' ' -f 2) VLAN=$(echo $LINE | cut -d' ' -f 3) IPADDR=$(echo $LINE | cut -d' ' -f 4) NETMASK=$(echo $LINE | cut -d' ' -f 5) IFACE_ID=$(ovm_cli list bondport | grep $OVS_NAME | grep $IFACE_NAME | grep -oP '(?<=id:)[^ ]+(?= )') echo -e "$yel$(date '+%Y.%m.%d %H:%M') | ${IFACE_NAME}.${VLAN} letrehozasa a(z) $OVS_NAME szerver $IFACE_NAME interfeszen:$end" | tee -a $LOGFILE VLAN_IFACE_ID=$(ovm_cli "create VlanInterface vlanId=${VLAN} mtu=1500 name=${IFACE_NAME}.${VLAN} on BondPort id=${IFACE_ID}" | tee /tmp/ovm_create_vlan_interfaces.tmp | grep -oP '(?<=id:)[^ ]+(?= )') RC=$? cat /tmp/ovm_create_vlan_interfaces.tmp | tee -a $LOGFILE if [[ $RC -eq 0 ]]; then echo "$yel$(date '+%Y.%m.%d %H:%M') | ${IFACE}.${VLAN} IP beallitas:$end" | tee -a $LOGFILE ovm_cli embeddedCreate VlanInterface id=${VLAN_IFACE_ID} ipAddressConfig ipAddressConfigType=STATIC ipAddress=$IPADDR ipNetmask=$NETMASK | tee /tmp/ovm_create_vlan_interfaces.tmp RC2=$? cat /tmp/ovm_create_vlan_interfaces.tmp | tee -a $LOGFILE if [[ $RC2 -eq 0 ]]; then echo "$grn$(date '+%Y.%m.%d %H:%M') | Sikerult!$end" | tee -a $LOGFILE else echo "$red$(date '+%Y.%m.%d %H:%M') | IP cim beallitas nem sikerült!$end" | tee -a $LOGFILE fi else echo "$red$(date '+%Y.%m.%d %H:%M') | Valami nem sikerült!$end" | tee -a $LOGFILE fi echo | tee >> $LOGFILE done <<< "`cat $1 | grep -v '^#' | sed 's/[[:space:]]\+/ /g' | tr -s '[:blank:]'`" sed -i -e 's/\x1b\[[0-9;]*m//g' -e 's/^M//g' $LOGFILE