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