Commit Graph

546 Commits (159f4c56a51344341a0d108629bef751595a095e)
 

Author SHA1 Message Date
Javier Sánchez Parra 543b12aca8 Change login redirection to "Home"
When the user logs into ogcp, the web page redirects him to "Scopes".

In the future ogcp will have a dashboard showing multiple stats and
details. This dashboard will be in "Home" path and we want the user to
see it when he logs in.

Change login redirection from "Scopes" to "Home".
2021-05-20 18:44:07 +02:00
Jose M. Guisado 2ad382b5ed Add cosmetic improvements
* Adds label for each action page.
* Adds a colored state for opengnsys connected clients
* Fix nav active item
* Rename some actions
* Adds DISK to partition and format form
2021-03-24 14:32:16 +01:00
Jose M. Guisado 9ee0565ac4 Add login
Ogcp requires a simple login page in order to avoid exposure of the
ogServer API to anyone trying to access the web page.

Because the main authorization mechanism in ogServer is the api token
the login implemented for the ogcp does not include registration process
but a single user and password specified in the ogcp.json.

 	"USER": "user",
 	"PASS": "pass"

Adds two new views: /login and /logout. They are used to login the user so
that the rest of views regarding ogServer functionality can be accessed
in a "login required" fashion. Index view (/) is an exception, it can be
accessed logged in or not so different data can be displayed.

Templates can now access a variable "current_user" to get information
about login status. This is a Flask-Login feature.

- Templates regarding login can be found in templates/auth/
- Login form is defined in forms/auth.py to separate it from
  action_forms.py
- Adds Flask-Login module to requirements.txt
- Adds default user and pass in ogcp.json
2021-03-05 11:47:27 +01:00
Jose M. Guisado 149dfdcbfd Make partition forms inline in setup/
quick_form macro from Flask-Bootstrap creates vertical forms by
default, this rendered each partition spanning too much vertical space.

Use form_type='inline' from quick_form macro to compact the whole setup
form.
2021-03-05 11:43:05 +01:00
Jose M. Guisado 45af740c1f Cosmetic enhacements
* Use validate_ips and flashed messages for some more actions.
* Use extra_classes in quick_form macro to add bootstrap classes to
  rendered forms
2021-03-05 11:43:05 +01:00
Jose M. Guisado 2b76106475 Add multiple ip handling to image restore form
This patch enables a set of ips to be specified as a target of an image
restore action.

The set of selected computers must have the same partition setup in
order for the form to be rendered sucessfully, if different partition
setups are detected a redirection is made and an error flash message
is shown.
2021-02-22 14:25:29 +01:00
Jose M. Guisado 20f88065bb Add boot mode to actions
This action is related to /mode in ogServer API.  Allows changing
the netboot template for a set of given clients, previously selected
in the /scopes view.
2021-02-17 13:40:06 +00:00
Jose M. Guisado e68eb7a3da Add example image creation WTForms validator
Adds in a declarative way the validation of the image name form control
when creating a partition image.

This commit serves as an example of adding a predefined validator of the
WTForms module. Custom validator may be added by creating a given
function and appending it to the list of validators.

See https://wtforms.readthedocs.io/en/2.3.x/validators/#custom-validators
2021-02-16 13:30:28 +00:00
Jose M. Guisado 622f0bacbc Add ips field validation and better redirections
Add a function to validate that the ips received from the /scopes form
is valid (no more, no less).

Also redirects to the /scopes when any final request to the ogServer is
responded by a "200 OK"
2021-02-16 13:27:40 +00:00
Jose M. Guisado 2ec14a0061 Add FAT32 to FS_CODES dict
An error was produced when rendering the setup form of a computer
with any FAT32 partition. It was missing from the mapping of codes
received in a response to a given filesystem.
2021-02-16 13:25:10 +00:00
Jose M. Guisado 55d923431d Add some minor cosmetic changes
This commit may serve for future reference as to how some cosmetic
changes have been applied to the web.

