-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
global: structure initialization and wiki migration
- Loading branch information
Pablo Panero
committed
Jan 8, 2020
0 parents
commit b523197
Showing
23 changed files
with
1,022 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (C) 2019 CERN. | ||
# Copyright (C) 2019 Northwestern University. | ||
# | ||
# Invenio-Cli is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
notifications: | ||
email: false | ||
|
||
sudo: true | ||
|
||
language: python | ||
|
||
python: | ||
- "3.6" | ||
|
||
services: | ||
- docker | ||
|
||
before_script: | ||
- gem install awesome_bot | ||
|
||
script: | ||
- ./run-tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
MIT License | ||
|
||
Copyright (C) 2019 CERN. | ||
Copyright (C) 2019 Northwestern University. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# docs.reana.io | ||
|
||
[](https://travis-ci.org/inveniosoftware/docs-invenio-rdm.svg) [](https://gitter.im/inveniosoftware/InvenioRDM?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](https://github.com/inveniosoftware/docs-invenio-rdm/blob/master/LICENSE) | ||
|
||
## About | ||
|
||
InvenioRDM user documentation web site. | ||
|
||
## Running | ||
|
||
```console | ||
$ mkvirtualenv docs-invenio-rdm | ||
$ pip install -r requirements.txt | ||
$ mkdocs serve | ||
$ firefox http://127.0.0.1:8000 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Kubernetes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# OpenShift |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Build and Setup | ||
|
||
## Deploy your instance | ||
|
||
The CLI supports two deployment modes: local development and containerized *semi*-production. This document will focus on deploying a containerized *semi*-production instance (we will use the `--containers` flag throughout). To deploy for local development, replace that flag by `--local`. | ||
|
||
Before going on, let's move into the project directory: | ||
|
||
``` console | ||
$ cd december-release | ||
``` | ||
|
||
**Known issues**: | ||
|
||
- If you do not move into the correct directory you will get an error like this: | ||
``` | ||
ERROR:root:No flavour specified. | ||
``` | ||
|
||
The error message is not intuitive: it is not because no flavour was specified that there is an error! We will change it. It just means that the folder does not contain the `.invenio` config file because the current directory is wrong: *cd into it :-)*. | ||
|
||
### Build the docker images | ||
|
||
We use the `build` command with the `--containers` flag to build the images specified in the `december-release/docker-compose.full.yml`. | ||
In addition, we need to add ``--pre`` in order to allow `pipenv` to install alpha releases, since many InvenioRDM packages are now in this phase. Be patient, the docker images might take some time to build. | ||
|
||
``` console | ||
(your-virtualenv)$ invenio-cli build --pre --containers | ||
Building RDM application... | ||
Locking dependencies... | ||
Bootstrapping server... | ||
Building base docker image... | ||
Building applications docker image... | ||
Creating services... | ||
``` | ||
|
||
As a result, six images (December-Release, Nginx, Redis, PostgreSQL, RabbitMQ and Elasticsearch) have been built. | ||
|
||
### Setup the DB, ES and others | ||
|
||
We just need to initialize the database, the indices and so on. For this, we can use the `setup` command. Note that this command is only needed once. Afterwards, you can stop (not destroy) your instance and start again, and your data will still be there. | ||
|
||
``` console | ||
(your-virtualenv)$ invenio-cli setup --containers | ||
Setting up environment for RDM application... | ||
Setting up server... | ||
Starting containers... | ||
Creating database... | ||
Creating indexes... | ||
Creating files location... | ||
Creating admin role... | ||
Assigning superuser access to admin role... | ||
Stopping containers... | ||
``` | ||
|
||
In case you want to wipe out the data that was there (say to start fresh), you can use `--force` and nuke the content! | ||
|
||
``` console | ||
(your-virtualenv)$ invenio-cli setup --containers --force | ||
Setting up environment for RDM application... | ||
Setting up server... | ||
Starting containers... | ||
Flushing redis cache... | ||
Deleting database... | ||
Deleting indexes... | ||
Purging queues... | ||
Creating database... | ||
Creating indexes... | ||
Creating files location... | ||
Creating admin role... | ||
Assigning superuser access to admin role... | ||
Stopping containers... | ||
``` | ||
|
||
### Populate DB | ||
|
||
Let's add some content so you can interact a bit with the instance. For this you will generate 10 random demo records, using the `demo` command: | ||
|
||
``` console | ||
(your-virtualenv)$ invenio-cli demo --containers | ||
Setting up server... | ||
Starting containers... | ||
Populating instance with demo records... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Cleanup after you | ||
|
||
## Destroy the instance | ||
|
||
Finally, we want to destroy it. This will take us to a clean state. Note that it destroys images, containers and volumes (the ones defined in the `december-release/docker-compose.full.yml`. ). | ||
|
||
Stop the application: | ||
|
||
``` console | ||
(your-virtualenv)$ invenio-cli destroy --containers | ||
Destroying RDM application... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Configuration | ||
|
||
You can configure your InvenioRDM instance to best suit your needs. The `invenio.cfg` file, overrides the `config.py` variables provided by [Invenio modules](https://invenio.readthedocs.io/en/latest/general/bundles.html) and their dependencies. We will use configuring permissions as an example of how to configure your application. | ||
|
||
For the purpose of this example, we will only allow super users to create records through the REST API. To do so, we define our own permission policy. | ||
|
||
Open the `invenio.cfg` file with your favorite editor. We will use `vim` to avoid `emacs` and other wars ;). | ||
|
||
``` console | ||
$ vim invenio.cfg | ||
``` | ||
|
||
Let's add the following to the file: | ||
|
||
```python | ||
# imports at the top... | ||
from invenio_rdm_records.permissions import RDMRecordPermissionPolicy | ||
from invenio_records_permissions.generators import SuperUser | ||
|
||
# ... | ||
|
||
# At the bottom | ||
# Our custom Permission Policy | ||
class MyRecordPermissionPolicy(RDMRecordPermissionPolicy): | ||
can_create = [SuperUser()] | ||
|
||
RECORDS_PERMISSIONS_RECORD_POLICY = MyRecordPermissionPolicy | ||
``` | ||
|
||
When we set `RECORDS_PERMISSIONS_RECORD_POLICY = MyRecordPermissionPolicy`, we are overriding `RECORDS_PERMISSIONS_RECORD_POLICY` provided by [invenio-records-permissions](https://github.com/inveniosoftware/invenio-app-rdm). You will note that `invenio.cfg` is really just a Python module. How convenient! | ||
|
||
**Pro tip** : You can type `can_create = []` to achieve the same effect; any empty permission list only allows super users. | ||
|
||
That's it configuration-wise. If we try to create a record through the API, your instance will check if you are a super user before allowing you. The same approach to configuration holds for any other setting you would like to override. Now we must stop the current instance, rebuild the application image and re-start it to see our changes take effect. | ||
|
||
You can run the same `build` command. If you are in a hurry, you can skip locking dependencies and building the base image. | ||
|
||
``` console | ||
(your-virtualenv)$ invenio-cli server --containers --stop | ||
(your-virtualenv)$ invenio-cli build --pre --containers [--skip-base --skip-lock] | ||
(your-virtualenv)$ invenio-cli server --containers --start | ||
``` | ||
|
||
Did the changes work? We are going to try to create a new record: | ||
|
||
``` console | ||
$ curl -k -XPOST -H "Content-Type: application/json" https://localhost/api/records/ -d ' | ||
{ | ||
"access": { | ||
"metadata_restricted": "false", | ||
"files_restricted": "false" | ||
}, | ||
"access_right": "open", | ||
"contributors": [{"name": "Jon Doe"}], | ||
"description": "A Holiday Record description", | ||
"owners": [1], | ||
"publication_date": "25/12/2019", | ||
"resource_type": { | ||
"type": "Dataset", | ||
"subtype": "dataset" | ||
}, | ||
"title": "A Holiday Record" | ||
}' | ||
``` | ||
|
||
As you can see, the server could not know if we are authenticated/superuser and rejected us: | ||
|
||
``` console | ||
{"message":"The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.","status":401} | ||
``` | ||
|
||
**Advanced example**: | ||
|
||
1- Create a user, for example using the web UI (*sign up* button). Alternatively, you can do so with the CLI, executing the following command (Wait until you read point number *2* before executing): | ||
|
||
``` console | ||
invenio-cli users create [email protected] --password=123456 | ||
``` | ||
|
||
Note that the user will have ID 1 if it was the first one created. | ||
|
||
2- Grant admin access to it. In order to do so, we only have to add the `-a` flag to the previous command: | ||
|
||
``` console | ||
invenio-cli users create [email protected] -a --password=123456 | ||
``` | ||
|
||
Note that this user will have ID 2. | ||
|
||
3- Get a token and try to create the record again. You can do so on the UI by going to `settings->applications-->new token`. Alternatively you can do it in the terminal by executing the following command: | ||
|
||
``` console | ||
# TODO Wait until invenio-oauthclient REST only is integrated | ||
``` | ||
|
||
Afterwards we can test if the new permissions are working correctly. | ||
|
||
``` console | ||
$ curl -k -XPOST -H "Authorization:Bearer sHHq1K9y7a2v5doKDRSFmSFOxa1tZDHFcbs31npaxm1sFEt27yomLMt0ynkl" -H "Content-Type: application/json" https://localhost/api/records/ -d ' | ||
{ | ||
"access": { | ||
"metadata_restricted": "false", | ||
"files_restricted": "false" | ||
}, | ||
"access_right": "open", | ||
"contributors": [{"name": "Jon Doe"}], | ||
"description": "A Holiday Record description", | ||
"owners": [1], | ||
"publication_date": "25/12/2019", | ||
"resource_type": { | ||
"type": "Dataset", | ||
"subtype": "dataset" | ||
}, | ||
"title": "A Holiday Record" | ||
}' | ||
``` | ||
|
||
It works! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Customization | ||
|
||
As we just saw, overriding configured values is an easy and common way of customizing your instance to your needs. Sometimes, however, you need to provide custom files too: logos, templates... We show how to perform these custom changes. | ||
|
||
We are going to change the logo, take an *svg* file and update your **local** static files (You can use the [invenio color logo](https://github.com/inveniosoftware/invenio-theme/blob/master/invenio_theme/static/images/invenio-color.svg)): | ||
|
||
``` console | ||
$ cp ./path/to/new/color/logo.svg static/images/logo.svg | ||
``` | ||
|
||
Then, use the update command: | ||
|
||
``` console | ||
(your-virtualenv)$ invenio-cli update --containers | ||
Updating static files... | ||
``` | ||
|
||
Go to the browser [*https://localhost/*](https://localhost) or refresh the page. And voila! The logo has been changed! | ||
|
||
**WARNING**: If you do not see it changing, check in an incognito window, the browser might have cached the logo. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Home |
Oops, something went wrong.