nuancier: retire and remove from ansible

See https://pagure.io/fedora-infrastructure/issue/11371
This service is retired.

Signed-off-by: Kevin Fenzi <kevin@scrye.com>
This commit is contained in:
Kevin Fenzi 2023-11-15 10:44:00 -08:00
parent ea8c50232c
commit a60ca7159f
26 changed files with 2 additions and 680 deletions

View file

@ -17,5 +17,4 @@ db-openqa01.iad2.fedoraproject.org
db-koji01.iad2.fedoraproject.org
value01.iad2.fedoraproject.org
tang01.iad2.fedoraproject.org
#nuancier01.iad2.fedoraproject.org
ipa01.iad2.fedoraproject.org

View file

@ -1,10 +0,0 @@
---
ipa_client_shell_groups:
- sysadmin-datanommer
- sysadmin-noc
- sysadmin-veteran
ipa_client_sudo_groups:
- sysadmin-datanommer
ipa_host_group: nuancier
ipa_host_group_desc: Supplementary Wallpaper Voting
primary_auth_source: ipa

View file

@ -1,9 +0,0 @@
---
ipa_client_shell_groups:
- sysadmin-datanommer
- sysadmin-noc
- sysadmin-veteran
ipa_client_sudo_groups:
- sysadmin-datanommer
ipa_host_group: nuancier
ipa_host_group_desc: Supplementary Wallpaper Voting

View file

@ -17,7 +17,6 @@ databases:
- mbs
- mirrormanager2
- notifications
- nuancier_lite
- odcs
- pagure
- pdc
@ -42,7 +41,6 @@ dbs_to_backup:
- mbs
- mirrormanager2
- notifications
- nuancier_lite
- odcs
- pagure
- pdc

View file

@ -14,7 +14,6 @@ databases:
- mailman
- mirrormanager
- notifications
- nuancier_lite
- tahrir
datacenter: iad2
effective_cache_size: "12GB"

View file

@ -1,11 +0,0 @@
---
datacenter: iad2
eth0_ipv4_gw: 10.3.163.254
eth0_ipv4_ip: 10.3.163.99
ks_repo: http://10.3.163.35/repo/rhel/RHEL7-x86_64/
ks_url: http://10.3.163.35/repo/rhel/ks/kvm-rhel-7-iad2
tcp_ports: [80]
vmhost: vmhost-x86-04.iad2.fedoraproject.org
volgroup: /dev/vg_guests
wsgi_procs: 2
wsgi_threads: 2

View file

@ -1,11 +0,0 @@
---
datacenter: iad2
eth0_ipv4_gw: 10.3.163.254
eth0_ipv4_ip: 10.3.163.100
ks_repo: http://10.3.163.35/repo/rhel/RHEL7-x86_64/
ks_url: http://10.3.163.35/repo/rhel/ks/kvm-rhel-7-iad2
tcp_ports: [80]
vmhost: vmhost-x86-01.iad2.fedoraproject.org
volgroup: /dev/vg_guests
wsgi_procs: 2
wsgi_threads: 2

View file

@ -313,14 +313,6 @@ notifs-web01.iad2.fedoraproject.org
[notifs_web_stg]
notifs-web01.stg.iad2.fedoraproject.org
[nuancier]
nuancier01.iad2.fedoraproject.org
nuancier02.iad2.fedoraproject.org
[nuancier_stg]
# nuancier01.stg.iad2.fedoraproject.org
# nuancier02.stg.iad2.fedoraproject.org
[memcached]
memcached01.iad2.fedoraproject.org
@ -1240,7 +1232,6 @@ memcached
mm
nagios_iad2
notifs
nuancier
oci_registry
odcs
openqa
@ -1278,7 +1269,6 @@ koji_stg
mbs_stg
memcached_stg
mm_stg
nuancier_stg
oci_registry_stg
odcs_stg
pdc_web_stg

View file

@ -15,7 +15,6 @@
- include_playbook: /srv/web/infra/ansible/playbooks/groups/mailman.yml
- include_playbook: /srv/web/infra/ansible/playbooks/groups/notifs-backend.yml
- include_playbook: /srv/web/infra/ansible/playbooks/groups/notifs-web.yml
- include_playbook: /srv/web/infra/ansible/playbooks/groups/nuancier.yml
- include_playbook: /srv/web/infra/ansible/playbooks/groups/packages.yml
- include_playbook: /srv/web/infra/ansible/playbooks/groups/releng.yml
- include_playbook: /srv/web/infra/ansible/playbooks/groups/wiki.yml

