mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Replace chef with a python script configure.py will read the bags and (hopefully) create the desired state At this stage this is ipassociation This code should work for both VR and VPCrs TODO: iptables ip route throw (present in VR but not in VPCr Determine default route Unit tests
		
			
				
	
	
		
			19 lines
		
	
	
		
			629 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			629 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from pprint import pprint
 | |
| from netaddr import *
 | |
| 
 | |
| def merge(dbag, ip):
 | |
|     added = False
 | |
|     for dev in dbag:
 | |
|         if dev == "id":
 | |
|            continue
 | |
|         for address in dbag[dev]:
 | |
|             if address['public_ip'] == ip['public_ip']:
 | |
|                dbag[dev].remove(address)
 | |
|     if ip['add']:
 | |
|        ipo = IPNetwork(ip['public_ip'] + '/' + ip['netmask'])
 | |
|        ip['device'] = 'eth' + str(ip['nic_dev_id'])
 | |
|        ip['cidr'] = str(ipo.ip) + '/' + str(ipo.prefixlen)
 | |
|        ip['network'] = str(ipo.network) + '/' + str(ipo.prefixlen)
 | |
|        dbag.setdefault('eth' + str(ip['nic_dev_id']), []).append( ip )
 | |
|     return dbag
 |