Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Issue 399 part 2: MOU Generation #549

Merged
merged 99 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
98f8c51
add test impl
ViRu-ThE-ViRuS May 13, 2023
db6d668
resolved merge conflict
Hzaakk May 23, 2023
a1b7fa9
testing using python 3.8
Hzaakk May 23, 2023
270fa94
bug with prev commit
Hzaakk May 23, 2023
567963e
testing local storage
Hzaakk May 24, 2023
5b04da3
Merge branch 'issue_540' into issue_399
Hzaakk May 24, 2023
f72f3a4
implemented mou upload and download process for secure dir, SU, and p…
Hzaakk May 25, 2023
360192b
fixed cancel button
Hzaakk May 25, 2023
9d9bfc2
got google drive working
Hzaakk May 25, 2023
c2f5c49
removing gdstorage
Hzaakk Jun 5, 2023
722be73
got google drive working with custom filenames
Hzaakk Jun 9, 2023
81d8dbd
fixed media root error
Hzaakk Jun 12, 2023
dc5ade4
fixed main.yml
Hzaakk Jun 12, 2023
ad2bf97
validation, only in progress uploads, iso 8601 format
Hzaakk Jun 21, 2023
b3f44bd
added file size validation and fixed error messages
Hzaakk Jun 21, 2023
9e090c3
fixed testing
Hzaakk Jun 21, 2023
7408f7e
fixed testing again
Hzaakk Jun 21, 2023
bc06865
initial attempt at generation
Hzaakk Jun 26, 2023
3f0c295
pdf writing but needs click
Hzaakk Jul 3, 2023
2624d88
final pypdf try before html
Hzaakk Jul 10, 2023
916906d
working mou generation for ICA and recharge
Hzaakk Jul 12, 2023
cf9e2a6
initial secure dir mou implementation
Hzaakk Jul 12, 2023
840856a
fixed title for Secure Dir
Hzaakk Jul 17, 2023
49e62ea
fixed some bugs
Hzaakk Jul 17, 2023
4007b2e
before moving body text to template files
Hzaakk Jul 24, 2023
989ce0e
moved body strings to templates
Hzaakk Jul 24, 2023
c385561
removed unused imports
Hzaakk Jul 24, 2023
b5737bd
added extra field editing button for projects
Hzaakk Jul 24, 2023
e134a77
abstracted common view functionality
Hzaakk Jul 27, 2023
c119cce
added department field in secure dir form
Hzaakk Jul 27, 2023
5d68085
moved mou gen functionality to a separate package and added base for …
Hzaakk Aug 21, 2023
70fe64b
refactoring, moving things around
Hzaakk Sep 5, 2023
1676f18
ported functionality to secure directories
Hzaakk Sep 6, 2023
23e5ea0
ported functionality to addition requests
Hzaakk Sep 7, 2023
58e1c8f
resolved merge conflict
Hzaakk Sep 7, 2023
2b2608d
remade migration files, implemented emails for new projects
Hzaakk Sep 18, 2023
5f97ead
finished emails for other mou types. incomplete testing
Hzaakk Sep 25, 2023
e904217
completed testing
Hzaakk Oct 2, 2023
ac596bb
added comments and removed unused imports in settings_template.tmpl
Hzaakk Oct 2, 2023
f6b0c6e
switched to private repo for mou generation
Hzaakk Oct 3, 2023
14fa5b0
trying to fix broken tests
Hzaakk Oct 3, 2023
7ac0608
added option to disable mou generation
Hzaakk Oct 3, 2023
fced439
separated mou-generator installation in dockerfile
Hzaakk Oct 3, 2023
72aa01e
re-added key variable to test settings
Hzaakk Oct 3, 2023
355fdc1
fixed prev commit
Hzaakk Oct 3, 2023
09f2ab1
attempt to fix bug in testing w/ django_flags
Hzaakk Oct 9, 2023
718f63d
account for empty google storage key file
Hzaakk Oct 9, 2023
d4ddc03
attempt 2
Hzaakk Oct 9, 2023
70052d9
added github actions secret
Hzaakk Oct 9, 2023
85dca8a
removed local_storage options
Hzaakk Oct 9, 2023
79f7483
added missing comma
Hzaakk Oct 12, 2023
4980ad1
fixed missing '-'
Hzaakk Oct 12, 2023
14b21c2
fixed indentation of 'when'
Hzaakk Oct 12, 2023
274a5fd
added google drive permssions to test settings
Hzaakk Oct 12, 2023
92f605d
fixed playbook, added mou filename to downloads.
Hzaakk Oct 23, 2023
fef28fc
refactoring and addressing comments on PR
Hzaakk Oct 30, 2023
1514328
refactor wkhtmltopdf install and mou filenames
Hzaakk Nov 6, 2023
79f3a95
added deploy key path and readme
Hzaakk Nov 6, 2023
51d241b
addressed more comments, refactorign
Hzaakk Nov 6, 2023
e6b7c35
fixed testing
Hzaakk Nov 6, 2023
d6b6682
further fixed testing
Hzaakk Nov 6, 2023
7c7432c
removed old non-working ids
Hzaakk Nov 6, 2023
04ce8e8
changed gitignore
Hzaakk Nov 6, 2023
618b039
another attempt at fixing testing
Hzaakk Nov 13, 2023
a7bf503
fixed deploy_key variable name
Hzaakk Nov 15, 2023
af6fb6f
moved deploy key to separate section
Hzaakk Nov 15, 2023
f31ffc9
removed quotes around path
Hzaakk Nov 15, 2023
a14b27f
downgrade django-simple-history
Hzaakk Nov 15, 2023
9df86b1
moved comments in main.copyme
Hzaakk Nov 15, 2023
fe3c30d
changed absolute paths to relative
Hzaakk Nov 15, 2023
b1d8959
hyphen to underscore
Hzaakk Nov 15, 2023
9aa2f64
only pi or requester can download/upload mou
Hzaakk Nov 15, 2023
917197f
fixed mixin ordering, mou -> rua
Hzaakk Nov 16, 2023
b40f520
Added deploy key step to README, user permission testing to mou_views.py
Hzaakk Nov 20, 2023
c0fc5a1
fixed testing, added google drive key readme section
Hzaakk Nov 20, 2023
6bbab45
Roughly implement dynamic storage backend selection: no migration nee…
matthew-li Dec 8, 2023
38476ef
Generalize dynamic storage to the other two requests; give feedback w…
matthew-li Dec 13, 2023
c175bbd
Support file_system backend in settings + Ansible; only install gdsto…
matthew-li Dec 15, 2023
d67a132
Merge pull request #572 from ucb-rit/issue_399_gen_dynamic_storage_ba…
Hzaakk Dec 18, 2023
aa99321
refactoring, added notify view mixin
Hzaakk Jan 8, 2024
13830a1
fixed bugs
Hzaakk Jan 8, 2024
4f7a742
fixed merge conflicts
Hzaakk Jan 8, 2024
eba0c17
fixed github actions testing
Hzaakk Jan 8, 2024
60ffa2d
added creation of mou dirs to testing
Hzaakk Jan 8, 2024
2d84645
added sudo to commands
Hzaakk Jan 8, 2024
3986614
make testing /media directory writable
Hzaakk Jan 8, 2024
eddd740
giving permissions to /media folder
Hzaakk Jan 8, 2024
e5d673a
multiple chmod to recursive chmod
Hzaakk Jan 8, 2024
b904741
create media root in dockerfile
Hzaakk Jan 8, 2024
7a17f46
Ensure that Ansible variable is defined before referencing it in Jinj…
matthew-li Jan 16, 2024
f02e058
Restore original name/contents of existing migration
matthew-li Jan 16, 2024
32cd224
Correct syntax error in template
matthew-li Jan 16, 2024
1bf902d
fixed some bugs
Hzaakk Jan 23, 2024
0a026ce
renamed file upload form
Hzaakk Jan 23, 2024
84d4d47
fixed bug with renaming mou_file to file
Hzaakk Jan 23, 2024
78d2516
converted all mou references to rua in secure_dir
Hzaakk Feb 5, 2024
5cec1fe
added request_card_mou_buttons.html
Hzaakk Feb 5, 2024
3c30318
updated request_card_mou_buttons.html
Hzaakk Feb 5, 2024
8d9e62b
MOU -> RUA in the right places
Hzaakk Feb 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/django_testing_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
- name: Checkout the current commit
uses: actions/checkout@v3

