def _add_service_magpie_and_phoenix(svc, svc_push, db): db.add(svc) if svc_push and svc.type in SERVICES_PHOENIX_ALLOWED: sync_services_phoenix(db.query(models.Service)) # sometimes, resource ID is not updated, fetch the service to obtain it if not svc.resource_id: svc = ax.evaluate_call( lambda: models.Service.by_service_name(service_name, db_session=db_session), fallback=lambda: db_session.rollback(), http_error=HTTPInternalServerError, msg_on_fail=s.Services_POST_InternalServerErrorResponseSchema. description, content={ "service_name": str(service_name), "resource_id": svc.resource_id }) ax.verify_param( svc.resource_id, not_none=True, param_compare=int, is_type=True, http_error=HTTPInternalServerError, msg_on_fail=s.Services_POST_InternalServerErrorResponseSchema. description, content={ "service_name": str(service_name), "resource_id": svc.resource_id }, param_name="service_name") return svc
def update_service_magpie_and_phoenix(_svc, new_name, new_url, svc_push, db_session): _svc.resource_name = new_name _svc.url = new_url has_getcap = Permission.GET_CAPABILITIES in SERVICE_TYPE_DICT[_svc.type].permissions if svc_push and _svc.type in SERVICES_PHOENIX_ALLOWED and has_getcap: # (re)apply getcapabilities to updated service to ensure updated push su.add_service_getcapabilities_perms(_svc, db_session) sync_services_phoenix(db_session.query(models.Service)) # push all services
def view_services(self): if "delete" in self.request.POST: service_name = self.request.POST.get("service_name") service_data = { u"service_push": self.request.POST.get("service_push") } path = schemas.ServiceAPI.path.format(service_name=service_name) resp = request_api(self.request, path, "DELETE", data=json.dumps(service_data)) check_response(resp) cur_svc_type = self.request.matchdict["cur_svc_type"] svc_types, cur_svc_type, services = self.get_services(cur_svc_type) service_names = services.keys() success_sync = None if "phoenix_push" in self.request.POST: if cur_svc_type in register.SERVICES_PHOENIX_ALLOWED: success_sync = register.sync_services_phoenix( services, services_as_dicts=True) if "edit" in self.request.POST: service_name = self.request.POST.get("service_name") return HTTPFound( self.request.route_url("edit_service", service_name=service_name, cur_svc_type=cur_svc_type)) return add_template_data( self.request, { u"cur_svc_type": cur_svc_type, u"svc_types": svc_types, u"service_names": service_names, u"service_push_show": cur_svc_type in register.SERVICES_PHOENIX_ALLOWED, u"service_push_success": success_sync })
def rename_service_magpie_and_phoenix(res, new_name, svc_push, db): if res.resource_type != "service": svc_push = False res.resource_name = new_name if svc_push: sync_services_phoenix(db.query(models.Service))
def remove_service_magpie_and_phoenix(res, svc_push, db): if res.resource_type != "service": svc_push = False db.delete(res) if svc_push: sync_services_phoenix(db.query(models.Service))
def remove_service_magpie_and_phoenix(svc, svc_push, db_session): db_session.delete(svc) if svc_push and svc.type in SERVICES_PHOENIX_ALLOWED: sync_services_phoenix(db_session.query(models.Service))
def rename_service_magpie_and_phoenix(): resource.resource_name = res_new_name if is_res_svc and service_push: sync_services_phoenix(all_services)