View file

@ -1,131 +0,0 @@
# create a new nuancier server
# NOTE: should be used with --limit most of the time
# NOTE: make sure there is room/space for this server on the vmhost
# NOTE: most of these vars_path come from group_vars/nuancier* or from hostvars
- import_playbook: "/srv/web/infra/ansible/playbooks/include/virt-create.yml"
vars:
myhosts: "nuancier:nuancier_stg"
- name: make the box be real
hosts: nuancier:nuancier_stg
user: root
gather_facts: True
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
roles:
- base
- rkhunter
- nagios_client
- hosts
- { role: openvpn/client,
when: env != "staging" }
- ipa/client
- collectd/base
- sudo
- mod_wsgi
pre_tasks:
- import_tasks: "{{ tasks_path }}/yumrepos.yml"
tasks:
- import_tasks: "{{ tasks_path }}/motd.yml"
handlers:
- import_tasks: "{{ handlers_path }}/restart_services.yml"
- name: set up fedmsg
hosts: nuancier:nuancier_stg
user: root
gather_facts: True
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
roles:
- fedmsg/base
handlers:
- import_tasks: "{{ handlers_path }}/restart_services.yml"
- name: set up gluster on stg
hosts: nuancier_stg
user: root
gather_facts: True
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
roles:
- role: gluster/server
glusterservername: gluster
username: "{{ nuancier_gluster_username }}"
password: "{{ nuancier_gluster_password }}"
owner: root
group: root
datadir: /srv/glusterfs/nuancier-stg
- role: gluster/client
glusterservername: gluster
servers:
- nuancier01.stg.iad2.fedoraproject.org
- nuancier02.stg.iad2.fedoraproject.org
username: "{{ nuancier_gluster_username }}"
password: "{{ nuancier_gluster_password }}"
owner: apache
group: root
mountdir: /var/cache/nuancier
- name: set up gluster on prod
hosts: nuancier
user: root
gather_facts: True
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml
roles:
- role: gluster/server
glusterservername: gluster
username: "{{ nuancier_gluster_username }}"
password: "{{ nuancier_gluster_password }}"
owner: root
group: root
datadir: /srv/glusterfs/nuancier
- role: gluster/client
glusterservername: gluster
servers:
- nuancier01.iad2.fedoraproject.org
- nuancier02.iad2.fedoraproject.org
username: "{{ nuancier_gluster_username }}"
password: "{{ nuancier_gluster_password }}"
owner: apache
group: root
mountdir: /var/cache/nuancier
- name: deploy nuancier itself
hosts: nuancier:nuancier_stg
user: root
gather_facts: True
vars_files:
- /srv/web/infra/ansible/vars/global.yml
- "/srv/private/ansible/vars.yml"
- "{{ vars_path }}/{{ ansible_distribution }}.yml"
roles:
- nuancier
handlers:
- import_tasks: "{{ handlers_path }}/restart_services.yml"

View file

@ -126,14 +126,6 @@
proxyurl: http://value02
when: env == "staging"
- role: httpd/reverseproxy
website: apps.fedoraproject.org
destname: nuancier
localpath: /nuancier
remotepath: /nuancier
header_scheme: true
proxyurl: "{{ varnish_url }}"
- role: httpd/reverseproxy
website: apps.fedoraproject.org
destname: github2fedmsg

View file

@ -277,18 +277,6 @@ children:
Election application. Voting is a right and a duty as a member
of the community; it is one of the things you can do to
influence the development of Fedora.
- name: Nuancier
data:
icon: nuancier.png
url: https://apps.fedoraproject.org/nuancier
source_url: https://github.com/fedora-infra/nuancier
bugs_url: https://github.com/fedora-infra/nuancier/issues
docs_url: https://nuancier.readthedocs.org/en/latest/
sops:
- https://infrastructure.fedoraproject.org/infra/docs/nuancier.rst
description: >
Nuancier is a simple voting application for the
supplementary wallpapers included in Fedora.
- name: The Mailing lists
data:
icon: hyperkitty.png

View file

@ -72,7 +72,6 @@
- endpoints-fmn-web.py
- endpoints-github2fedmsg.py
- endpoints-kerneltest.py
- endpoints-nuancier.py
- endpoints-odcs-backend.py
- pkgdb.py
tags:

View file

