Commit Graph

949 Commits

Author SHA1 Message Date
Paul Eggleton
b5ba406a07 dockersetup.py: add connectivity check
It's easy to get the proxy settings wrong and not realise until you've
got quite a long way into the process of setting things up. Thus, add a
check where we actually try to fetch various things within the container
environment and fail reasonably early if things aren't working.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-10-02 14:13:47 +13:00
Paul Eggleton
a0763f6da8 API: fix recipes view to really point to recipes ViewSet
I forgot the lesson of f5922091b4 which
was that djangorestframework has a very silly default of registering
the model name as the key for finding the ViewSet, with the result that
the recently created RecipesExtendedViewSet was also being used for the
recipes URL which we expect to point to RecipeViewSet; this broke the
bitbake-layers layerindex-* commands.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-09-18 09:25:56 +12:00
Paul Eggleton
b78e498c20 import_layers: fix updating build dependencies
Apparently I forgot that filter() returns a QuerySet and not an actual
object.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-09-17 15:35:44 +12:00
Paul Eggleton
b46de0bfa7 import_layers: fix output when importing layers from scratch
Fixes "Importing None" message since we had not yet initialised the
layerbranch variable.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-09-16 17:15:58 +12:00
Paul Eggleton
cb4bd5e45b import_layers: use recipesExtended viewset
The new viewset has a different URL and uses pagination, so we need to
take that into account.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-09-16 17:15:18 +12:00
Paul Eggleton
ee1ff214a0 API: fix recipes API performance regression
Adding these extra child items to the standard "recipes" viewset (which
we did recently in 684a06a383) means that
some current usage is impractical due to the size of the returned list
of items. Instead, create a recipesExtended viewset, move the new child
items to that and add pagination to avoid result size issues.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-09-16 17:14:25 +12:00
Paul Eggleton
73198bd548 README: add reference to using import_layers to update
This is now be practical to use for updating as well as the initial
import. Additionally the user doesn't need to be using the debug
option by default so drop it from the example command.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 12:04:17 +12:00
Paul Eggleton
7953e7a853 import_layers: show basic progress
Show an info message with a counter when importing layers.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 11:57:05 +12:00
Paul Eggleton
54e51c26ac import_layers: add reload option
Make it possible to reload the data even if the updated field says it's
up-to-date.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 11:38:50 +12:00
Paul Eggleton
40aada94e0 import_layers: delete non-matching LayerBranch objects
If a LayerBranch is on a branch that is in the remote layer index (and
that branch is in any branch list specified with -b/--branch) and the
layer for the LayerBranch is not found in the remote layerindex then it
should be deleted, otherwise we could end up with stale data.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 11:38:50 +12:00
Paul Eggleton
0d62b19a38 import_layers: allow filtering layers
Add an option to import only certain layers - mostly for debugging
(can make testing a lot quicker).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 11:38:33 +12:00
Paul Eggleton
8501a6da40 import_layers: allow filtering branches
We only work with branches that exist in both the local database and the
remote index, but allow the user to restrict the list further if
desired.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 11:38:06 +12:00
Paul Eggleton
577e62e62f import_layers: switch to argparse
No functionality changes, just a code upgrade.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 11:38:01 +12:00
Paul Eggleton
712ed71c63 Add simple script for testing web API
This is not a comprehensive test, but does provide a way to easily
compare that what was originally fetched for a recipe from the API is
the same once it's been imported into a new instance using
import_layers.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 11:35:00 +12:00
Paul Eggleton
4fe3eea540 admin: add layerbranch to BBAppend string representation
This makes it a little bit easier to see which BBAppend objects belong
to which layer.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 11:35:00 +12:00
Paul Eggleton
71ff6571c6 import_layers: import other missing items
Import Machine, Distro, BBClass, BBAppend, IncFile objects.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 09:55:34 +12:00
Paul Eggleton
150b774cce import_layers: import recipes
Import recipe data from the REST API, including sub-recipe objects
(sources, patches, PACKAGE_CONFIGs, dependencies etc.) now that they are
available from the API. Also, with the data being more or less complete,
it's also reasonable to also set the vcs_* fields so that we can tell
how up-to-date it is.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-06 09:54:43 +12:00
Paul Eggleton
5352a227ab import_layers: enable incremental LayerItem/LayerBranch import
Don't assume we need to create these objects - check the updated field
value against what the API reports and update the existing object if the
latter is newer.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-05 16:18:00 +12:00
Paul Eggleton
8861ccfa19 import_layers: avoid importing duplicate objects
For LayerDependency, LayerMaintainer and LayerNote objects, properly
sync the objects in the database with the objects fetched from the API.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-05 16:18:00 +12:00
Paul Eggleton
01b1b030a0 API: add BBAppend and IncFile objects to REST API
These are a little less useful than the other items but if we want to be
able to create a clone of a layer index then we need them.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-05 16:17:58 +12:00
Paul Eggleton
684a06a383 API: add sources, patches, dependencies to recipes
We're tracking these items for each recipe, so they should be
accessible via the API as well.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-08-05 16:17:13 +12:00
Paul Eggleton
9ce9f7d2d1 dockersetup: fix regression with https enabled
Fix a regression introduced in bfecbb091b.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-31 09:03:46 +12:00
Paul Eggleton
bc6984b582 dockersetup: fix error when printing URL with https enabled
Copy-paste error.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-25 16:25:48 +12:00
Paul Eggleton
c427f82bfd import_otherdistro: try-specfile: handle files in current dir
The try-specfile subcommand is for testing, so it's entirely possible
the spec file we are testing with will be in the current directory;
os.path.dirname() returns '' in this case, which os.path.relpath() then
chokes on. Avoid this in the easiest way possible by just prepending ./
to the path in this case.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-25 16:25:44 +12:00
Paul Eggleton
4902baa1d7 import_otherdistro: handle non-UTF8 encoded spec files
It's not common, but if someone saves a spec file with a non-UTF8
encoding then the surrogate characters were preventing the data from
being saved to the database (at least with MariaDB). Instead of assuming
UTF8, try a few common encodings on the first 100 lines.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-25 16:25:41 +12:00
Paul Eggleton
fe4acbbb9b Optionally allow accounts without security questions to reset password
Add a SECURITY_QUESTIONS_REQUIRED setting that defaults to True, but if
set to False then a user who has not set security questions will still
be allowed to reset their password. This is convenient for the OE Layer
index because there are a number of existing accounts, none of which
will have security questions set.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-25 16:25:06 +12:00
Paul Eggleton
40c728181a Set string representation for UserProfile & SecurityQuestionAnswer models
Makes the admin pages a bit more useful for debugging.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-25 16:25:06 +12:00
Paul Eggleton
02a5113bdd Fix admin logout login button redirection
If you clicked on logout in the admin site then clicked on the "Login"
button and logged in, you were redirected to the logout page because we
weren't detecting that the redirection should not be applied.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-25 16:25:06 +12:00
Paul Eggleton
483811dc40 auth_views: minor indentation fix
No code changes.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-25 16:24:59 +12:00
Paul Eggleton
8a4dd12ae3 requirements.txt: update pillow
This is the only dependency we can update right now; the rest will cause
problems given that the layer index needs python 2 support still.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
9cc87919ef Fix a couple of Edit Profile form message bugs
* Tweak message when one or more (but not all) security question answers
  have been changed so that it's clear that all are required