- name: Set up Python 3.6.8
- name: Set up Python 3.8.13
uses: actions/setup-python@v3
with:
python-version: 3.6.8
python-version: 3.8.13

- name: Cache and/or Install apache2-dev needed for testing suite
uses: awalsh128/cache-apt-pkgs-action@latest
Expand All @@ -57,7 +57,7 @@ jobs:
- if: ${{ steps.cache-python.outputs.cache-hit != 'true' }} # If a cache is not found
name: Install Python packages
run: |
python3.6 -m venv ~/venv
python3.8 -m venv ~/venv
source ~/venv/bin/activate
pip install -r requirements.txt

Expand Down Expand Up @@ -87,4 +87,6 @@ jobs:
export django_secret_key=`openssl rand -base64 64`
python manage.py migrate
python manage.py test
env:
GOOGLE_DRIVE_STORAGE_JSON_KEY_FILE_CONTENTS: ${{ secrets.GOOGLE_DRIVE_STORAGE_JSON_KEY_FILE_CONTENTS }}

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ main.yml
.vagrant
.coverage
htmlcov
id_coldfront
fetch_database_backup.sh
google-drive-key.json
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ FROM centos/python-38-centos7
LABEL description="coldfront"

USER root

# TODO: comment out these lines if flag_mou_generation_enabled=False
Hzaakk marked this conversation as resolved.
Show resolved Hide resolved
RUN mkdir /root/.ssh && ssh-keyscan github.com > /root/.ssh/known_hosts
COPY --chmod=0600 bootstrap/development/id_coldfront /root/.ssh/id_rsa
RUN pip install git+ssh://git@github.com/ucb-rit/mou-generator.git

