File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
systemvm/patches/debian/config/opt/cloud/bin Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 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
2221def 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
You can’t perform that action at this time.
0 commit comments