* Ensure success message gets shown upon saving

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
436596159f Tweak password reset security question handling
* Require all three answers to be correct (previously only two had to
  be)
* Give the user three attempts instead of just two

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
2b98f751e6 check_requirements.sh: more tweaks
* Use venv module instead of deprecated virtualenv command
* Upgrade pip at the start so we don't get warnings about it

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
02e116b698 docker: disable client MIME type sniffing
We should be being explicit about the MIME type rather than allowing the
browser to guess.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
36427bdf9d .gitignore: add a few more files
Try to cleanup the typical uncommitted files list. The added files:

* The .json files are generated when running in development mode
* requirements* are generated by check_requirements.sh
* The others relate to dockersetup.sh

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
86682be25d check_requirements: make output file naming a bit more consistent
Prefix all output files with "requirements" so that it's clear what they
are related to.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
31a2e3f043 dockersetup: support encryption/authentication for SMTP
Some SMTP servers are configured to require encrypted connections and
username & password, so provide options to enable those.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
bfecbb091b dockersetup: refactor arguments handling slightly
Just pass back the args object instead of individual arguments to avoid
having to change two places for every trivial argument we add.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
f16ca9da35 dockersetup: show a warning if no email host specified
If no email host has been specified that will prevent certain things
from working, so warn the user if they haven't specified one.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
a8bb9e64bb dockersetup: handle http/https port properly
* Use the port number in the domain so that emails have working URLs
* Don't include the port in the URL printed at the end of installation
  if it's the default

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
d215e2899a Fix axes lockout not working
We use django-axes to lock out IP addresses after a set number of
attempts at logging in, and separately we use django-reversion to
record change history. As part of the history tracking, the default
behaviour of django-reversion is to wrap all POST requests in
"with transaction.atomic()", with the result that if an exception is
raised any changes get rolled back; unfortunately when authentication
fails for the final time, axes updates the database and then raises
PermissionDenied - with the result that the database changes are rolled
back, and the user's IP is not locked out, in fact it can never be
locked out. To work around this, disable the atomic mode on
ReversionMiddleware using a subclass. (I don't like having to do this,
but this is the quickest solution for now.)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
58e501afc9 check_requirements.sh: improve output for cron usage
For running this script in a cron job we want to see just the
interesting output since that will be sent as an email, so make the
following changes:

* Silence the normal output of virtualenv and pip
* Add a -q option for the script to silence progress messages

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
736c1104ae check_requirements: write out output of safety check
Use tee to write the output of safety check just in case we need to
refer to it later.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
190a97fda4 requirements.txt: update
Update to latest versions; as per last update we skip django-reversion
and django-axes. (Now however I've realised that django-axes > 4.5.4
probably isn't found within the container because in my development
setup, pip == pip3 whereas in the container pip is the Python 2 version.
For now let's stick with something that we can still use with the layer
index that still requires Python 2).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
3a4a61aafb README: add pointer to import layer index data
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
778632a445 docker: remove hardcoded container names
This allows for multiple instances of the project to coexist on the same
machine.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
0c617f1064 dockersetup: add option to disable adding admin user
If you supply a database file then you may already have ad admin user
defined and thus adding another one is superfluous. Add an option to
make it easy to disable that step.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
d39929b405 dockersetup: do not set site name if a database file is specified
If a database file is specified we probably want to stick with whatever
site name is defined in there and not overwrite it.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
f527692c7c Replace custom pagination with django-bootstrap-pagination
Simplify things a bit. We lose the digg-style pagination but the new
behaviour is good enough and improves maintainability.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00
Paul Eggleton
513be9d8ef dockersetup: add option to specify docker-compose project name
Allow specifying the project name (either with a --project-name
command-line option or COMPOSE_PROJECT_NAME) and save it so that
future upgrade operations work properly by default.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2019-07-17 11:31:04 +12:00