WORKDIR /root
COPY requirements.txt ./
RUN pip install -r requirements.txt && rm requirements.txt
RUN pip install jinja2 pyyaml
RUN yum -y install https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos7.x86_64.rpm
Hzaakk marked this conversation as resolved.
Show resolved Hide resolved

# mybrc or mylrc
ARG PORTAL="mybrc"
Expand Down
42 changes: 42 additions & 0 deletions bootstrap/ansible/main.copyme
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ flag_lrc_enabled: False
# TODO: For LRC, set the month number to 9 (September).
flag_next_period_renewal_requestable_month: 5
flag_multiple_email_addresses_allowed: False
# Whether to install and enable the MOU generation package.
# TODO: For Production and Staging, enable.
flag_mou_generation_enabled: false

# Portal settings.
# TODO: For LRC, use "MyLRC", "Laboratory Research Computing", "LRC", and
Expand Down Expand Up @@ -159,6 +162,19 @@ sentry_dsn: ""
# app_port: 8000
# full_host_path: http://scgup-dev.lbl.gov:8000

# # Storage settings.
# # TODO: fill these out
# # Note: local_storage currently not implemented
# file_storage_backend: 'google_drive'
Hzaakk marked this conversation as resolved.
Show resolved Hide resolved
# # TODO: Change to absolute path
# google_drive_private_key_file_path: 'google-drive-key.json'
# # for google_drive, provide only the bottom-level directory name
# # with a slash at the end. If someone shares a new folder with the same name
# # to the same service account, new MOUs may go there.
# new_project_request_mou_path: 'New Project Request MOUs/'
# secure_directory_request_mou_path: 'Secure Directory Request MOUs/'
# service_units_purchase_request_mou_path: 'Service Units Purchase Request MOUs/'

# # SSL settings.
# ssl_enabled: false
# ssl_certificate_file: /etc/ssl/ssl_certificate.file
Expand Down Expand Up @@ -215,6 +231,19 @@ sentry_dsn: ""
# # TODO: For LRC, use https://mylrc.lbl.gov.
# full_host_path: https://mybrc.brc.berkeley.edu

# # Storage settings.
# # TODO: fill these out
# # Note: local_storage currently not implemented
# file_storage_backend: 'google_drive'
# # TODO: Change to absolute path
# google_drive_private_key_file_path: 'google-drive-key.json'
# # for google_drive, provide only the bottom-level directory name
# # with a slash at the end. If someone shares a new folder with the same name
# # to the same service account, new MOUs may go there.
# new_project_request_mou_path: 'New Project Request MOUs/'
# secure_directory_request_mou_path: 'Secure Directory Request MOUs/'
# service_units_purchase_request_mou_path: 'Service Units Purchase Request MOUs/'

