From 19a302774a601e27c7fcd107aa7388c06ce44d17 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 27 Jun 2016 13:21:38 -0400 Subject: [PATCH 1/4] Changed gunicorn path to since that appears to be standard for Ubuntu now --- docs/getting-started.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 1d657fbf3..8f2688aef 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -259,10 +259,10 @@ Restart the nginx service to use the new configuration. ## gunicorn Configuration -Save the following configuration file in the root netbox installation path (in this example, `/opt/netbox/`.) as `gunicorn_config.py`. Be sure to update the `pythonpath` variable if needed. +Save the following configuration file in the root netbox installation path (in this example, `/opt/netbox/`.) as `gunicorn_config.py`. Be sure to verify the location of the gunicorn executable (e.g. `which gunicorn`) and to update the `pythonpath` variable if needed. ``` -command = '/usr/local/bin/gunicorn' +command = '/usr/bin/gunicorn' pythonpath = '/opt/netbox/netbox' bind = '127.0.0.1:8001' workers = 3 From 7cf437e11b5377a46dcbe23f13cc3d1215b848fd Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 27 Jun 2016 13:53:39 -0400 Subject: [PATCH 2/4] Fixes #26: Added rack height validation --- netbox/dcim/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index 0fe3bc30c..5ff233c9c 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -183,6 +183,16 @@ class Rack(CreatedUpdatedModel): def get_absolute_url(self): return reverse('dcim:rack', args=[self.pk]) + def clean(self): + + # Validate that Rack is tall enough to house the installed Devices + if self.pk: + top_device = Device.objects.filter(rack=self).order_by('-position').first() + min_height = top_device.position + top_device.device_type.u_height - 1 + if self.u_height < min_height: + raise ValidationError("Rack must be at least {}U tall with currently installed devices." + .format(min_height)) + def to_csv(self): return ','.join([ self.site.name, From eade3cbd6b86d52e14f5b511f329ac86f763ce46 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 27 Jun 2016 14:12:30 -0400 Subject: [PATCH 3/4] Fixes #25: Recurse expand_pattern only if there are more ranges to unpack --- netbox/utilities/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox/utilities/forms.py b/netbox/utilities/forms.py index 7ad41697e..260365eec 100644 --- a/netbox/utilities/forms.py +++ b/netbox/utilities/forms.py @@ -19,11 +19,11 @@ def expand_pattern(string): lead, pattern, remnant = re.split(EXPANSION_PATTERN, string, maxsplit=1) x, y = pattern.split('-') for i in range(int(x), int(y) + 1): - if remnant: + if re.search(EXPANSION_PATTERN, remnant): for string in expand_pattern(remnant): yield "{}{}{}".format(lead, i, string) else: - yield "{}{}".format(lead, i) + yield "{}{}{}".format(lead, i, remnant) # From c6e66a073d93745f52f0ef9c8c53bc7037c130eb Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Mon, 27 Jun 2016 14:39:08 -0400 Subject: [PATCH 4/4] Fixes #29: Corrected typo --- netbox/dcim/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index fd4aaf6ff..50c3243d8 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -353,7 +353,7 @@ class ComponentTemplateCreateView(View): if not form.errors: self.model.objects.bulk_create(component_templates) - messages.success(request, "Added {} compontent(s) to {}".format(len(component_templates), devicetype)) + messages.success(request, "Added {} component(s) to {}".format(len(component_templates), devicetype)) if '_addanother' in request.POST: return redirect(request.path) else: