api_reply: migrate routers static routes
Change-Id: I546052ae3f4089af55d0c2a569de6f87d2a61984
This commit is contained in:
parent
1e2ba282ce
commit
56dd2d0525
@ -10,6 +10,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from neutronclient.common import exceptions as n_exc
|
from neutronclient.common import exceptions as n_exc
|
||||||
from neutronclient.v2_0 import client
|
from neutronclient.v2_0 import client
|
||||||
@ -46,9 +47,10 @@ class ApiReplayClient(object):
|
|||||||
|
|
||||||
self.migrate_security_groups()
|
self.migrate_security_groups()
|
||||||
self.migrate_qos_policies()
|
self.migrate_qos_policies()
|
||||||
self.migrate_routers()
|
routers_routes = self.migrate_routers()
|
||||||
self.migrate_networks_subnets_ports()
|
self.migrate_networks_subnets_ports()
|
||||||
self.migrate_floatingips()
|
self.migrate_floatingips()
|
||||||
|
self.migrate_routers_routes(routers_routes)
|
||||||
|
|
||||||
def find_subnet_by_id(self, subnet_id, subnets):
|
def find_subnet_by_id(self, subnet_id, subnets):
|
||||||
for subnet in subnets:
|
for subnet in subnets:
|
||||||
@ -229,13 +231,22 @@ class ApiReplayClient(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def migrate_routers(self):
|
def migrate_routers(self):
|
||||||
"""Migrates routers from source to dest neutron."""
|
"""Migrates routers from source to dest neutron.
|
||||||
|
|
||||||
|
Also return a dictionary of the routes that should be added to
|
||||||
|
each router. Static routes must be added later, after the router
|
||||||
|
ports are set.
|
||||||
|
"""
|
||||||
source_routers = self.source_neutron.list_routers()['routers']
|
source_routers = self.source_neutron.list_routers()['routers']
|
||||||
dest_routers = self.dest_neutron.list_routers()['routers']
|
dest_routers = self.dest_neutron.list_routers()['routers']
|
||||||
|
update_routes = {}
|
||||||
|
|
||||||
for router in source_routers:
|
for router in source_routers:
|
||||||
dest_router = self.have_id(router['id'], dest_routers)
|
dest_router = self.have_id(router['id'], dest_routers)
|
||||||
if dest_router is False:
|
if dest_router is False:
|
||||||
|
if router.get('routes'):
|
||||||
|
update_routes[router['id']] = router['routes']
|
||||||
|
|
||||||
drop_router_fields = ['status',
|
drop_router_fields = ['status',
|
||||||
'routes',
|
'routes',
|
||||||
'ha',
|
'ha',
|
||||||
@ -249,6 +260,14 @@ class ApiReplayClient(object):
|
|||||||
new_router = (self.dest_neutron.create_router(
|
new_router = (self.dest_neutron.create_router(
|
||||||
{'router': body}))
|
{'router': body}))
|
||||||
print("created router %s" % new_router)
|
print("created router %s" % new_router)
|
||||||
|
return update_routes
|
||||||
|
|
||||||
|
def migrate_routers_routes(self, routers_routes):
|
||||||
|
"""Add static routes to the created routers."""
|
||||||
|
for router_id, routes in six.iteritems(routers_routes):
|
||||||
|
self.dest_neutron.update_router(router_id,
|
||||||
|
{'router': {'routes': routes}})
|
||||||
|
print("Added routes to router %s" % router_id)
|
||||||
|
|
||||||
def migrate_networks_subnets_ports(self):
|
def migrate_networks_subnets_ports(self):
|
||||||
"""Migrates networks/ports/router-uplinks from src to dest neutron."""
|
"""Migrates networks/ports/router-uplinks from src to dest neutron."""
|
||||||
|
Loading…
Reference in New Issue
Block a user