lgromero-new-oglive
Last change
on this file was
cf14a94,
checked in by Natalia Serrano <natalia.serrano@…>, 6 months ago
|
refs #941 try to make installer on ESXi pick oglive/ogagent from NFS
|
-
Property mode set to
100755
|
File size:
1.3 KB
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | |
---|
3 | set -e |
---|
4 | |
---|
5 | BRANCH=$1 |
---|
6 | BRANCH=${BRANCH:-"main"} |
---|
7 | ESXCLI=/usr/bin/esxcli |
---|
8 | VSWITCH="vSwitch2" |
---|
9 | source ~/.pass |
---|
10 | |
---|
11 | |
---|
12 | # Check if portgroup exists |
---|
13 | function checkIfPortgroupExists () { |
---|
14 | local i=0 |
---|
15 | PORTGROUPS=( $($ESXCLI network vswitch standard portgroup list | grep $BRANCH | awk ' { print $1 }') ) |
---|
16 | for portgroup in "${PORTGROUPS[@]}"; do |
---|
17 | if [ $portgroup == $BRANCH ] ; then |
---|
18 | echo "Portgroup $BRANCH is not going to be created, already exists" |
---|
19 | echo "Please Check ESXI configuration" |
---|
20 | exit 0 |
---|
21 | fi |
---|
22 | done |
---|
23 | } |
---|
24 | function createPortGroup() { |
---|
25 | echo Adding portgroup $BRANCH to $VSWITCH |
---|
26 | $ESXCLI network vswitch standard portgroup add --portgroup-name=$BRANCH --vswitch-name=$VSWITCH |
---|
27 | } |
---|
28 | |
---|
29 | function getMaxVlan(){ |
---|
30 | PORTGROUPS=( $($ESXCLI --formatter=csv network vswitch standard portgroup list | grep $VSWITCH | cut -d "," -f3 ) ) |
---|
31 | IFS=$'\n' |
---|
32 | MAX_VLAN=$(echo "${PORTGROUPS[*]}" | sort -nr | head -n1) |
---|
33 | NEXT_VLAN=$(( MAX_VLAN + 1 )) |
---|
34 | [[ $NEXT_VLAN -lt 3000 ]] && NEXT_VLAN=3000 |
---|
35 | echo VLAN assigned is $NEXT_VLAN |
---|
36 | } |
---|
37 | |
---|
38 | function setVlan(){ |
---|
39 | $ESXCLI network vswitch standard portgroup set -p $BRANCH --vlan-id $1 |
---|
40 | } |
---|
41 | |
---|
42 | #### SCRIPT |
---|
43 | checkIfPortgroupExists |
---|
44 | createPortGroup |
---|
45 | getMaxVlan |
---|
46 | setVlan $NEXT_VLAN |
---|
47 | echo portgroup $BRANCH created with vlan_id $NEXT_VLAN |
---|
Note: See
TracBrowser
for help on using the repository browser.