Skip to content

Commit 7c33083

Browse files
committed
fixed the incorrect ordering of public IPs on eth1 after a VR reboot
1 parent 5a3f479 commit 7c33083

File tree

1 file changed

+9
-7
lines changed
  • systemvm/patches/debian/config/opt/cloud/bin

1 file changed

+9
-7
lines changed

systemvm/patches/debian/config/opt/cloud/bin/cs_ip.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,20 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18-
from pprint import pprint
19-
from netaddr import *
2018

19+
from netaddr import *
2120

2221
def merge(dbag, ip):
23-
added = False
2422
nic_dev_id = None
23+
index = -1 # a non-valid array index
2524
for dev in dbag:
2625
if dev == "id":
2726
continue
28-
for address in dbag[dev]:
27+
for i, address in enumerate(dbag[dev]):
2928
if address['public_ip'] == ip['public_ip']:
3029
if 'nic_dev_id' in address:
3130
nic_dev_id = address['nic_dev_id']
32-
dbag[dev].remove(address)
31+
index = i
3332

3433
ipo = IPNetwork(ip['public_ip'] + '/' + ip['netmask'])
3534
if 'nic_dev_id' in ip:
@@ -42,8 +41,11 @@ def merge(dbag, ip):
4241
if 'nw_type' not in ip.keys():
4342
ip['nw_type'] = 'public'
4443
if ip['nw_type'] == 'control':
45-
dbag['eth' + str(nic_dev_id)] = [ip]
44+
dbag[ip['device']] = [ip]
4645
else:
47-
dbag.setdefault('eth' + str(nic_dev_id), []).append(ip)
46+
if index != -1:
47+
dbag[ip['device']][index] = ip
48+
else:
49+
dbag.setdefault(ip['device'], []).append(ip)
4850

4951
return dbag

0 commit comments

Comments
 (0)