# # SSL settings.
# ssl_enabled: true
# ssl_certificate_file: /etc/ssl/ssl_certificate.file
Expand Down Expand Up @@ -271,6 +300,19 @@ sentry_dsn: ""
# app_port: 80
# full_host_path: http://localhost:8880

# # Storage settings.
# # TODO: fill these out
# # Note: local_storage currently not implemented
# file_storage_backend: 'google_drive'
# # TODO: Change to absolute path
# google_drive_private_key_file_path: 'google-drive-key.json'
# # for google_drive, provide only the bottom-level directory name
# # with a slash at the end. If someone shares a new folder with the same name
# # to the same service account, new MOUs may go there.
# new_project_request_mou_path: 'New Project Request MOUs/'
# secure_directory_request_mou_path: 'Secure Directory Request MOUs/'
# service_units_purchase_request_mou_path: 'Service Units Purchase Request MOUs/'

# # SSL settings.
# ssl_enabled: false
# ssl_certificate_file: /etc/ssl/ssl_certificate.file
Expand Down
36 changes: 34 additions & 2 deletions bootstrap/ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
- git-core
- gcc-c++
- libffi-devel
- https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos7.x86_64.rpm
state: present

- name: Install SCL
include_role:
role: smbambling.scl
Expand Down Expand Up @@ -463,13 +464,14 @@

- name: Add dev QOL lines to .bashrc
blockinfile:
path: /home/{{ djangooperator }}/.bashrc
path: {{ ansible_env.HOME }}/.bashrc
block: |
# Upon login, navigate to the ColdFront directory and source the virtual environment.
cd {{ git_prefix }}/{{ reponame }}
source ../venv/bin/activate
# Restart Apache with a keyword.
alias reload="sudo service httpd reload"
become_user: "{{ djangooperator }}"

when: provisioning_tasks == true and deployment == "dev"
tags: provisioning
Expand Down Expand Up @@ -536,6 +538,36 @@
state: reloaded
enabled: true

- block:
# Allow pip installation of private git repo for mou generation.

- name: Check if github in known_hosts
shell: ssh-keygen -F github.com
register: github_known_hosts
changed_when: false
failed_when: false

- name: Add github.com to known_hosts
shell: ssh-keyscan github.com >> {{ ansible_env.HOME }}/.ssh/known_hosts
changed_when: github_known_hosts.rc != 0
become_user: "{{ djangooperator }}"

- name: Copy deploy key to root user's .ssh directory
copy:
src: "{{ git_prefix }}/{{ reponame }}/bootstrap/development/id_coldfront"
Hzaakk marked this conversation as resolved.
Show resolved Hide resolved
dest: {{ ansible_env.HOME }}/.ssh/id_rsa
owner: "{{ djangooperator }}"
group: "{{ djangooperator }}"
mode: 0600
become_user: "{{ djangooperator }}"

- name: Install mou generation package
pip:
name: git+ssh://git@github.com/ucb-rit/mou-generator.git
executable: "{{ git_prefix }}/venv/bin/pip3"
become_user: "{{ djangooperator }}"
when: flag_mou_generation_enabled

# Install Django application dependencies

- name: Install Django application dependencies
Expand Down
28 changes: 28 additions & 0 deletions bootstrap/ansible/settings_template.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,33 @@ REQUEST_APPROVAL_CC_LIST = {{ request_approval_cc_list }}
ALLOW_ALL_JOBS = True
{% endif %}

#------------------------------------------------------------------------------
# File Storage Settings
#------------------------------------------------------------------------------

# gdstorage (Django Google Drive Storage library) settings.
# Path to google drive api key json file
GOOGLE_DRIVE_STORAGE_JSON_KEY_FILE = '{{ google_drive_private_key_file_path }}'
Hzaakk marked this conversation as resolved.
Show resolved Hide resolved
# Path to prepend to gdstorage file paths. Should be '/'
Hzaakk marked this conversation as resolved.
Show resolved Hide resolved
GOOGLE_DRIVE_STORAGE_MEDIA_ROOT = '/'
# Can be used to set permissions e.g "restrict to Berkeley users".
GOOGLE_DRIVE_PERMISSIONS = ()

