Skip to content

Commit

Permalink
See CHANGELOG tag v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnavarro committed Dec 26, 2022
1 parent 66b7f31 commit 2934c6a
Show file tree
Hide file tree
Showing 11 changed files with 340 additions and 229 deletions.
34 changes: 21 additions & 13 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
v2.1.0 20221215 JP
v2.1.0 2022-12-26 JP
- Ordered Cancel button left, Save button right

v2.0.2 20221206 JP
- Added LogEntry fields that reference host, staff, and event for expanded logging
- Improve LogEntry viewing for expanded logging
- login/logout logging with IP address to LogEntry and log file so that we can remote rsyslog it
- New /services/api/hosts/ returns hosts and related service json w/o people phones or emails
- New /services/login url for logging
- Use djangorestframework for api serializers
- Significant update_service improvements & fixes to properly handle form errors
- Standardize on "Y/m/d H:i" datetime format

v2.0.2 2022-12-06 JP
- Improve logging

v2.0.1 20221205 JP
v2.0.1 2022-12-05 JP
- Fix new service bug that prevented links and hosts from being added
- Set btn-access-auth border-radius
- Include information/help glyphicon in header linking to application information in the operations portal
- Turn version in header into a link to GitHub source
- Improve navigation item order
- Fix service edit button width

v2.0.0 20221128 JP
v2.0.0 2022-11-28 JP
- Upgrade and convert to django-bootstrap-v5 installed in pipenv, remove old local version
- Upgrade and convert to JQuery Core 3.6.1 and JQuery UI 1.13.1 loaded from code.jquery.com cdn, remove old local version
- Support connecting sociallogin to existing Drupal user
Expand All @@ -27,17 +35,17 @@ v2.0.0 20221128 JP
- Rename several templates with better names
- New syslog_standard_10514 and syslog_relp_10515 check boxes model fields

v1.2.2 20221111 JP
v1.2.2 2022-11-11 JP
- New 'viewers' group, update all views to require editor or viewer privs as appropriate

v1.2.1 20221111 JP
v1.2.1 2022-11-11 JP
- Fix link form saving bug
- Make metrics entry dates Central time aware since log entries do have a UTC timzeone
- When log entries are display, make it clear they are in UTC
- Display APP_VERSION / GitHub tag in header
- Show (username) in logout link

v1.2.0 20221107 JP
v1.2.0 2022-11-07 JP
- More opsres to serviceindex changes
- Convert to use ModelForms
- Separate add_service, edit_service, update_service urls and functions
Expand All @@ -51,17 +59,17 @@ v1.2.0 20221107 JP
- Remove some legacy code
- Other minor improvements

v1.1.1 20221028 JP
v1.1.1 2022-10-28 JP
- Remove logacy socialauth configuration

v1.1.0 20221028 JP
v1.1.0 2022-10-28 JP
- Renamed application from Registry to ServiceIndex

tag-1.0.2 20221013 JP
tag-1.0.2 2022-10-13 JP
- Add required trailing slash to login/ url

tag-1.0.1 20220923 JP
tag-1.0.1 2022-09-23 JP
- Improved Docker build and implement https support

tag-1.0.0 20220920 JP
tag-1.0.0 2022-09-20 JP
- Initial check-in of fully functional application
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
ACCOUNT_EMAIL_VERIFICATION = 'none'
ACCOUNT_LOGOUT_REDIRECT_URL = '/accounts/cilogon/login/'
LOGIN_URL = '/accounts/cilogon/login/'
LOGIN_REDIRECT_URL = '/services/'
LOGIN_REDIRECT_URL = '/services/login'
#SOCIALACCOUNT_ADAPTER = 'services.views.MySocialAccountAdapter'
#SOCIALACCOUNT_STORE_TOKENS = True

Expand Down Expand Up @@ -203,6 +203,8 @@
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

# Logging setup
import logging
from logging.handlers import SysLogHandler
Expand Down Expand Up @@ -245,7 +247,5 @@
}
}

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

APP_NAME = 'Service Index'
APP_VERSION = CONF['APP_VERSION']
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 4.1.3 on 2022-12-21 14:32

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('services', '0001_squashed_0004_alter_host_nagios_alter_host_qualys_and_more'),
]

operations = [
migrations.AddField(
model_name='logentry',
name='event',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='services.event'),
),
migrations.AddField(
model_name='logentry',
name='host',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='services.host'),
),
migrations.AddField(
model_name='logentry',
name='staff',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='services.staff'),
),
migrations.AlterField(
model_name='logentry',
name='service',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='services.service'),
),
]
26 changes: 16 additions & 10 deletions Operations_ServiceIndex_Django/services/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Host(models.Model):
host_last_verified = models.DateField(null=True, blank=True)

def __str__(self):
return 'label={}:host={}:service={}:site={}'.format(self.label, self.hostname, self.service, self.location)
return 'label={}:host={}:service={}'.format(self.label, self.hostname, self.service)

class Meta:
db_table = '"serviceindex"."host"'
Expand All @@ -133,15 +133,6 @@ class Link(models.Model):
class Meta:
db_table = '"serviceindex"."link"'

