def create_vip(self, context, vip): self._validate_vip(vip) db_vip = self.plugin.populate_vip_graph(context, vip) vip_port = self.plugin._core_plugin._get_port(context, db_vip['port_id']) vip_utif_info = self._retrieve_utif_info(context, vip_port) vip_ip_allocation_info = utils.retrieve_ip_allocation_info( context, vip_port) vip_ip_allocation_info.is_gw = True db_pool = pool_utif_info = pool_ip_allocation_info = None members = monitors = [] if db_vip['pool_id']: db_pool = self.plugin.get_pool( context, db_vip['pool_id']) pool_port = edb.get_pool_port(context, db_pool["id"]) if pool_port: db_port = self.plugin._core_plugin._get_port( context, pool_port["port_id"]) pool_utif_info = self._retrieve_utif_info(context, db_port) pool_ip_allocation_info = utils.retrieve_ip_allocation_info( context, db_port) members = self.plugin.get_members( context, filters={'id': db_pool['members']}) monitors = self.plugin.get_members( context, filters={'id': db_pool['health_monitors']}) self._dispatcher.dispatch_lb( embrane_ctx.DispatcherContext(econ.Events.CREATE_VIP, db_vip, context, None), self._flavor, vip_utif_info, vip_ip_allocation_info, pool_utif_info, pool_ip_allocation_info, db_pool, members, monitors)
def create_vip(self, context, vip): self._validate_vip(vip) db_vip = self.plugin.populate_vip_graph(context, vip) vip_port = self.plugin._core_plugin._get_port(context, db_vip['port_id']) vip_utif_info = self._retrieve_utif_info(context, vip_port) vip_ip_allocation_info = utils.retrieve_ip_allocation_info( context, vip_port) vip_ip_allocation_info.is_gw = True db_pool = pool_utif_info = pool_ip_allocation_info = None members = monitors = [] if db_vip['pool_id']: db_pool = self.plugin.get_pool( context, db_vip['pool_id']) pool_port = edb.get_pool_port(context, db_pool["id"]) if pool_port: db_port = self.plugin._core_plugin._get_port( context, pool_port["port_id"]) pool_utif_info = self._retrieve_utif_info(context, db_port) pool_ip_allocation_info = utils.retrieve_ip_allocation_info( context, db_port) members = self.plugin.get_members( context, filters={'id': db_pool['members']}) monitors = self.plugin.get_members( context, filters={'id': db_pool['health_monitors']}) self._dispatcher.dispatch_lb( embrane_ctx.DispatcherContext(econ.Events.CREATE_VIP, db_vip, context, None), self._flavor, vip_utif_info, vip_ip_allocation_info, pool_utif_info, pool_ip_allocation_info, db_pool, members, monitors)
def update_vip(self, context, old_vip, vip): new_pool = old_port_id = removed_ip = None new_pool_utif = new_pool_ip_allocation = None old_pool = {} members = monitors = [] if old_vip['pool_id'] != vip['pool_id']: new_pool = self.plugin.get_pool( context, vip['pool_id']) members = self.plugin.get_members( context, filters={'id': new_pool['members']}) monitors = self.plugin.get_members( context, filters={'id': new_pool['health_monitors']}) new_pool_port = edb.get_pool_port(context, new_pool["id"]) if new_pool_port: db_port = self.plugin._core_plugin._get_port( context, new_pool_port["port_id"]) new_pool_utif = self._retrieve_utif_info(context, db_port) new_pool_ip_allocation = utils.retrieve_ip_allocation_info( context, db_port) old_pool = self.plugin.get_pool( context, old_vip['pool_id']) old_pool_port = edb.get_pool_port(context, old_pool["id"]) if old_pool_port: old_port = self.plugin._core_plugin._get_port( context, old_pool_port['port_id']) # remove that subnet ip removed_ip = old_port['fixed_ips'][0]['ip_address'] old_port_id = old_port['id'] self._dispatcher.dispatch_lb( embrane_ctx.DispatcherContext(econ.Events.UPDATE_VIP, vip, context, None), old_pool.get('id'), old_port_id, removed_ip, new_pool_utif, new_pool_ip_allocation, new_pool, members, monitors)
def add_router_interface(self, context, router_id, interface_info): """Grows DVA interface in the specified subnet.""" neutron_router = self._get_router(context, router_id) rport_qry = context.session.query(models_v2.Port) ports = rport_qry.filter_by( device_id=router_id).all() if len(ports) >= p_con.UTIF_LIMIT: raise neutron_exc.BadRequest( resource=router_id, msg=("this router doesn't support more than " + str(p_con.UTIF_LIMIT) + " interfaces")) neutron_router_iface = self._l3super.add_router_interface( self, context, router_id, interface_info) port = self._get_port(context, neutron_router_iface["port_id"]) utif_info = self._plugin_support.retrieve_utif_info(context, port) ip_allocation_info = utils.retrieve_ip_allocation_info(context, port) state_change = operation.Operation(self._set_db_router_state, args=(context, neutron_router, p_con.Status.UPDATING)) self._dispatcher.dispatch_l3( d_context=embrane_ctx.DispatcherContext( p_con.Events.GROW_ROUTER_IF, neutron_router, context, state_change), args=(utif_info, ip_allocation_info)) return neutron_router_iface
def add_router_interface(self, context, router_id, interface_info): """Grows DVA interface in the specified subnet.""" neutron_router = self._get_router(context, router_id) rport_qry = context.session.query(models_v2.Port) ports = rport_qry.filter_by( device_id=router_id).all() if len(ports) >= p_con.UTIF_LIMIT: raise neutron_exc.BadRequest( resource=router_id, msg=("this router doesn't support more than " + str(p_con.UTIF_LIMIT) + " interfaces")) neutron_router_iface = self._l3super.add_router_interface( self, context, router_id, interface_info) port = self._get_port(context, neutron_router_iface["port_id"]) utif_info = self._plugin_support.retrieve_utif_info(context, port) ip_allocation_info = utils.retrieve_ip_allocation_info(context, port) state_change = operation.Operation(self._set_db_router_state, args=(context, neutron_router, p_con.Status.UPDATING)) self._dispatcher.dispatch_l3( d_context=embrane_ctx.DispatcherContext( p_con.Events.GROW_ROUTER_IF, neutron_router, context, state_change), args=(utif_info, ip_allocation_info)) return neutron_router_iface
def update_vip(self, context, old_vip, vip): new_pool = old_port_id = removed_ip = None new_pool_utif = new_pool_ip_allocation = None old_pool = {} members = monitors = [] if old_vip['pool_id'] != vip['pool_id']: new_pool = self.plugin.get_pool( context, vip['pool_id']) members = self.plugin.get_members( context, filters={'id': new_pool['members']}) monitors = self.plugin.get_members( context, filters={'id': new_pool['health_monitors']}) new_pool_port = edb.get_pool_port(context, new_pool["id"]) if new_pool_port: db_port = self.plugin._core_plugin._get_port( context, new_pool_port["port_id"]) new_pool_utif = self._retrieve_utif_info(context, db_port) new_pool_ip_allocation = utils.retrieve_ip_allocation_info( context, db_port) old_pool = self.plugin.get_pool( context, old_vip['pool_id']) old_pool_port = edb.get_pool_port(context, old_pool["id"]) if old_pool_port: old_port = self.plugin._core_plugin._get_port( context, old_pool_port['port_id']) # remove that subnet ip removed_ip = old_port['fixed_ips'][0]['ip_address'] old_port_id = old_port['id'] self._dispatcher.dispatch_lb( embrane_ctx.DispatcherContext(econ.Events.UPDATE_VIP, vip, context, None), old_pool.get('id'), old_port_id, removed_ip, new_pool_utif, new_pool_ip_allocation, new_pool, members, monitors)
def create_router(self, context, router): r = router["router"] self._get_tenant_id_for_create(context, r) with context.session.begin(subtransactions=True): neutron_router = self._l3super.create_router(self, context, router) network_id = None gw_port = None ext_gw_info = neutron_router.get(l3_db.EXTERNAL_GW_INFO) if ext_gw_info: network_id = ext_gw_info.get("network_id") if network_id: gw_ports = self.get_ports( context, { "device_id": [id], "device_owner": ["network:router_gateway"] }) if len(gw_ports) != 1: raise c_exc.EmbranePluginException( err_msg=_("There must be only one gateway port " "per router at once")) gw_port = gw_ports[0] # For now, only small flavor is used utif_info = (self._plugin_support.retrieve_utif_info( context, gw_port) if network_id else None) ip_allocation_info = (utils.retrieve_ip_allocation_info( self, context, gw_port) if network_id else None) neutron_router = self._l3super._get_router(self, context, neutron_router["id"]) neutron_router["status"] = p_con.Status.CREATING self._dispatcher.dispatch_l3( d_context=embrane_ctx.DispatcherContext( p_con.Events.CREATE_ROUTER, neutron_router, context, None), args=(h_con.Flavor.SMALL, utif_info, ip_allocation_info)) return self._make_router_dict(neutron_router)
def create_router(self, context, router): r = router["router"] self._get_tenant_id_for_create(context, r) db_router = self._l3super.create_router(self, context, router) neutron_router = self._get_router(context, db_router['id']) gw_port = neutron_router.gw_port # For now, only small flavor is used utif_info = (self._plugin_support.retrieve_utif_info(context, gw_port) if gw_port else None) ip_allocation_info = (utils.retrieve_ip_allocation_info( context, gw_port) if gw_port else None) neutron_router = self._l3super._get_router(self, context, neutron_router["id"]) neutron_router["status"] = p_con.Status.CREATING self._dispatcher.dispatch_l3(d_context=embrane_ctx.DispatcherContext( p_con.Events.CREATE_ROUTER, neutron_router, context, None), args=(h_con.Flavor.SMALL, utif_info, ip_allocation_info)) return self._make_router_dict(neutron_router)
def update_router(self, context, id, router): db_router = self._l3super.update_router(self, context, id, router) neutron_router = self._get_router(context, db_router['id']) gw_port = neutron_router.gw_port utif_info = (self._plugin_support.retrieve_utif_info(context, gw_port) if gw_port else None) ip_allocation_info = (utils.retrieve_ip_allocation_info( context, gw_port) if gw_port else None) routes_info = router["router"].get("routes") neutron_router = self._l3super._get_router(self, context, id) state_change = operation.Operation(self._set_db_router_state, args=(context, neutron_router, p_con.Status.UPDATING)) self._dispatcher.dispatch_l3(d_context=embrane_ctx.DispatcherContext( p_con.Events.UPDATE_ROUTER, neutron_router, context, state_change), args=(utif_info, ip_allocation_info, routes_info)) return self._make_router_dict(neutron_router)
def create_router(self, context, router): r = router["router"] self._get_tenant_id_for_create(context, r) db_router = self._l3super.create_router(self, context, router) neutron_router = self._get_router(context, db_router['id']) gw_port = neutron_router.gw_port # For now, only small flavor is used utif_info = (self._plugin_support.retrieve_utif_info(context, gw_port) if gw_port else None) ip_allocation_info = (utils.retrieve_ip_allocation_info(context, gw_port) if gw_port else None) neutron_router = self._l3super._get_router(self, context, neutron_router["id"]) neutron_router["status"] = p_con.Status.CREATING self._dispatcher.dispatch_l3( d_context=embrane_ctx.DispatcherContext( p_con.Events.CREATE_ROUTER, neutron_router, context, None), args=(h_con.Flavor.SMALL, utif_info, ip_allocation_info)) return self._make_router_dict(neutron_router)
def update_router(self, context, id, router): with context.session.begin(subtransactions=True): db_router = self._l3super.update_router(self, context, id, router) gw_port = None ext_gw_info = db_router.get(l3_db.EXTERNAL_GW_INFO) if ext_gw_info: ext_gw_info = db_router[l3_db.EXTERNAL_GW_INFO] network_id = (ext_gw_info.get("network_id") if ext_gw_info else None) if network_id: gw_ports = self.get_ports( context, {"device_id": [id], "device_owner": ["network:router_gateway"]}) if len(gw_ports) != 1: raise c_exc.EmbranePluginException( err_msg=_("there must be only one gateway port" " per router at once")) gw_port = gw_ports[0] utif_info = (self._plugin_support.retrieve_utif_info(context, gw_port) if gw_port else None) ip_allocation_info = (utils.retrieve_ip_allocation_info(self, context, gw_port) if gw_port else None) routes_info = router["router"].get("routes") neutron_router = self._l3super._get_router(self, context, id) state_change = operation.Operation( self._set_db_router_state, args=(context, neutron_router, p_con.Status.UPDATING)) self._dispatcher.dispatch_l3( d_context=embrane_ctx.DispatcherContext( p_con.Events.UPDATE_ROUTER, neutron_router, context, state_change), args=(utif_info, ip_allocation_info, routes_info)) return self._make_router_dict(neutron_router)
def update_router(self, context, id, router): with context.session.begin(subtransactions=True): db_router = self._l3super.update_router(self, context, id, router) gw_port = None ext_gw_info = db_router.get(l3_db.EXTERNAL_GW_INFO) if ext_gw_info: ext_gw_info = db_router[l3_db.EXTERNAL_GW_INFO] network_id = (ext_gw_info.get("network_id") if ext_gw_info else None) if network_id: gw_ports = self.get_ports( context, { "device_id": [id], "device_owner": ["network:router_gateway"] }) if len(gw_ports) != 1: raise c_exc.EmbranePluginException( err_msg=_("There must be only one gateway port " "per router at once")) gw_port = gw_ports[0] utif_info = (self._plugin_support.retrieve_utif_info( context, gw_port) if gw_port else None) ip_allocation_info = (utils.retrieve_ip_allocation_info( self, context, gw_port) if gw_port else None) routes_info = router["router"].get("routes") neutron_router = self._l3super._get_router(self, context, id) state_change = operation.Operation(self._set_db_router_state, args=(context, neutron_router, p_con.Status.UPDATING)) self._dispatcher.dispatch_l3( d_context=embrane_ctx.DispatcherContext( p_con.Events.UPDATE_ROUTER, neutron_router, context, state_change), args=(utif_info, ip_allocation_info, routes_info)) return self._make_router_dict(neutron_router)
def update_router(self, context, id, router): db_router = self._l3super.update_router(self, context, id, router) neutron_router = self._get_router(context, db_router['id']) gw_port = neutron_router.gw_port utif_info = (self._plugin_support.retrieve_utif_info(context, gw_port) if gw_port else None) ip_allocation_info = (utils.retrieve_ip_allocation_info(context, gw_port) if gw_port else None) routes_info = router["router"].get("routes") neutron_router = self._l3super._get_router(self, context, id) state_change = operation.Operation( self._set_db_router_state, args=(context, neutron_router, p_con.Status.UPDATING)) self._dispatcher.dispatch_l3( d_context=embrane_ctx.DispatcherContext( p_con.Events.UPDATE_ROUTER, neutron_router, context, state_change), args=(utif_info, ip_allocation_info, routes_info)) return self._make_router_dict(neutron_router)
def create_router(self, context, router): r = router["router"] self._get_tenant_id_for_create(context, r) with context.session.begin(subtransactions=True): neutron_router = self._l3super.create_router(self, context, router) network_id = None gw_port = None ext_gw_info = neutron_router.get(l3_db.EXTERNAL_GW_INFO) if ext_gw_info: network_id = ext_gw_info.get("network_id") if network_id: gw_ports = self.get_ports( context, {"device_id": [id], "device_owner": ["network:router_gateway"]}) if len(gw_ports) != 1: raise c_exc.EmbranePluginException( err_msg=_("there must be only one gateway port " "per router at once")) gw_port = gw_ports[0] # For now, only small flavor is used utif_info = (self._plugin_support.retrieve_utif_info(context, gw_port) if network_id else None) ip_allocation_info = (utils.retrieve_ip_allocation_info(self, context, gw_port) if network_id else None) neutron_router = self._l3super._get_router(self, context, neutron_router["id"]) neutron_router["status"] = p_con.Status.CREATING self._dispatcher.dispatch_l3( d_context=embrane_ctx.DispatcherContext( p_con.Events.CREATE_ROUTER, neutron_router, context, None), args=(h_con.Flavor.SMALL, utif_info, ip_allocation_info)) return self._make_router_dict(neutron_router)