Merge "Only update if there are networks to update"

This commit is contained in:
Jenkins
2012-01-17 23:31:14 +00:00
committed by Gerrit Code Review

View File

@@ -139,23 +139,7 @@ def upgrade(migrate_engine):
return subnet
# 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:
network = get_network_by_id(vif['network_id'])[0]
logging.info("Network for Instance %s: \n %s" % \
(instance['uuid'], network))
def _update_network(vif, network):
# vifs have a network which has subnets, so create the subnets
# subnets contain all of the ip information
network['subnets'] = []
@@ -206,6 +190,28 @@ def upgrade(migrate_engine):
if not 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
del vif['network_id']
vif['id'] = vif.pop('uuid')