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,6 +139,57 @@ def upgrade(migrate_engine):
return subnet
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'] = []
network['dns1'] = _ip_dict_from_string(network['dns1'], 'dns')
network['dns2'] = _ip_dict_from_string(network['dns2'], 'dns')
# nova networks can only have 2 subnets
if network['cidr']:
network['subnets'].append(_create_subnet(4, network, vif))
if network['cidr_v6']:
network['subnets'].append(_create_subnet(6, network, vif))
# put network together to fit model
network['id'] = network.pop('uuid')
network['meta'] = {}
# NOTE(tr3buchet) this isn't absolutely necessary as hydration
# would still work with these as keys, but cache generated by
# the model would show these keys as a part of meta. i went
# ahead and set it up the same way just so it looks the same
if network['project_id']:
network['meta']['project_id'] = network['project_id']
del network['project_id']
if network['injected']:
network['meta']['injected'] = network['injected']
del network['injected']
if network['multi_host']:
network['meta']['multi_host'] = network['multi_host']
del network['multi_host']
if network['bridge_interface']:
network['meta']['bridge_interface'] = \
network['bridge_interface']
del network['bridge_interface']
if network['vlan']:
network['meta']['vlan'] = network['vlan']
del network['vlan']
# ip information now lives in the subnet, pull them out of network
del network['dns1']
del network['dns2']
del network['cidr']
del network['cidr_v6']
del network['gateway']
del network['gateway_v6']
# don't need meta if it's empty
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():
@@ -152,59 +203,14 @@ def upgrade(migrate_engine):
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" % \
networks_ = get_network_by_id(vif['network_id'])
if networks_:
network = networks_[0]
logging.info("Network for Instance %s: \n %s" % \
(instance['uuid'], network))
# vifs have a network which has subnets, so create the subnets
# subnets contain all of the ip information
network['subnets'] = []
network['dns1'] = _ip_dict_from_string(network['dns1'], 'dns')
network['dns2'] = _ip_dict_from_string(network['dns2'], 'dns')
# nova networks can only have 2 subnets
if network['cidr']:
network['subnets'].append(_create_subnet(4, network, vif))
if network['cidr_v6']:
network['subnets'].append(_create_subnet(6, network, vif))
# put network together to fit model
network['id'] = network.pop('uuid')
network['meta'] = {}
# NOTE(tr3buchet) this isn't absolutely necessary as hydration
# would still work with these as keys, but cache generated by
# the model would show these keys as a part of meta. i went
# ahead and set it up the same way just so it looks the same
if network['project_id']:
network['meta']['project_id'] = network['project_id']
del network['project_id']
if network['injected']:
network['meta']['injected'] = network['injected']
del network['injected']
if network['multi_host']:
network['meta']['multi_host'] = network['multi_host']
del network['multi_host']
if network['bridge_interface']:
network['meta']['bridge_interface'] = \
network['bridge_interface']
del network['bridge_interface']
if network['vlan']:
network['meta']['vlan'] = network['vlan']
del network['vlan']
# ip information now lives in the subnet, pull them out of network
del network['dns1']
del network['dns2']
del network['cidr']
del network['cidr_v6']
del network['gateway']
del network['gateway_v6']
# don't need meta if it's empty
if not network['meta']:
del network['meta']
_update_network(vif, network)
else:
network = None
# put vif together to fit model
del vif['network_id']