Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 7 additions & 2 deletions .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: main branch CI
on:
push:
branches:
- "main"
- "main_v3"

jobs:
testing:
Expand All @@ -12,7 +12,7 @@ jobs:
max-parallel: 4
matrix:
python-version: ["3.11"]
netbox-version: ["v4.1.0"]
netbox-version: ["v4.1.11"]
services:
redis:
image: redis
Expand Down Expand Up @@ -55,6 +55,11 @@ jobs:
run: |
ln -s $(pwd)/../netbox-docker-plugin/netbox_configuration/configuration_testing.py netbox/netbox/configuration.py
python -m pip install --upgrade pip
# Les runners embarquent les en-tetes PostgreSQL 18, contre lesquels
# psycopg-c ne compile pas (macro HAVE_LONG_INT_64 supprimee). La roue
# binaire embarque sa propre libpq et evite toute compilation.
sed -i 's/^psycopg\[c,pool\]/psycopg[binary,pool]/' requirements.txt
grep -q '^psycopg\[binary,pool\]' requirements.txt
pip install -r requirements.txt -U
- name: Run Pylint
run: |
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/pr_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Pull Request CI
on:
pull_request:
branches:
- "main"
- "main_v3"

jobs:
testing:
Expand Down Expand Up @@ -58,6 +58,11 @@ jobs:
run: |
ln -s $(pwd)/../netbox-docker-plugin/netbox_configuration/configuration_testing.py netbox/netbox/configuration.py
python -m pip install --upgrade pip
# Les runners embarquent les en-tetes PostgreSQL 18, contre lesquels
# psycopg-c ne compile pas (macro HAVE_LONG_INT_64 supprimee). La roue
# binaire embarque sa propre libpq et evite toute compilation.
sed -i 's/^psycopg\[c,pool\]/psycopg[binary,pool]/' requirements.txt
grep -q '^psycopg\[binary,pool\]' requirements.txt
pip install -r requirements.txt -U
- name: Run Pylint
run: |
Expand Down
2 changes: 1 addition & 1 deletion netbox_docker_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class NetBoxDockerConfig(PluginConfig):
name = "netbox_docker_plugin"
verbose_name = " NetBox Docker Plugin"
description = "Manage Docker"
version = "3.3.0"
version = "3.4.0"
base_url = "docker"
min_version = "4.1.0"
author = "Vincent Simonin <vincent@saashup.com>, David Delassus <david.jose.delassus@gmail.com>"
Expand Down
16 changes: 6 additions & 10 deletions netbox_docker_plugin/forms/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
Container,
ContainerRestartPolicyChoices,
ContainerCapAddChoices,
ContainerLogDriverChoices,
)
from ..models.image import Image

Expand Down Expand Up @@ -121,9 +120,7 @@ class ContainerFilterForm(NetBoxModelFilterSetForm):
restart_policy = forms.ChoiceField(
label="Restart Policy", choices=ContainerRestartPolicyChoices, required=False
)
log_driver = forms.ChoiceField(
label="Logging driver", choices=ContainerLogDriverChoices, required=False
)
log_driver = forms.CharField(label="Logging driver", required=False)
tag = TagFilterField(model)


Expand All @@ -138,11 +135,11 @@ class ContainerImportForm(NetBoxModelImportForm):
+ "`always`, `unless-stopped`.",
)

log_driver = forms.ChoiceField(
log_driver = forms.CharField(
label="Logging driver",
choices=ContainerLogDriverChoices,
required=False,
help_text="Logging driver. Can be `json-log`, `syslog`.",
help_text="Logging driver, as reported by Docker. For example "
+ "`json-file`, `syslog`, `journald`, `local`.",
)

class Meta:
Expand Down Expand Up @@ -170,10 +167,9 @@ class ContainerBulkEditForm(NetBoxModelBulkEditForm):
choices=ContainerRestartPolicyChoices,
required=True,
)
log_driver = forms.ChoiceField(
log_driver = forms.CharField(
label="Logging driver",
choices=ContainerLogDriverChoices,
required=True,
required=False,
)
hostname = forms.CharField(
label="Hostname", max_length=256, min_length=1, required=False
Expand Down
32 changes: 32 additions & 0 deletions netbox_docker_plugin/migrations/0036_alter_container_log_driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# pylint: disable=C0103
"""Migration file"""

from django.db import migrations, models


class Migration(migrations.Migration):
"""Make Container.log_driver a free-form value.

The agent reports HostConfig.LogConfig.Type verbatim from the Docker
daemon (json-file, journald, local, ...), which the previous two-value
choice set rejected. The legacy `json-log` value was never a valid Docker
driver name and is normalised to `json-file`.
"""

dependencies = [
("netbox_docker_plugin", "0035_container_log_driver_logdriveroption"),
]

operations = [
migrations.RunSQL(
sql="UPDATE netbox_docker_plugin_container "
"SET log_driver='json-file' WHERE log_driver='json-log'",
reverse_sql="UPDATE netbox_docker_plugin_container "
"SET log_driver='json-log' WHERE log_driver='json-file'",
),
migrations.AlterField(
model_name="container",
name="log_driver",
field=models.CharField(max_length=32, null=True, blank=True),
),
]
32 changes: 32 additions & 0 deletions netbox_docker_plugin/migrations/0037_alter_env_value.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# pylint: disable=C0103
"""Migration file"""

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):
"""Raise Env.value to 32768 characters.

The agent imports environment variables verbatim from the Docker daemon;
inline configuration and certificate material routinely exceed the previous
4096 character ceiling.
"""

dependencies = [
("netbox_docker_plugin", "0036_alter_container_log_driver"),
]

operations = [
migrations.AlterField(
model_name="env",
name="value",
field=models.CharField(
blank=True,
max_length=32768,
validators=[
django.core.validators.MaxLengthValidator(limit_value=32768)
],
),
),
]
26 changes: 26 additions & 0 deletions netbox_docker_plugin/migrations/0038_container_cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# pylint: disable=C0103
"""Migration file"""

import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):
"""Migration file"""

