Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vyatta] Bug fixes and improvements #327

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions src/partials/vyatta.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ while read -r net; \
do \
name="$(awk -F '|' '{print $3}' <<< "$net" | sed 's/management/mgmt/g' | tr -d ' ')"; \
if test "$(wc -c <<< "$name")" -gt 12; then name=$(head -c 10 <<< "$name"); fi; \
vlan="$(awk -F '|' '{print $4}' <<< "$net" | tr -d ' ')"; \
cidr="$(awk -F '|' '{print $5}' <<< "$net" | sed -E 's/ +//' | tr -d ' ' | tr '/' '_')"; \
cmd="govc host.portgroup.add -vswitch vSwitch0 ${name}-${cidr}-${vlan}"; \
cidr="$(awk -F '|' '{print $4}' <<< "$net" | sed -E 's/ +//' | tr -d ' ' | tr '/' '_')"; \
cmd="govc host.portgroup.add -vswitch vSwitch0 ${name}-${cidr}"; \
echo "--> $cmd"; \
$cmd; \
govc host.portgroup.change -allow-promiscuous=true -forged-transmits=true -mac-changes=true "${name}-${cidr}-${vlan}"; \
govc vm.network.add -vm="$VM_NAME" -net="${name}-${cidr}-${vlan}" -net.adapter=vmxnet3; \
done < <(grep --color -E 'Network +\|.*_pg +\| [0-9]{4} +\| 172.*' "src/deployment-guides/${DEPLOYMENT_GUIDE}.md")
govc host.portgroup.change -allow-promiscuous=true -forged-transmits=true -mac-changes=true "${name}-${cidr}"; \
govc vm.network.add -vm="$VM_NAME" -net="${name}-${cidr}" -net.adapter=vmxnet3; \
done < <(grep -E 'Network {0,}\|.*_pg {0,}\| {0,}[0-9]{3}\..*' "src/deployment-guides/${DEPLOYMENT_GUIDE}.md")
```
>
If your VM's NICs are connected to a port group on a distributed virtual
Expand All @@ -63,13 +62,12 @@ while read -r net; \
do \
name="$(awk -F '|' '{print $3}' <<< "$net" | sed 's/management/mgmt/g' | tr -d ' ')"; \
if test "$(wc -c <<< "$name")" -gt 12; then name=$(head -c 10 <<< "$name"); fi; \
vlan="$(awk -F '|' '{print $4}' <<< "$net" | tr -d ' ')"; \
cidr="$(awk -F '|' '{print $5}' <<< "$net" | sed -E 's/ +//' | tr -d ' ' | tr '/' '_')"; \
cmd="govc dvs.portgroup.add -dvs vSwitch0 ${name}-${cidr}-${vlan}"; \
vlan="$(awk -F '|' '{print $4}' <<< "$net" | tr -d ' ' | tr '/' '_')"; \
cmd="govc dvs.portgroup.add -dvs vSwitch0 ${name}-${vlan}"; \
echo "--> $cmd"; \
$cmd; \
govc vm.network.add -vm="$VM_NAME" -net="${name}-${cidr}-${vlan}" -net.adapter=vmxnet3; \
done < <(grep --color -E 'Network +\|.*_pg +\| [0-9]{4} +\| 172.*' "src/deployment-guides/${DEPLOYMENT_GUIDE}.md")
govc vm.network.add -vm="$VM_NAME" -net="${name}-${vlan}" -net.adapter=vmxnet3; \
done < <(grep -E 'Network {0,}\|.*_pg {0,}\| {0,}[0-9]{3}\..*' "src/deployment-guides/${DEPLOYMENT_GUIDE}.md")
```

