def _provision_ha(self, context, logical_global_router):
     with context.session.begin(subtransactions=True):
         ha_group_uuid = uuidutils.generate_uuid()
         group_id = self.generate_ha_group_id(
             context, logical_global_router,
             {'device_owner': l3_constants.DEVICE_OWNER_ROUTER_GW}, {},
             ha_group_uuid)
         subnet_id = logical_global_router[
             l3.EXTERNAL_GW_INFO]['external_fixed_ips'][0]['subnet_id']
         r_ha_s = ha_db.RouterHASetting(
             router_id=logical_global_router['id'],
             ha_type=cfg.CONF.ha.default_ha_mechanism,
             redundancy_level=1,
             priority=ha_db.DEFAULT_MASTER_PRIORITY,
             probe_connectivity=False,
             probe_target=None,
             probe_interval=None)
         context.session.add(r_ha_s)
         r_ha_g = ha_db.RouterHAGroup(
             id=ha_group_uuid,
             tenant_id='',
             ha_type=r_ha_s.ha_type,
             group_identity=group_id,
             ha_port_id=logical_global_router['gw_port_id'],
             extra_port_id=None,
             subnet_id=subnet_id,
             user_router_id=logical_global_router['id'],
             timers_config='',
             tracking_config='',
             other_config='')
         context.session.add(r_ha_g)
 def _create_logical_global_router(self, context, tenant_router):
     r_spec = {
         'router': {
             # global routers are not tied to any tenant
             'tenant_id':
             '',
             'name':
             self._global_router_name('', logical=True),
             'admin_state_up':
             True,
             # set auto-schedule to false to keep this router un-hosted
             routertypeawarescheduler.AUTO_SCHEDULE_ATTR:
             False
         }
     }
     # notifications should never be sent for this logical router!
     logical_global_router, r_hd_b_db = (self._l3_plugin.do_create_router(
         context, r_spec, tenant_router[routertype.TYPE_ATTR], False, True,
         None, ROUTER_ROLE_LOGICAL_GLOBAL))
     with context.session.begin(subtransactions=True):
         r_ha_s_db = ha_db.RouterHASetting(
             router_id=logical_global_router['id'],
             ha_type=cfg.CONF.ha.default_ha_mechanism,
             redundancy_level=1,
             priority=ha_db.DEFAULT_MASTER_PRIORITY,
             probe_connectivity=False,
             probe_target=None,
             probe_interval=None)
         context.session.add(r_ha_s_db)
     return logical_global_router