@ -184,16 +184,6 @@ backend badges-backend
server badges-web01 badges-web01:80 check inter 10s rise 1 fall 2
option httpchk GET /heartbeat
frontend nuancier-frontend
bind 0.0.0.0:10035
default_backend nuancier-backend
backend nuancier-backend
balance hdr(appserver)
server nuancier01 nuancier01:80 check inter 10s rise 1 fall 2
server nuancier02 nuancier02:80 check inter 10s rise 1 fall 2
option httpchk GET /nuancier/
frontend notifs-web-frontend
bind 0.0.0.0:10036
default_backend notifs-web-backend

View file

@ -1,4 +1,4 @@
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.5.128.120 db01.stg.phx2.fedoraproject.org db-ask db-elections db-datanommer db-datanommer01 db-datanommer02 db-datanommer02.phx2.fedoraproject.org db-github2fedmsg db-fedocal tagger_dbdb-summershum db-tahrir db-notifs nuancier_db db-kerneltest
10.5.128.120 db01.stg.phx2.fedoraproject.org db-ask db-elections db-datanommer db-datanommer01 db-datanommer02 db-datanommer02.phx2.fedoraproject.org db-github2fedmsg db-fedocal tagger_dbdb-summershum db-tahrir db-notifs db-kerneltest

View file

@ -40,7 +40,7 @@ openid identity url template=http://%(username)s.id{{env_suffix}}.fedoraproject.
{% if env == 'staging' %}
openid trusted roots=
{% else %}
openid trusted roots=https://ask.fedoraproject.org/,https://fedorahosted.org/,https://badges.fedoraproject.org,https://apps.fedoraproject.org/nuancier/,https://apps.fedoraproject.org/datagrepper/,https://apps.fedoraproject.org/calendar/,http://notifications.fedoraproject.org/,http://copr.fedoraproject.org/,https://copr.fedoraproject.org/,https://admin.fedoraproject.org/voting/,https://apps.fedoraproject.org/github2fedmsg,https://admin.fedoraproject.org,https://apps.fedoraproject.org/,https://release-monitoring.org/,http://pagure.io/,http://admin.fedoraproject.org/mirrormanager/,https://koschei.fedoraproject.org/,https://bodhi.fedoraproject.org,https://lists.fedoraproject.org/,https://openqa.fedoraproject.org/,https://src.fedoraproject.org/
openid trusted roots=https://ask.fedoraproject.org/,https://fedorahosted.org/,https://badges.fedoraproject.org,https://apps.fedoraproject.org/datagrepper/,https://apps.fedoraproject.org/calendar/,http://notifications.fedoraproject.org/,http://copr.fedoraproject.org/,https://copr.fedoraproject.org/,https://admin.fedoraproject.org/voting/,https://apps.fedoraproject.org/github2fedmsg,https://admin.fedoraproject.org,https://apps.fedoraproject.org/,https://release-monitoring.org/,http://pagure.io/,http://admin.fedoraproject.org/mirrormanager/,https://koschei.fedoraproject.org/,https://bodhi.fedoraproject.org,https://lists.fedoraproject.org/,https://openqa.fedoraproject.org/,https://src.fedoraproject.org/
{% endif %}
{% if env == 'staging' %}
openid database url=postgresql://{{ ipsilon_db_user }}:{{ ipsilon_stg_db_pass }}@{{ ipsilon_db_host }}/{{ ipsilon_db_openid_name }}

View file

@ -39,9 +39,6 @@ command[check_datanommer_trac]={{libdir}}/nagios/plugins/check_datanommer_timesi
command[check_datanommer_rpmsign]=/usr/lib64/nagios/plugins/check_datanommer_timesince.py org.fedoraproject.prod.buildsys.rpm.sign 10800 14400
command[check_datanommer_wiki]={{libdir}}/nagios/plugins/check_datanommer_timesince.py wiki 259200 1814400
# This one is retired since it times out all the time. Too few messages.
#command[check_datanommer_nuancier]={{libdir}}/nagios/plugins/check_datanommer_timesince.py nuancier 23652000 31536000
# These are not actually finished and deployed yet
command[check_datanommer_mailman]={{libdir}}/nagios/plugins/check_datanommer_timesince.py mailman 14400 86400
command[check_datanommer_bugzilla]={{libdir}}/nagios/plugins/check_datanommer_timesince.py bugzilla 86400 259200

View file

@ -248,13 +248,6 @@ define service {
use websitetemplate
}
define service {
hostgroup_name nuancier
service_description http-apps.fedoraproject.org-nuancier
check_command check_website!localhost!/nuancier!Nuancier
use websitetemplate
}
#define service {
# hostgroup_name packages
# service_description http-packages-internal