FILE_STORAGE = {
'backend': '{{ file_storage_backend }}',
'details': {
'NEW_PROJECT_REQUEST_MOU': {
'location': '{{ new_project_request_mou_path }}'
},
'SECURE_DIRECTORY_REQUEST_MOU': {
'location': '{{ secure_directory_request_mou_path }}'
},
'SERVICE_UNITS_PURCHASE_REQUEST_MOU': {
'location': '{{ service_units_purchase_request_mou_path }}'
}
},
}

#------------------------------------------------------------------------------
# Billing settings
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -194,6 +221,7 @@ FLAGS = {
'SECURE_DIRS_REQUESTABLE': [{'condition': 'boolean', 'value': {{ flag_brc_enabled }}}],
'SERVICE_UNITS_PURCHASABLE': [{'condition': 'boolean', 'value': {{ flag_brc_enabled }}}],
'SSO_ENABLED': [{'condition': 'boolean', 'value': {{ flag_sso_enabled }}}],
'MOU_GENERATION_ENABLED': [{'condition': 'boolean', 'value': {{ flag_mou_generation_enabled }}}],
}

# Enforce that boolean flags are consistent with each other.
Expand Down
5 changes: 5 additions & 0 deletions coldfront/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
'coldfront.core.socialaccount',
]

# Google Cloud Integration
INSTALLED_APPS += [
'gdstorage'
]

# ------------------------------------------------------------------------------
# Django Middleware
# ------------------------------------------------------------------------------
Expand Down
22 changes: 22 additions & 0 deletions coldfront/config/test_settings.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,27 @@ API_LOG_PATH = '/var/log/user_portals/cf_mybrc/cf_mybrc_api.log'
# A list of admin email addresses to CC when certain requests are approved.
REQUEST_APPROVAL_CC_LIST = ['test@test.test']

#------------------------------------------------------------------------------
# File Storage Settings
#------------------------------------------------------------------------------

GOOGLE_DRIVE_PERMISSIONS = ()

FILE_STORAGE = {
'backend': 'local_storage',
'details': {
'NEW_PROJECT_REQUEST_MOU': {
'location': 'New Project Request MOUs/'
},
'SECURE_DIRECTORY_REQUEST_MOU': {
'location': 'Secure Directory Request MOUs/'
},
'SERVICE_UNITS_PURCHASE_REQUEST_MOU': {
'location': 'Service Units Purchase Request MOUs/'
}
},
}

#------------------------------------------------------------------------------
# SSL settings
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -96,4 +117,5 @@ FLAGS = {
'SECURE_DIRS_REQUESTABLE': [{'condition': 'boolean', 'value': True}],
'SERVICE_UNITS_PURCHASABLE': [{'condition': 'boolean', 'value': True}],
'SSO_ENABLED': [{'condition': 'boolean', 'value': False}],
'MOU_GENERATION_ENABLED': [{'condition': 'boolean', 'value': False}],
}
16 changes: 16 additions & 0 deletions coldfront/core/allocation/forms_/secure_dir_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ class SecureDirManageUsersRequestCompletionForm(forms.Form):


class SecureDirDataDescriptionForm(forms.Form):
department = forms.CharField(
label=('Specify the full name of the department that this directory '
'will belong to (e.g "Dept. of Chemistry", "Dept. of Economics").'),
validators=[MinLengthValidator(5)],
required=True,
widget=forms.Textarea(attrs={'rows': 3}))

data_description = forms.CharField(
label='Please explain the kind of P2/P3 data you are planning to '
'work with on Savio. Please include: (1) Dataset description '
Expand Down Expand Up @@ -200,3 +207,12 @@ class SecureDirRDMConsultationReviewForm(forms.Form):
validators=[MinLengthValidator(10)],
required=False,
widget=forms.Textarea(attrs={'rows': 3}))

class SecureDirRequestEditDepartmentForm(forms.Form):

department = forms.CharField(
label=('Specify the full name of the department that this directory '
'will belong to (e.g "Dept. of Chemistry", "Dept. of Economics").'),
validators=[MinLengthValidator(5)],
required=True,
widget=forms.Textarea(attrs={'rows': 3}))
Loading
Loading