#!/opt/openstack/venv/bin/python import MySQLdb import sys import json connection = MySQLdb.connect( host=sys.argv[1], user="nova", passwd=sys.argv[2], db="nova") cursor = connection.cursor() cursor.execute("select network_info, instance_uuid from instance_info_caches where deleted=0") h = {} for f in cursor.fetchall(): d = json.loads(f[0])[0] d['details'].pop('ovs_hybrid_plug', None) net_prefix = d['network']['id'][:11] d['network']['bridge'] = "brq%s" % net_prefix d['network']['meta']['should_create_bridge'] = True d['ovs_interfaceid'] = None d['type'] = "bridge" h[f[1]] = json.dumps([d]) cursor.close() cursor = connection.cursor() for k in h.keys(): cursor.execute("update instance_info_caches set network_info='%s' where instance_uuid='%s'" % (h[k], k)) cursor.close() connection.commit() connection.close() connection = MySQLdb.connect( host=sys.argv[1], user="neutron", passwd=sys.argv[3], db="neutron") cursor = connection.cursor() cursor.execute("update ml2_port_bindings set vif_type='bridge', driver='linuxbridge', vif_details='{\"port_filter\": true}'") cursor.close() connection.commit() connection.close()