def unregister_instance(): payload = {'enabled': False} url = url_join(_get_url(), cephalopod_settings.get('uuid')) response = requests.patch(url, data=json.dumps(payload), headers=HEADERS, timeout=TIMEOUT, verify=(not config.DEBUG)) try: response.raise_for_status() except HTTPError as err: if err.response.status_code != 404: logger.error( 'failed to unregister the server to the community hub, got: %s', err) raise except Timeout: logger.error( 'failed to unregister: timeout while contacting the community hub') raise except RequestException as err: logger.error( 'unexpected exception while unregistering the server with the Community Hub: %s', err) raise cephalopod_settings.set('joined', False) logger.info('successfully unregistered the server from the community hub')
def migrate(self): self.migrate_global_ip_acl() self.migrate_api_settings() self.migrate_global_settings() self.migrate_user_management_settings() self.migrate_legal_settings() self.migrate_payment_settings() self.migrate_news_settings() self.migrate_news() self.migrate_networks() self.migrate_reference_types() cephalopod_settings.set('show_migration_message', True) db.session.commit()
def _process(self): form = CephalopodForm(obj=FormDefaults(**cephalopod_settings.get_all())) if form.validate_on_submit(): return self._process_form(form) hub_url = url_join(config.COMMUNITY_HUB_URL, 'api/instance/{}'.format(cephalopod_settings.get('uuid'))) cephalopod_settings.set('show_migration_message', False) return WPCephalopod.render_template('cephalopod.html', 'cephalopod', affiliation=core_settings.get('site_organization'), enabled=cephalopod_settings.get('joined'), form=form, indico_version=indico.__version__, instance_url=config.BASE_URL, language=config.DEFAULT_LOCALE, operating_system=get_os(), postgres_version=get_postgres_version(), python_version=platform.python_version(), hub_url=hub_url)
def _process(self): form = CephalopodForm(obj=FormDefaults(**cephalopod_settings.get_all())) if form.validate_on_submit(): return self._process_form(form) hub_url = url_join(config.COMMUNITY_HUB_URL, 'api/instance/{}'.format(cephalopod_settings.get('uuid'))) cephalopod_settings.set('show_migration_message', False) return WPCephalopod.render_template('cephalopod.html', 'cephalopod', affiliation=core_settings.get('site_organization'), enabled=cephalopod_settings.get('joined'), form=form, indico_version=indico.__version__, instance_url=config.BASE_URL, language=config.DEFAULT_LOCALE, operating_system=get_os(), postgres_version=get_postgres_version(), python_version=platform.python_version(), hub_url=hub_url, show_local_warning=(config.DEBUG or is_private_url(request.url_root)))
def unregister_instance(): payload = {'enabled': False} url = url_join(_get_url(), cephalopod_settings.get('uuid')) response = requests.patch(url, data=json.dumps(payload), headers=HEADERS, timeout=TIMEOUT, verify=(not config.DEBUG)) try: response.raise_for_status() except HTTPError as err: if err.response.status_code != 404: logger.error('failed to unregister the server to the community hub, got: %s', err.message) raise except Timeout: logger.error('failed to unregister: timeout while contacting the community hub') raise except RequestException as err: logger.error('unexpected exception while unregistering the server with the Community Hub: %s', err.message) raise cephalopod_settings.set('joined', False) logger.info('successfully unregistered the server from the community hub')
def register_instance(contact, email): payload = {'url': config.BASE_URL, 'contact': contact, 'email': email, 'organization': core_settings.get('site_organization')} response = requests.post(_get_url(), data=json.dumps(payload), headers=HEADERS, timeout=TIMEOUT, verify=(not config.DEBUG)) try: response.raise_for_status() except HTTPError as err: logger.error('failed to register the server to the community hub, got: %s', err.message) cephalopod_settings.set('joined', False) raise except Timeout: logger.error('failed to register: timeout while contacting the community hub') cephalopod_settings.set('joined', False) raise except RequestException as err: logger.error('unexpected exception while registering the server with the Community Hub: %s', err.message) raise json_response = response.json() if 'uuid' not in json_response: logger.error('invalid json reply from the community hub: uuid missing') cephalopod_settings.set('joined', False) raise ValueError('invalid json reply from the community hub: uuid missing') cephalopod_settings.set_multi({ 'joined': True, 'uuid': json_response['uuid'], 'contact_name': payload['contact'], 'contact_email': payload['email'] }) logger.info('successfully registered the server to the community hub')
def register_instance(contact, email): payload = {'url': config.BASE_URL, 'contact': contact, 'email': email, 'organization': core_settings.get('site_organization')} response = requests.post(_get_url(), data=json.dumps(payload), headers=HEADERS, timeout=TIMEOUT, verify=(not config.DEBUG)) try: response.raise_for_status() except HTTPError as err: logger.error('failed to register the server to the community hub, got: %s', err) cephalopod_settings.set('joined', False) raise except Timeout: logger.error('failed to register: timeout while contacting the community hub') cephalopod_settings.set('joined', False) raise except RequestException as err: logger.error('unexpected exception while registering the server with the Community Hub: %s', err) raise json_response = response.json() if 'uuid' not in json_response: logger.error('invalid json reply from the community hub: uuid missing') cephalopod_settings.set('joined', False) raise ValueError('invalid json reply from the community hub: uuid missing') cephalopod_settings.set_multi({ 'joined': True, 'uuid': json_response['uuid'], 'contact_name': payload['contact'], 'contact_email': payload['email'] }) logger.info('successfully registered the server to the community hub')
def _process(self): form = CephalopodForm(obj=FormDefaults( **cephalopod_settings.get_all())) if form.validate_on_submit(): return self._process_form(form) config = Config.getInstance() hub_url = url_join( config.getCommunityHubURL(), 'api/instance/{}'.format(cephalopod_settings.get('uuid'))) cephalopod_settings.set('show_migration_message', False) return WPCephalopod.render_template( 'cephalopod.html', 'cephalopod', affiliation=core_settings.get('site_organization'), enabled=cephalopod_settings.get('joined'), form=form, indico_version=indico.__version__, instance_url=config.getBaseURL(), language=config.getDefaultLocale(), operating_system=get_os(), postgres_version=get_postgres_version(), python_version=platform.python_version(), hub_url=hub_url)