V2T migration: Fix issues with api-replay
1. Add subnet host routes when enabling the dhcp 2. Add empty listeners to Lb objects Change-Id: I1754bf565ebbc90889e2f04e124fc7c08eedbad6
This commit is contained in:
parent
2f11462faf
commit
b5af694793
@ -565,6 +565,7 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
|
|||||||
|
|
||||||
# Handle DHCP enabled subnets
|
# Handle DHCP enabled subnets
|
||||||
enable_dhcp = False
|
enable_dhcp = False
|
||||||
|
sub_host_routes = None
|
||||||
if body['enable_dhcp']:
|
if body['enable_dhcp']:
|
||||||
count_dhcp_subnet = count_dhcp_subnet + 1
|
count_dhcp_subnet = count_dhcp_subnet + 1
|
||||||
# disable dhcp on subnet: we will enable it after creating
|
# disable dhcp on subnet: we will enable it after creating
|
||||||
@ -586,13 +587,17 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
|
|||||||
enable_dhcp = False
|
enable_dhcp = False
|
||||||
else:
|
else:
|
||||||
enable_dhcp = True
|
enable_dhcp = True
|
||||||
|
if body.get('host_routes'):
|
||||||
|
# Should be added when dhcp is enabled
|
||||||
|
sub_host_routes = body.pop('host_routes')
|
||||||
try:
|
try:
|
||||||
created_subnet = self.dest_neutron.create_subnet(
|
created_subnet = self.dest_neutron.create_subnet(
|
||||||
{'subnet': body})['subnet']
|
{'subnet': body})['subnet']
|
||||||
LOG.info("Created subnet: %s", created_subnet['id'])
|
LOG.info("Created subnet: %s", created_subnet['id'])
|
||||||
subnets_map[subnet_id] = created_subnet['id']
|
subnets_map[subnet_id] = created_subnet['id']
|
||||||
if enable_dhcp:
|
if enable_dhcp:
|
||||||
dhcp_subnets.append(created_subnet)
|
dhcp_subnets.append({'id': created_subnet['id'],
|
||||||
|
'host_routes': sub_host_routes})
|
||||||
except n_exc.BadRequest as e:
|
except n_exc.BadRequest as e:
|
||||||
LOG.error("Failed to create subnet: %(subnet)s: %(e)s",
|
LOG.error("Failed to create subnet: %(subnet)s: %(e)s",
|
||||||
{'subnet': subnet, 'e': e})
|
{'subnet': subnet, 'e': e})
|
||||||
@ -715,11 +720,14 @@ class ApiReplayClient(utils.PrepareObjectForMigration):
|
|||||||
'ip': ip_addr,
|
'ip': ip_addr,
|
||||||
'mac': created_port['mac_address']})
|
'mac': created_port['mac_address']})
|
||||||
|
|
||||||
# Enable dhcp on the relevant subnets:
|
# Enable dhcp on the relevant subnets, and re-add host routes:
|
||||||
for subnet in dhcp_subnets:
|
for subnet in dhcp_subnets:
|
||||||
try:
|
try:
|
||||||
|
data = {'enable_dhcp': True}
|
||||||
|
if subnet['host_routes']:
|
||||||
|
data['host_routes'] = subnet['host_routes']
|
||||||
self.dest_neutron.update_subnet(subnet['id'],
|
self.dest_neutron.update_subnet(subnet['id'],
|
||||||
{'subnet': {'enable_dhcp': True}})
|
{'subnet': data})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error("Failed to enable DHCP on subnet %(subnet)s: "
|
LOG.error("Failed to enable DHCP on subnet %(subnet)s: "
|
||||||
"%(e)s",
|
"%(e)s",
|
||||||
|
@ -315,18 +315,21 @@ class PrepareObjectForMigration(object):
|
|||||||
def prepare_lb_listener(self, listener_obj, lb_body):
|
def prepare_lb_listener(self, listener_obj, lb_body):
|
||||||
body = self.drop_fields(listener_obj, self.drop_lb_listener_fields)
|
body = self.drop_fields(listener_obj, self.drop_lb_listener_fields)
|
||||||
body['loadbalancer'] = lb_body
|
body['loadbalancer'] = lb_body
|
||||||
|
body['loadbalancer']['listeners'] = []
|
||||||
body['loadbalancer_id'] = lb_body['id']
|
body['loadbalancer_id'] = lb_body['id']
|
||||||
return body
|
return body
|
||||||
|
|
||||||
def prepare_lb_pool(self, pool_obj, lb_body):
|
def prepare_lb_pool(self, pool_obj, lb_body):
|
||||||
body = self.drop_fields(pool_obj, self.drop_lb_pool_fields)
|
body = self.drop_fields(pool_obj, self.drop_lb_pool_fields)
|
||||||
body['loadbalancer'] = lb_body
|
body['loadbalancer'] = lb_body
|
||||||
|
body['loadbalancer']['listeners'] = []
|
||||||
body['loadbalancer_id'] = lb_body['id']
|
body['loadbalancer_id'] = lb_body['id']
|
||||||
return body
|
return body
|
||||||
|
|
||||||
def prepare_lb_member(self, mem_obj, lb_body):
|
def prepare_lb_member(self, mem_obj, lb_body):
|
||||||
body = self.drop_fields(mem_obj, self.drop_lb_member_fields)
|
body = self.drop_fields(mem_obj, self.drop_lb_member_fields)
|
||||||
body['loadbalancer'] = lb_body
|
body['loadbalancer'] = lb_body
|
||||||
|
body['loadbalancer']['listeners'] = []
|
||||||
body['loadbalancer_id'] = lb_body['id']
|
body['loadbalancer_id'] = lb_body['id']
|
||||||
return body
|
return body
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user