vr: fix python exception when configure VRs (#4489)

before
```
root@r-27-VM:/var/cache/cloud# /opt/cloud/bin/configure.py monitor_service.json
ERROR:root:Command 'ip link show eth0 | grep 'state DOWN'' returned non-zero exit status 1
```

with this change
```
root@r-27-VM:/var/cache/cloud# /opt/cloud/bin/configure.py monitor_service.json
root@r-27-VM:/var/cache/cloud#
```
This commit is contained in:
Wei Zhou 2020-11-23 09:39:40 +01:00 committed by GitHub
parent 75fdb07387
commit 81ac9f90ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,7 +35,7 @@ STATE_COMMANDS = {"router": "ip addr show dev eth0 | grep inet | wc -l | xargs b
def reconfigure_interfaces(router_config, interfaces):
for interface in interfaces:
cmd = "ip link show %s | grep 'state DOWN'" % interface.get_device()
cmd = "ip link show %s | grep ' state '" % interface.get_device()
for device in execute(cmd):
if " DOWN " in device:
cmd = "ip link set %s up" % interface.get_device()