View file

@ -1,123 +0,0 @@
---
# Configuration for the nuancier webapp
- name: install needed packages
package: name={{ item }} state=present
with_items:
- nuancier
- python-psycopg2
- python-openid-cla
- python-openid-teams
- python-memcached
- libsemanage-python
- python-alembic
tags:
- packages
- nuancier
- name: copy sundry nuancier configuration
template: src={{ item.file }}
dest={{ item.location }}/{{ item.dest }}
owner=apache group=apache mode=0600
with_items:
- { file: nuancier_admin.cfg, location: /etc/nuancier, dest: nuancier.cfg }
- { file: alembic.ini, location: /etc/nuancier, dest: alembic.ini }
changed_when: "1 != 1"
tags:
- config
- nuancier
notify:
- restart apache
- name: create pictures folder where we upload the pictures
file: state=directory
path=/var/cache/nuancier/pictures
owner=apache group=apache mode=0700
tags:
- setup
- nuancier
- name: create the cache folder where nuancier creates the thumbnails
file: state=directory
path=/var/cache/nuancier/cache
owner=apache group=apache mode=0700
tags:
- setup
- nuancier
- name: create the database scheme
command: /usr/bin/python2 /usr/share/nuancier/nuancier_createdb.py
environment:
NUANCIER_CONFIG: /etc/nuancier/nuancier.cfg
changed_when: "1 != 1"
tags:
- nuancier
- name: replace the nuancier configuration file by the one with the normal user
template: src={{ item.file }}
dest="{{ item.location }}/{{ item.file }}"
owner=apache group=apache mode=0600
changed_when: "1 != 1"
with_items:
- { file: nuancier.cfg, location: /etc/nuancier }
- { file: nuancier.conf, location: /etc/httpd/conf.d }
- { file: nuancier.wsgi, location: /var/www }
tags:
- config
- nuancier
notify:
- restart apache
- name: set sebooleans so nuancier can talk to the db
seboolean: name=httpd_can_network_connect_db
state=true
persistent=true
tags:
- nuancier
- selinux
- name: apply selinux type to static files
file: >
dest=/usr/lib/python2.6/site-packages/nuancier/static/
setype=httpd_sys_content_t
state=directory
recurse=yes
tags:
- nuancier
- selinux
- name: set sebooleans so apache can use glusterfs
seboolean: name=httpd_use_fusefs
state=true
persistent=true
tags:
- nuancier
- selinux
- name: set sebooleans so apache can send emails
seboolean: name=httpd_can_sendmail
state=true
persistent=true
tags:
- nuancier
- selinux
- name: apply selinux type to the wsgi file
file: >
dest=/var/www/nuancier.wsgi
setype=httpd_sys_content_t
tags:
- nuancier
- selinux
- name: Install SAR script for nuancier
template: src={{ item.file }}
dest="{{ item.location }}/{{ item.file }}"
owner=apache group=apache mode=0700
with_items:
- { file: nuancier_sar.py, location: /usr/local/bin }
tags:
- config
- nuancier
- SAR
- GDPR

View file

@ -1,54 +0,0 @@
# A generic, single database configuration.
[alembic]
# path to migration scripts
script_location = /usr/share/nuancier/alembic
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false
{% if env == "staging" %}
sqlalchemy.url = postgresql://{{ nuancier_stg_db_admin_user }}:{{ nuancier_stg_db_admin_pass }}@{{ nuancier_stg_db_host }}/{{ nuancier_stg_db_name }}
{% else %}
sqlalchemy.url = postgresql://{{ nuancier_db_admin_user }}:{{ nuancier_db_admin_pass }}@{{ nuancier_db_host }}/{{ nuancier_db_name }}
{% endif %}
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = WARN
handlers = console
qualname =
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
[logger_alembic]
level = INFO
handlers =
qualname = alembic
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

View file

