Compare commits

...

12 Commits

Author SHA1 Message Date
Markku Leiniö 0cc2963e6f
Closes #16043: Add 'die-on-term = true' to fix stopping uWSGI (#16045)
* Closes #16043: Add 'die-on-term = true' to fix stopping uWSGI

* Fix spelling
2024-05-08 14:51:54 -04:00
Arthur Hanson 56ea7b8714
16014 Update incorrect django-graphene reference and add link to filtering docs. (#16015)
* 16014 change ref from django-graphene to django-strawberry

* 16014 add references to filtering syntax

* 16014 remove graphene reference

* 16014 remove graphene reference

* Remove obsolete reference to Graphene

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-05-08 14:29:54 -04:00
Jeremy Stretch 6e658d43dc #15999: Additional cleanup 2024-05-08 14:06:48 -04:00
Arnold 6ff349dbac Putting field labels above fields 2024-05-08 14:06:04 -04:00
Daniel Sheppard d7d97b1b52 Return an empty dict if the module cannot be loaded 2024-05-08 13:29:39 -04:00
Markku Leiniö d7f652bcc7 Closes #16034: Disable uWSGI logging 2024-05-08 12:02:23 -04:00
Jeremy Stretch 313b6e624c Remove duplicate column definition from ReportResultsTable 2024-05-08 11:59:36 -04:00
Arthur 0df3787796 16031 make script result message display markdown 2024-05-08 11:43:20 -04:00
Jeremy Stretch 5c68fc9202 Fixes #16020: Include Python version on system UI view 2024-05-08 10:35:38 -04:00
Jeremy Stretch ff8dabe8d9 Fixes #16025: Fix execution of scripts via the runscript management command 2024-05-08 10:30:47 -04:00
Markku Leiniö 5c5c0e1e43 Fixes #16032: Specify the WSGI module to load in uwsgi.ini 2024-05-08 10:28:35 -04:00
Jeremy Stretch b87d1eca98 Fixes #16016: Correct typo 2024-05-08 10:15:43 -04:00
10 changed files with 44 additions and 14 deletions

View File

@ -11,8 +11,21 @@ master = true
; clear environment on exit
vacuum = true
; make SIGTERM stop the app (instead of reload)
die-on-term = true
; exit if no app can be loaded
need-app = true
; do not use multiple interpreters
single-interpreter = true
; change to the project directory
chdir = netbox
; specify the WSGI module to load
module = netbox.wsgi
; only log internal messages and errors (reverse proxy already logs the requests)
disable-logging = true
log-5xx = true

View File

@ -77,7 +77,7 @@ Create the following for each model:
## 13. GraphQL API components
Create a Graphene object type for the model in `graphql/types.py` by subclassing the appropriate class from `netbox.graphql.types`.
Create a GraphQL object type for the model in `graphql/types.py` by subclassing the appropriate class from `netbox.graphql.types`.
Also extend the schema class defined in `graphql/schema.py` with the individual object and object list fields per the established convention.

View File

@ -17,7 +17,7 @@ pip3 install pyuwsgi
Once installed, add the package to `local_requirements.txt` to ensure it is re-installed during future rebuilds of the virtual environment:
```no-highlight
sudo sh -c "echo 'pyuwgsi' >> /opt/netbox/local_requirements.txt"
sudo sh -c "echo 'pyuwsgi' >> /opt/netbox/local_requirements.txt"
```
## Configuration

View File

@ -1,6 +1,6 @@
# GraphQL API Overview
NetBox provides a read-only [GraphQL](https://graphql.org/) API to complement its REST API. This API is powered by the [Graphene](https://graphene-python.org/) library and [Graphene-Django](https://docs.graphene-python.org/projects/django/en/latest/).
NetBox provides a read-only [GraphQL](https://graphql.org/) API to complement its REST API. This API is powered by [Strawberry Django](https://strawberry-graphql.github.io/strawberry-django/).
## Queries
@ -47,7 +47,7 @@ NetBox provides both a singular and plural query field for each object type:
For example, query `device(id:123)` to fetch a specific device (identified by its unique ID), and query `device_list` (with an optional set of filters) to fetch all devices.
For more detail on constructing GraphQL queries, see the [Graphene documentation](https://docs.graphene-python.org/en/latest/) as well as the [GraphQL queries documentation](https://graphql.org/learn/queries/).
For more detail on constructing GraphQL queries, see the [GraphQL queries documentation](https://graphql.org/learn/queries/). For filtering and lookup syntax, please refer to the [Strawberry Django documentation](https://strawberry-graphql.github.io/strawberry-django/guide/filters/).
## Filtering

View File

@ -2,7 +2,7 @@
## Defining the Schema Class
A plugin can extend NetBox's GraphQL API by registering its own schema class. By default, NetBox will attempt to import `graphql.schema` from the plugin, if it exists. This path can be overridden by defining `graphql_schema` on the PluginConfig instance as the dotted path to the desired Python class. This class must be a subclass of `graphene.ObjectType`.
A plugin can extend NetBox's GraphQL API by registering its own schema class. By default, NetBox will attempt to import `graphql.schema` from the plugin, if it exists. This path can be overridden by defining `graphql_schema` on the PluginConfig instance as the dotted path to the desired Python class.
### Example

View File

@ -85,6 +85,7 @@ class Command(BaseCommand):
module_name, script_name = script.split('.', 1)
module, script = get_module_and_script(module_name, script_name)
script = script.python_class
# Take user from command line if provided and exists, other
if options['user']:

View File

@ -60,7 +60,10 @@ def get_module_scripts(scriptmodule):
return cls.full_name.split(".", maxsplit=1)[1]
loader = SourceFileLoader(get_python_name(scriptmodule), get_full_path(scriptmodule))
module = loader.load_module()
try:
module = loader.load_module()
except FileNotFoundError:
return {}
scripts = {}
ordered = getattr(module, 'script_order', [])

View File

@ -545,7 +545,7 @@ class ScriptResultsTable(BaseTable):
template_code="""{% load log_levels %}{% log_level record.status %}""",
verbose_name=_('Level')
)
message = tables.Column(
message = columns.MarkdownColumn(
verbose_name=_('Message')
)
@ -566,22 +566,17 @@ class ReportResultsTable(BaseTable):
time = tables.Column(
verbose_name=_('Time')
)
status = tables.Column(
empty_values=(),
verbose_name=_('Level')
)
status = tables.TemplateColumn(
template_code="""{% load log_levels %}{% log_level record.status %}""",
verbose_name=_('Level')
)
object = tables.Column(
verbose_name=_('Object')
)
url = tables.Column(
verbose_name=_('URL')
)
message = tables.Column(
message = columns.MarkdownColumn(
verbose_name=_('Message')
)

View File

@ -31,6 +31,10 @@
<th scope="row">{% trans "NetBox version" %}</th>
<td>{{ stats.netbox_version }}</td>
</tr>
<tr>
<th scope="row">{% trans "Python version" %}</th>
<td>{{ stats.python_version }}</td>
</tr>
<tr>
<th scope="row">{% trans "Django version" %}</th>
<td>{{ stats.django_version }}</td>

View File

@ -46,7 +46,21 @@
<input type="hidden" name="next" value="{{ request.POST.next }}" />
{% endif %}
{% render_form form %}
<div class="form-group mb-3">
<label for="id_username" class="form-label">{{ form.username.label }}</label>
{{ form.username }}
{% for error in form.username.errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
</div>
<div class="form-group">
<label for="id_password" class="form-label">{{ form.password.label }}</label>
{{ form.password }}
{% for error in form.password.errors %}
<div class="alert alert-danger">{{ error }}</div>
{% endfor %}
</div>
<div class="form-footer">
<button type="submit" class="btn btn-primary w-100">