def _create_dva_and_assign_address(api, tenant_id, neutron_router, flavor, utif_info=None, ip_allocation_info=None): """Creates a new router, and assign the gateway interface if any.""" dva = api.create_router(tenant_id=tenant_id, router_id=neutron_router["id"], name=neutron_router["name"], flavor=flavor, up=neutron_router["admin_state_up"]) try: if utif_info: api.grow_interface(utif_info, neutron_router["admin_state_up"], tenant_id, neutron_router["id"]) if ip_allocation_info: dva = api.allocate_address(neutron_router["id"], neutron_router["admin_state_up"], ip_allocation_info) except h_exc.PreliminaryOperationsFailed as ex: raise h_exc.BrokenInterface(err_msg=ex.message) state = api.extract_dva_state(dva) return state
def _shrink_dva_iface(api, tenant_id, neutron_router, port_id): try: dva = api.shrink_interface(tenant_id, neutron_router["id"], neutron_router["admin_state_up"], port_id) except h_exc.InterfaceNotFound: LOG.warning( _("Interface %s not found in the heleos back-end," "likely already deleted"), port_id) except h_exc.PreliminaryOperationsFailed as ex: raise h_exc.BrokenInterface(err_msg=ex.message) state = api.extract_dva_state(dva) return state
def _grow_dva_iface_and_assign_address(api, tenant_id, neutron_router, utif_info=None, ip_allocation_info=None): try: dva = api.grow_interface(utif_info, neutron_router["admin_state_up"], tenant_id, neutron_router["id"]) if ip_allocation_info: dva = api.allocate_address(neutron_router["id"], neutron_router["admin_state_up"], ip_allocation_info) except h_exc.PreliminaryOperationsFailed as ex: raise h_exc.BrokenInterface(err_msg=ex.message) state = api.extract_dva_state(dva) return state