Primarily using bootstrap classes in order to adjust margin or padding,
there are mechanisms that allow modifying the class of an
underlying html element in WTForms. Bootstrap classes are written
directly in html templates for Flask.

Also add a Soleta branded footer.
2021-02-16 13:21:24 +00:00
Jose M. Guisado 199854f1e9 Start using Flask flash messages
These are used to store a message string that can be later accessed. We
can use Flask flash messages to alert about any error or providing info
when processing a request.
2021-02-16 13:18:38 +00:00
Jose M. Guisado 989dc5bd36 Add image create template
Image creation action was lacking a template to render the form. This
patch adds said template.

Also redirects to /scopes when the request was processed by the ogserver
successfully.
2021-02-10 11:58:46 +00:00
Jose M. Guisado 3eda3fa684 Add UNICAST-DIRECT method to image restore
Previously the only method (in the form select) was "UNICAST". This
patch enables specifying a correct parameter for the underlying script
to fetch the image to be restored.

UNICAST-DIRECT makes the administrator transfer the image through the
network. UNICAST-CACHE indicates the taget pc to search for the image in
its cache partition.

Also redirects to the /scopes when ogserver responds with 200 OK.
2021-02-10 11:46:06 +00:00
Jose M. Guisado 95b28c9403 Add setup modif part scheme param and autofill partition_setup
A new parameter for the setup/ was added: type. Regarding the disk
partition scheme. It must be either "MSDOS" or "GPT".

ogServer expects a 4 partition setup in order to succesfully execute a
setup/ command. Ogcp is currently getting the partition to modify
one partition at a time. This patch enables ogcp to "autofill" with
empty partitions the partition_setup payload parameter.

TODO: In the future, the setup/ logic should not need to query the
database once again in order to create the 'partition_setup' payload
parameter with the form modifications.
2021-02-10 10:48:01 +00:00
Jose M. Guisado b8ac0b7963 config: rename config file to ogcp.json
Do not use the same name as ogserver config file.
2020-11-06 09:32:27 +00:00
Jose M. Guisado b708047d28 config: use from_json to read ogserver config
This patch introduces the usage of Flask.Config class so the config can
be read at startup (__init__) only once. Config keys must be uppercase
so that from_json method does take it into account.

 dormousehole.readthedocs.io/en/stable/api.html#flask.Config.from_json

Prior to this patch each request required opening and closing the
ogserver.json file via load_config in views.py.

In the future the decorated load_config function inside views.py
may be removed to avoid creating multiple instances of the OGServer
class.
2020-11-06 09:27:03 +00:00
Jose M. Guisado c08aca9219 Add software action
This action lists every piece of software installed in an OS from a
client.

