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 _provision_port_ha(self,
                        context,
                        ha_port,
                        subnet,
                        router,
                        ha_binding_db=None):
     ha_group_uuid = uuidutils.generate_uuid()
     router_id = router['id']
     with context.session.begin(subtransactions=True):
         ha_subnet_group = self._get_ha_group_by_ha_port_subnet_id(
             context, ha_port['id'], subnet['subnet_id'])
         if ha_subnet_group is not None:
             return
         if ha_binding_db is None:
             ha_binding_db = self._get_ha_binding(context, router_id)
         group_id = self.generate_ha_group_id(
             context, router,
             {'device_owner': DEVICE_OWNER_GLOBAL_ROUTER_GW}, ha_binding_db,
             ha_group_uuid)
         r_ha_g = ha_db.RouterHAGroup(id=ha_group_uuid,
                                      tenant_id='',
                                      ha_type=ha_binding_db.ha_type,
                                      group_identity=group_id,
                                      ha_port_id=ha_port['id'],
                                      extra_port_id=None,
                                      subnet_id=subnet['subnet_id'],
                                      user_router_id=router_id,
                                      timers_config='',
                                      tracking_config='',
                                      other_config='')
         context.session.add(r_ha_g)