@ -1,74 +0,0 @@
# Beware that the quotes around the values are mandatory
import os
### Secret key for the Flask application
{% if env == "staging" %}
SECRET_KEY='{{ nuancier_stg_secret_key }}'
{% else %}
SECRET_KEY='{{ nuancier_secret_key }}'
{% endif %}
### url to the database server:
{% if env == "staging" %}
DB_URL='postgresql://{{ nuancier_stg_db_user }}:{{ nuancier_stg_db_pass }}@{{ nuancier_stg_db_host }}/{{ nuancier_stg_db_name }}'
{% else %}
DB_URL='postgresql://{{ nuancier_db_user }}:{{ nuancier_db_pass }}@{{ nuancier_db_host }}/{{ nuancier_db_name }}'
{% endif %}
### The FAS groups in which the admin of nuancier are
### This can either be a single group or multiple, defined between
### parenthesis.
ADMIN_GROUP=('sysadmin-nuancier', 'sysadmin-main')
# FAS group for the nuancier reviewers
REVIEW_GROUP = ('nuancier-mentors')
# FAS group of users having a higher vote
WEIGHTED_GROUP = ('sysadmin-nuancier', 'designteam')
### Static folder
### The folder containing the css, javascript as well as the pictures
### candidates and the cache of those pictures.
### This directory should be somewhere where apache can access, it's
### proposed in '/var/www/nuancier'
STATIC_FOLDER = '/var/cache/nuancier'
### Pictures folder
### The folder in which are located the pictures of the different elections.
### This folder does not have to be writable by the application but should be
### readable.
### /!\ It should be the full path to this folder
PICTURE_FOLDER = os.path.join(STATIC_FOLDER, 'pictures')
### Cache folder
### The folder in which the application will generate thumbnails of the pictures
### selected for an election.
### This folder *must* be *writable* by the application.
### /!\ It should be the full path to this folder
CACHE_FOLDER = os.path.join(STATIC_FOLDER, 'cache')
### Size of the thumbnails (keeping the ratio)
### In order to reduce the loading page of the election page that might contains
### more than hundreds pictures, the application generates thumbnails of each
### pictures.
### The application will keep the ratio intact and just make sure that either
### length or width of the picture fit the length and width specified below.
THUMB_SIZE = (256, 256)
# This is required to fix login in stg
PREFERRED_URL_SCHEME='https'
# Make browsers send session cookie only via HTTPS
SESSION_COOKIE_SECURE = True
# Used by SESSION_COOKIE_PATH
APPLICATION_ROOT = '/nuancier/'
SESSION_COOKIE_NAME = 'nuancier'
# dogpile.cache configuration to work with memcached
NUANCIER_CACHE_BACKEND = 'dogpile.cache.memcached'
NUANCIER_CACHE_KWARGS = {'arguments' : {
'url': "127.0.0.1:11211",
}
}
NUANCIER_EMAIL_NOTIFICATIONS = True

View file

@ -1,24 +0,0 @@
Alias /nuancier/static /usr/lib/python2.7/site-packages/nuancier/static
WSGIDaemonProcess nuancier maximum-requests=1000 display-name=nuancier processes={{wsgi_procs}} threads={{wsgi_threads}}
WSGISocketPrefix run/wsgi
WSGIRestrictStdout On
WSGIRestrictSignal Off
WSGIPythonOptimize 1
WSGIScriptAlias /nuancier /var/www/nuancier.wsgi
<Location />
WSGIProcessGroup nuancier
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
</IfModule>
<IfModule !mod_authz_core.c>
# Apache 2.2
Order deny,allow
Allow from all
</IfModule>
</Location>

View file

@ -1,16 +0,0 @@
#-*- coding: utf-8 -*-
# The three lines below are required to run on EL6 as EL6 has
# two possible version of python-sqlalchemy and python-jinja2
# These lines make sure the application uses the correct version.
import __main__
__main__.__requires__ = ['SQLAlchemy >= 0.7', 'jinja2 >= 2.4']
import pkg_resources
import os
# Set the environment variable pointing to the configuration file
os.environ['NUANCIER_CONFIG'] = '/etc/nuancier/nuancier.cfg'
# The most import line to make the wsgi working
from nuancier import APP as application
application.debug = True

View file