This action can handle listing the software from the DB as well as
updating that DB with the latest client information.
2020-10-29 15:03:35 +01:00
Roberto Hueso Gómez a8d7494ab9 Add image create action
This action handles the creation of the image in the DB as well as the
'.img' file.
2020-10-29 14:43:23 +01:00
Roberto Hueso Gómez 282984d0ac Add templates for clients, hardware, restore, session and setup
These templates were not added in previous commits.
2020-10-27 11:15:19 +01:00
Roberto Hueso Gómez 8fa8ca3f42 Add run_test.sh script
This script is used to run a Flask testing environment.
2020-10-27 10:38:56 +01:00
Roberto Hueso Gómez 904989b175 Add image restore action
This action provides the image restoring functionality on a specific
client.
2020-10-23 15:10:29 +02:00
Roberto Hueso Gómez c5a4ccff55 Add session action
This action provides the functionality to run one of the installed OSs
in a client.
2020-10-22 11:04:57 +02:00
Roberto Hueso Gómez e978c30b9f Add client hardware action
This action lists all the hardware items in a client.
2020-10-21 14:38:44 +02:00
Roberto Hueso Gómez 93ffa115fe Add create client action
This action provides the functionality to add a new client to an
ogServer.
2020-09-28 15:04:00 +02:00
Roberto Hueso Gómez 664d032884 Add client details action
This action is used to visualize the specific details of a client, such
as its IP, Name, MAC, etc.
2020-09-28 15:02:16 +02:00
Roberto Hueso Gómez ea5b22c35e Add delete partition view
This view deletes and formats a partition from the selected machine.
2020-09-15 13:42:28 +02:00
Roberto Hueso Gómez 1ce9c8a95b Fix setup partitions filesystem codes to string
Partition filesystem are encoded with integers in the DB. We need to
send the type string instead of the encoded integer, so this patch
parses the encoded integer to string.
2020-09-15 13:39:05 +02:00
Roberto Hueso Gómez 7815d1fac7 Add partitions setup forms
This provides a menu to setup the internal partitions setup of each
machine. Delete partitions is still just a placeholder.
2020-09-14 10:56:58 +02:00
Roberto Hueso Gómez 9df3c538f3 Fix parse_ips(...) function to avoid parsing CSFR
This avoids trying to parse CSFT token as an IP.
2020-09-14 10:54:46 +02:00
Roberto Hueso Gómez 19be0f87de Fix internal server error code 2020-09-14 10:54:01 +02:00
Roberto Hueso Gómez b7e980f946 Add 500 default error handler
This handles HTTP 500 internal server errors.
2020-09-04 13:21:36 +02:00
Roberto Hueso Gómez 31d2808a43 Add 404 default error handler.
This handles HTTP 404 page does not exist errors.
2020-09-04 13:20:11 +02:00
Roberto Hueso Gómez bb7e201991 Add refresh action
This action can be applied on single or multiple scopes.
2020-09-04 13:18:26 +02:00
Roberto Hueso Gómez d5eaf699a7 Add WoL action
This action can be applied on one or multiple scopes. This
implementation use Flask-WTF as a way to build and valdiate forms. As a
side effect, this adds CSRF protection to all forms.
2020-09-04 11:09:44 +02:00
Roberto Hueso Gómez 73a6e07b83 Add reboot action
This action handles reboot on one or multiple scopes.
2020-09-03 11:50:58 +02:00
Roberto Hueso Gómez ef609cf52a Rename add_state_to_scopes() function
This function is renamed to add_state_and_ips() which is more accurate.
2020-09-02 14:50:52 +02:00
Roberto Hueso Gómez c12ff832c7 Add action_poweroff() view function
This function handles a poweroff request to one or multiple scopes.
2020-09-02 14:46:20 +02:00
Roberto Hueso Gómez 30c5173aea Implement scopes() view function
This function provides the data needed to render the scopes.html
template.
2020-09-02 14:45:02 +02:00
Roberto Hueso Gómez 46b88fff0b Add requests functionality to the OGServer class
These functions will be used to make HTTP GET and POST requests to the
OGServer.
2020-09-02 14:42:10 +02:00
Roberto Hueso Gómez a4957f2284 Add scopes.html template
This template shows information about scopes and its states as well as a
tool to apply actions on them. Style improvements are still necessary.
2020-09-02 14:37:56 +02:00
Roberto Hueso Gómez 3fe6ad6ac6 Add bootstrap bundle
This is used for multiple bootstrap components such as dropdown menus.
2020-09-02 14:35:30 +02:00
Roberto Hueso Gómez 01efd71022 Add frontend basic structure
This adds base.html and nav.html templates as well as its dependencies
on Bootstrap and jQuery.
2020-08-31 11:58:38 +02:00
Roberto Hueso Gómez df2e425b34 Add basic backend structure
This adds views functions and ogServer config loading.
2020-08-31 11:58:27 +02:00
Roberto Hueso Gómez 0e160da4c0 Add requirements.txt
These are the basic libraries this app needs in order to run:
- Flask
- requests
- Flask-Babel

the rest of libraries are dependencies of theirs.
2020-08-31 11:51:07 +02:00
Roberto Hueso Gómez 8429541558 Add gitignore 2020-08-28 10:18:43 +02:00