Merge "Only update if there are networks to update"
This commit is contained in:
@@ -139,23 +139,7 @@ def upgrade(migrate_engine):
|
|||||||
|
|
||||||
return subnet
|
return subnet
|
||||||
|
|
||||||
# preload caches table
|
def _update_network(vif, network):
|
||||||
# list is made up of a row(instance_id, nw_info_json) for each instance
|
|
||||||
for instance in get_instances():
|
|
||||||
logging.info("Updating %s" % (instance['uuid']))
|
|
||||||
instance_id = instance['id']
|
|
||||||
instance_uuid = instance['uuid']
|
|
||||||
|
|
||||||
# instances have vifs so aninstance nw_info is
|
|
||||||
# is a list of dicts, 1 dict for each vif
|
|
||||||
nw_info = get_vifs_by_instance_id(instance_id)
|
|
||||||
logging.info("VIFs for Instance %s: \n %s" % \
|
|
||||||
(instance['uuid'], nw_info))
|
|
||||||
for vif in nw_info:
|
|
||||||
network = get_network_by_id(vif['network_id'])[0]
|
|
||||||
logging.info("Network for Instance %s: \n %s" % \
|
|
||||||
(instance['uuid'], network))
|
|
||||||
|
|
||||||
# vifs have a network which has subnets, so create the subnets
|
# vifs have a network which has subnets, so create the subnets
|
||||||
# subnets contain all of the ip information
|
# subnets contain all of the ip information
|
||||||
network['subnets'] = []
|
network['subnets'] = []
|
||||||
@@ -206,6 +190,28 @@ def upgrade(migrate_engine):
|
|||||||
if not network['meta']:
|
if not network['meta']:
|
||||||
del network['meta']
|
del network['meta']
|
||||||
|
|
||||||
|
# preload caches table
|
||||||
|
# list is made up of a row(instance_id, nw_info_json) for each instance
|
||||||
|
for instance in get_instances():
|
||||||
|
logging.info("Updating %s" % (instance['uuid']))
|
||||||
|
instance_id = instance['id']
|
||||||
|
instance_uuid = instance['uuid']
|
||||||
|
|
||||||
|
# instances have vifs so aninstance nw_info is
|
||||||
|
# is a list of dicts, 1 dict for each vif
|
||||||
|
nw_info = get_vifs_by_instance_id(instance_id)
|
||||||
|
logging.info("VIFs for Instance %s: \n %s" % \
|
||||||
|
(instance['uuid'], nw_info))
|
||||||
|
for vif in nw_info:
|
||||||
|
networks_ = get_network_by_id(vif['network_id'])
|
||||||
|
if networks_:
|
||||||
|
network = networks_[0]
|
||||||
|
logging.info("Network for Instance %s: \n %s" % \
|
||||||
|
(instance['uuid'], network))
|
||||||
|
_update_network(vif, network)
|
||||||
|
else:
|
||||||
|
network = None
|
||||||
|
|
||||||
# put vif together to fit model
|
# put vif together to fit model
|
||||||
del vif['network_id']
|
del vif['network_id']
|
||||||
vif['id'] = vif.pop('uuid')
|
vif['id'] = vif.pop('uuid')
|
||||||
|
|||||||
Reference in New Issue
Block a user