@ -1,52 +0,0 @@
# Beware that the quotes around the values are mandatory
import os
### Secret key for the Flask application
{% if env == "staging" %}
SECRET_KEY='{{ nuancier_stg_secret_key }}'
{% else %}
SECRET_KEY='{{ nuancier_secret_key }}'
{% endif %}
### url to the database server:
{% if env == "staging" %}
DB_URL='postgresql://{{ nuancier_stg_db_admin_user }}:{{ nuancier_stg_db_admin_pass }}@{{ nuancier_stg_db_host }}/{{ nuancier_stg_db_name }}'
{% else %}
DB_URL='postgresql://{{ nuancier_db_admin_user }}:{{ nuancier_db_admin_pass }}@{{ nuancier_db_host }}/{{ nuancier_db_name }}'
{% endif %}
### The FAS groups in which the admin of nuancier are
### This can either be a single group or multiple, defined between
### parenthesis.
ADMIN_GROUP=('sysadmin-nuancier', 'sysadmin-main')
### Static folder
### The folder containing the css, javascript as well as the pictures
### candidates and the cache of those pictures.
### This directory should be somewhere where apache can access, it's
### proposed in '/var/www/nuancier'
STATIC_FOLDER = '/var/www/nuancier'
### Pictures folder
### The folder in which are located the pictures of the different elections.
### This folder does not have to be writable by the application but should be
### readable.
### /!\ It should be the full path to this folder
PICTURE_FOLDER = os.path.join(STATIC_FOLDER, 'pictures')
### Cache folder
### The folder in which the application will generate thumbnails of the pictures
### selected for an election.
### This folder *must* be *writable* by the application.
### /!\ It should be the full path to this folder
CACHE_FOLDER = os.path.join(STATIC_FOLDER, 'cache')
### Size of the thumbnails (keeping the ratio)
### In order to reduce the loading page of the election page that might contains
### more than hundreds pictures, the application generates thumbnails of each
### pictures.
### The application will keep the ratio intact and just make sure that either
### length or width of the picture fit the length and width specified below.
THUMB_SIZE = (256, 256)

View file

@ -1,89 +0,0 @@
#!/usr/bin/python
from __future__ import unicode_literals, print_function
import os
import json
import sys
if 'NUANCIER_CONFIG' not in os.environ \
and os.path.exists('/etc/nuancier/nuancier.cfg'):
os.environ['NUANCIER_CONFIG'] = '/etc/nuancier/nuancier.cfg'
from nuancier import SESSION # noqa
from nuancier.lib import model # noqa
_base_url = 'https://apps.fedoraproject.org/'\
'nuancier/pictures/{folder}/{filename}'
def get_user_candidates_by_name(username):
''' Return nuancier.lib.model.Candidate objects related to the
specified username.
'''
query = SESSION.query(
model.Candidates
).filter(
model.Candidates.candidate_submitter == username
).order_by(
model.Candidates.date_created
)
return query.all()
def get_user_candidates_by_email(email):
''' Return nuancier.lib.model.Candidate objects related to the
specified email address.
'''
query = SESSION.query(
model.Candidates
).filter(
model.Candidates.submitter_email == email
).order_by(
model.Candidates.date_created
)
return query.all()
def main():
''' Prints out all the candidates related to the username specified in
the SAR_USERNAME environment variable or the email address specified
in the SAR_EMAIL environment.
If no such SAR_USERNAME is available, the script will bail.
'''
email = os.getenv('SAR_EMAIL')
username = os.getenv('SAR_USERNAME')
if not username:
print('An username is required to query nuancier')
return 1
output = {}
output['candidates'] = []
# Get all candidates related to this user.
for candidate in get_user_candidates_by_name(username):
cand_json = candidate.api_repr(1)
cand_json['election'] = candidate.election.api_repr(1)
# Convert dates
for key in ['submission_date_start', 'submission_date_end',
'date_start', 'date_end']:
cand_json['election'][key] = \
cand_json['election'][key].isoformat()
# Add url to the candidate image
folder = candidate.election.election_folder
filename = candidate.candidate_file
cand_json['url'] = _base_url.format(
folder=folder, filename=filename)
output['candidates'].append(cand_json)
print(json.dumps(
output, sort_keys=True, indent=4, separators=(',', ': ')
).encode('utf-8'))
if __name__ == '__main__':
sys.exit(main())

View file

@ -42,11 +42,6 @@ sub vcl_init {
fas.add_backend(fas01);
}
backend nuancier {
.host = "localhost";
.port = "10035";
}
backend mirrormanager {
.host = "localhost";
.port = "10008";
@ -217,19 +212,6 @@ sub vcl_recv {
set req.url = regsub(req.url, "\?.*", "");
}
}
if (req.url ~ "^/nuancier") {
set req.backend_hint = nuancier;
if (req.url ~ "^/nuancier/static/") {
unset req.http.cookie;
set req.http.clear-cookies = "yes";
set req.url = regsub(req.url, "\?.*", "");
}
if (req.url ~ "^/nuancier/cache/") {
unset req.http.cookie;
set req.http.clear-cookies = "yes";
set req.url = regsub(req.url, "\?.*", "");
}
}
if (req.url ~ "^/packages/") {
set req.backend_hint = packages;
if (req.url ~ "^/packages/_res/") {