Next, go into the vCenter portal and connect to the VM's console. Log in with the username `vyos` and the password `vyos`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Next, go into the vCenter portal and connect to the VM's console. Log in with the username `vyos` and the password `vyos`.
<<Although the following steps have not been modified, wanted to suggest some changes here. Can we change the following steps in a numbered format?>>
-----------------------------------------
1. Go into the vCenter portal and connect to the VM's console.
2. Log in with the username `vyos` and the password `vyos`.
3. Install VyOS onto the machine's disk. Type `install image`, follow the instructions, then shut the machine down. Disconnect its CD-ROM drive, then power it on and log in again.
4. Configure your WAN interface. We'll assume that the externally-accessible network is on subnet `10.213.234.0/24`
5. Run `ifconfig eth0`. Take note of the MAC address for this interface.
6. In vCenter, ensure that the NIC created for this VM with this MAC address is connected to your external network.
We'll assume that your externally-accessible NIC is `eth0`.
Once confirmed, assign this interface with a static IP address in its subnet:

Expand Down Expand Up @@ -148,13 +146,9 @@ the block of code above.
>
```sh
VYOS_IP=10.220.3.252
ifaces=$(sshpass -p vyos ssh vyos@$VYOS_IP
find /sys/class/net -mindepth 1 -maxdepth 1
-not -name lo -printf "%P: " -execdir 'cat {}/address \;')
ifaces=$(sshpass -p vyos ssh vyos@$VYOS_IP find /sys/class/net -mindepth 1 -maxdepth 1 -not -name lo -printf "%P: " -execdir 'cat {}/address \;')
govc vm.info -json=true $VM_NAME |
jq -r '.VirtualMachines[0].Config.Hardware.Device[] | \
select(.MacAddress != null and .DeviceInfo.Summary != "VM Network") | \
.MacAddress + ";" + .DeviceInfo.Summary' |
jq -r '.VirtualMachines[0].Config.Hardware.Device[] | select(.MacAddress != null and .DeviceInfo.Summary != "VM Network") | .MacAddress + ";" + .DeviceInfo.Summary' |
while read -r line;
do
mac=$(echo "$line" | cut -f1 -d ';');
Expand All @@ -171,21 +165,18 @@ If your NICs are connected to a distributed vSwitch, use this instead:
```sh
VYOS_IP=10.220.8.189
>&2 echo '---> Grabbing portgroup names';
portgroupNamesToKeys=$(h2o_govc find / -type DistributedVirtualPortgroup | \
portgroupNamesToKeys=$(govc find / -type DistributedVirtualPortgroup | \
while read -r pg; \
do \
h2o_govc object.collect -json=true "$pg" | jq -r '.[] |
govc object.collect -json=true "$pg" | jq -r '.[] |
select(.Name == "config") | .Val.Key + ":" + .Val.Name'; \
done
);
>&2 echo '---> Grabbing interfaces';
ifaces=$(sshpass -p vyos ssh vyos@$VYOS_IP find /sys/class/net -mindepth 1 -maxdepth 1 \
-not -name lo -printf "%P: " -execdir 'cat {}/address \;');
ifaces=$(sshpass -p vyos ssh vyos@$VYOS_IP find /sys/class/net -mindepth 1 -maxdepth 1 -not -name lo -printf "%P: " -execdir 'cat {}/address \;');
>&2 echo '---> Forming vyos interface commands';
h2o_govc vm.info -json=true $VM_NAME |
jq -r '.VirtualMachines[0].Config.Hardware.Device[] |
select(.MacAddress != null) |
.MacAddress + ";" + .Backing.Port.PortgroupKey' |
govc vm.info -json=true $VM_NAME |
jq -r '.VirtualMachines[0].Config.Hardware.Device[] | select(.MacAddress != null) | .MacAddress + ";" + .Backing.Port.PortgroupKey' |
while read -r line;
do
mac=$(echo "$line" | cut -f1 -d ';');
Expand All @@ -194,8 +185,8 @@ select(.MacAddress != null) |
gw=$(echo "$pg" | cut -f2 -d '-' | cut -f1 -d '_');
eth=$(grep "$mac" <<< "$ifaces" | cut -f1 -d ':');
test "$eth" == "eth0" && continue;
echo "set interface ethernet $eth ${gw}/27";
echo "set interface ethernet description $pg";
echo "set interface ethernet $eth address ${gw}/27";
echo "set interface ethernet $eth description $pg";
done
```

Expand Down