class LogEntry(models.Model):
timestamp = models.DateTimeField(auto_now_add=True)
username = models.CharField(max_length=16) # foreign key to django user ?
service = models.ForeignKey(Service, on_delete=models.CASCADE,)
msg = models.CharField(max_length=1024)

class Meta:
db_table = '"serviceindex"."logentry"'

class EditLock(models.Model):
timestamp = models.DateTimeField(auto_now_add=True)
username = models.CharField(max_length=16)
Expand All @@ -156,6 +147,9 @@ class Event(models.Model):
name = models.CharField(max_length=128)
description = models.CharField(max_length=1024)

def __str__(self):
return '{} (id={})'.format(self.name, self.id)

class Meta:
db_table = '"serviceindex"."event"'

Expand Down Expand Up @@ -191,6 +185,18 @@ class HostEventLog(models.Model):
class Meta:
db_table = '"serviceindex"."hosteventlog"'

class LogEntry(models.Model):
timestamp = models.DateTimeField(auto_now_add=True)
username = models.CharField(max_length=16) # the user making changes about one of the following
service = models.ForeignKey(Service, blank=True, null=True, on_delete=models.CASCADE,)
host = models.ForeignKey(Host, blank=True, null=True, on_delete=models.CASCADE,)
staff = models.ForeignKey(Staff, blank=True, null=True, on_delete=models.CASCADE,)
event = models.ForeignKey(Event, blank=True, null=True, on_delete=models.CASCADE,)
msg = models.CharField(max_length=1024)

class Meta:
db_table = '"serviceindex"."logentry"'

# FORMS

class ServiceForm(forms.ModelForm):
Expand Down
29 changes: 29 additions & 0 deletions Operations_ServiceIndex_Django/services/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from rest_framework import serializers
from services.models import *

class Service_Serializer(serializers.ModelSerializer):
class Meta:
model = Service
fields = '__all__'

class Host_Serializer(serializers.ModelSerializer):
service = Service_Serializer(read_only=True)
location = serializers.CharField(source='location.site')
availability = serializers.CharField(source='availability.description')
support = serializers.CharField(source='support.hours')
sys_admin = serializers.SerializerMethodField()
poc_primary = serializers.SerializerMethodField()
poc_backup = serializers.SerializerMethodField()
class Meta:
model = Host
fields = ('service', 'location', 'hostname', 'ip_address',
'qualys', 'nagios', 'syslog_standard_10514', 'syslog_relp_10515',
'label', 'availability', 'support',
'sys_admin', 'poc_primary', 'poc_backup', 'host_last_verified')

def get_sys_admin(self, Host):
return '{}, {}'.format(Host.sys_admin.last_name, Host.sys_admin.name)
def get_poc_primary(self, Host):
return '{}, {}'.format(Host.poc_primary.last_name, Host.poc_primary.name)
def get_poc_backup(self, Host):
return '{}, {}'.format(Host.poc_backup.last_name, Host.poc_backup.name)
12 changes: 9 additions & 3 deletions Operations_ServiceIndex_Django/services/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import time
from django.contrib.auth.models import User
from django.dispatch import receiver, Signal
from allauth.account.signals import user_logged_in
from allauth.account.signals import user_logged_in, user_logged_out
from allauth.account.utils import sync_user_email_addresses, setup_user_email
from allauth.socialaccount.providers.cilogon import provider
from allauth.socialaccount.providers.oauth2.client import OAuth2Error
Expand All @@ -25,9 +25,16 @@ def set_username(request, user, **kwargs):

user.username = username
user.save()
msg = '{} logged in as {}'.format(subject, request.user.username)
remote_ip = request.META.get('HTTP_X_FORWARDED_FOR')
if not remote_ip:
remote_ip = request.META.get('REMOTE_ADDR')
msg = '{} logged in as {} from {}'.format(subject, request.user.username, remote_ip)
logger.info(msg)

@receiver(user_logged_out)
def logout_log(request, user, **kwargs):
msg = '{} logged out'.format(request.user.username)
logger.info(msg)

@receiver(pre_social_login)
def connect_existing_user(request, sociallogin, **kwargs):
Expand All @@ -48,4 +55,3 @@ def connect_existing_user(request, sociallogin, **kwargs):
setup_user_email(request, existing_user, [])
msg = 'login as email {} connected to {}'.format(email, existing_user.username)
logger.info(msg)

2 changes: 2 additions & 0 deletions Operations_ServiceIndex_Django/services/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
path('export/', views.export, name="export"),
path('custom/', views.custom, name="custom"),
path('listing/', views.listing, name="listing"),
path('login/', views.login, name="login"),
path('log_listing/', views.log_listing, name="log_listing"),
path('view_log/', views.view_log, name="view_log"),
path('metrics/', views.metrics, name="metrics"),
path('add_event/', views.add_event, name="add_event"),
path('events/', views.events, name="events"),
re_path('^event/(?P<event_id>\d+)$', views.event, name="event"),
re_path('^update_event/(?P<hes_id>\d+)$', views.update_event, name="update_event"),
path('api/hosts/', views.api_hosts, name="api_hosts"),
path('clear_and_logout/', views.clear_and_logout, name='clear_and_logout'),
path('unprivileged/', views.unprivileged, name="unprivileged"),
]
Loading

0 comments on commit 2934c6a

Please sign in to comment.