dependencies = [
("netbox_docker_plugin", "0037_alter_env_value"),
]

operations = [
migrations.AddField(
model_name="container",
name="cmd",
field=django.contrib.postgres.fields.ArrayField(
base_field=models.CharField(blank=True, max_length=1024, null=True),
blank=True,
null=True,
size=None,
),
),
]
30 changes: 30 additions & 0 deletions netbox_docker_plugin/migrations/1039_alter_port_public_port.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# pylint: disable=C0103
"""Migration file"""

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):
"""Allow Port.public_port to be -1.

The agent uses -1 to mean "exposed but not published"; the previous floor
of 0 rejected every container with an unpublished exposed port.
"""

dependencies = [
("netbox_docker_plugin", "0038_container_cmd"),
]

operations = [
migrations.AlterField(
model_name="port",
name="public_port",
field=models.IntegerField(
validators=[
django.core.validators.MinValueValidator(limit_value=-1),
django.core.validators.MaxValueValidator(limit_value=65535),
]
),
),
]
48 changes: 30 additions & 18 deletions netbox_docker_plugin/models/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,6 @@ class ContainerRestartPolicyChoices(ChoiceSet):
]


class ContainerLogDriverChoices(ChoiceSet):
"""Container log driver choices definition class"""

key = "Container.log_driver"

DEFAULT_VALUE = "json-log"

CHOICES = [
("json-log", "json-log", "blue"),
("syslog", "syslog", "blue"),
]


class PortTypeChoices(ChoiceSet):
"""Port type choices definition class"""

Expand All @@ -105,7 +92,27 @@ class ContainerCapAddChoices(ChoiceSet):
key = "Container.cap_add"

CHOICES = [
("AUDIT_WRITE", "AUDIT_WRITE"),
("CHOWN", "CHOWN"),
("DAC_OVERRIDE", "DAC_OVERRIDE"),
("DAC_READ_SEARCH", "DAC_READ_SEARCH"),
("FOWNER", "FOWNER"),
("FSETID", "FSETID"),
("KILL", "KILL"),
("MKNOD", "MKNOD"),
("NET_ADMIN", "NET_ADMIN"),
("NET_BIND_SERVICE", "NET_BIND_SERVICE"),
("NET_RAW", "NET_RAW"),
("SETFCAP", "SETFCAP"),
("SETGID", "SETGID"),
("SETPCAP", "SETPCAP"),
("SETUID", "SETUID"),
("SYS_ADMIN", "SYS_ADMIN"),
("SYS_CHROOT", "SYS_CHROOT"),
("SYS_NICE", "SYS_NICE"),
("SYS_PTRACE", "SYS_PTRACE"),
("SYS_RESOURCE", "SYS_RESOURCE"),
("ALL", "ALL"),
]


Expand Down Expand Up @@ -168,8 +175,13 @@ class Container(NetBoxModel):
)
log_driver = models.CharField(
max_length=32,
choices=ContainerLogDriverChoices,
default=ContainerLogDriverChoices.DEFAULT_VALUE,
null=True,
blank=True,
)
cmd = ArrayField(
models.CharField(max_length=1024, blank=True, null=True),
null=True,
blank=True,
)

@property
Expand Down Expand Up @@ -261,7 +273,7 @@ class Port(models.Model):
)
public_port = models.IntegerField(
validators=[
MinValueValidator(limit_value=0),
MinValueValidator(limit_value=-1),
MaxValueValidator(limit_value=65535),
],
)
Expand Down Expand Up @@ -345,9 +357,9 @@ class Env(models.Model):
)
value = models.CharField(
blank=True,
max_length=4096,
max_length=32768,
validators=[
MaxLengthValidator(limit_value=4096),
MaxLengthValidator(limit_value=32768),
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h5 class="card-header">CONTAINER</h5>
</tr>
<tr>
<th scope="row">Logging driver</th>
<td>{{ object.get_log_driver_display }}</td>
<td>{{ object.log_driver }}</td>
</tr>
</table>
</div>
Expand Down
Loading
Loading