--- /dev/null
+##############################################################################
+# Copyright (c) 2016 Max Breitenfeldt and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
\ No newline at end of file
--- /dev/null
+from dashboard_notification.notification import Notification
+from dashboard_api.api import DashboardAPI
+
+CONFIG = {
+ 'dashboard_ip': '127.0.0.1',
+ 'dashboard_url': 'http://127.0.0.1',
+ 'api_token': 'f33ff43c85ecb13f5d0632c05dbb0a7d85a5a8d1',
+ 'user': 'opnfv',
+ 'password': 'opnfvopnfv'
+}
+
+api = DashboardAPI(CONFIG['dashboard_url'], api_token=CONFIG['api_token'], verbose=True)
+
+
+def booking_start(message):
+ content = message.content
+ booking = api.get_booking(id=content['booking_id'])
+
+ # do something here...
+
+ # notify dashboard
+ api.post_resource_status(resource_id=booking['resource_id'], type='info', title='pod setup',
+ content='details')
+
+
+def booking_end(message):
+ # do something here...
+
+ # notify dashboard
+ api.post_resource_status(resource_id=message.content['resource_id'], type='info',
+ title='booking end', content='details')
+
+
+def main():
+ with Notification(CONFIG['dashboard_ip'], CONFIG['user'], CONFIG['password']) as notification:
+ notification.register(booking_start, 'Arm POD 2', 'booking_start')
+ notification.register(booking_end, 'Arm POD 2', 'booking_end')
+ notification.receive() # wait for notifications
+
+
+if __name__ == "__main__":
+ main()
# -*- coding: utf-8 -*-
-# Generated by Django 1.10 on 2016-09-23 11:36
+# Generated by Django 1.10 on 2016-11-03 13:33
from __future__ import unicode_literals
import account.models
('company', models.CharField(max_length=200)),
('oauth_token', models.CharField(max_length=1024)),
('oauth_secret', models.CharField(max_length=1024)),
+ ('jira_url', models.CharField(default='', max_length=100)),
+ ('full_name', models.CharField(default='', max_length=100)),
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Generated by Django 1.10 on 2016-10-05 12:01
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('account', '0001_initial'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='userprofile',
- name='full_name',
- field=models.CharField(default='', max_length=100),
- ),
- migrations.AddField(
- model_name='userprofile',
- name='jira_url',
- field=models.CharField(default='', max_length=100),
- ),
- ]
# -*- coding: utf-8 -*-
-# Generated by Django 1.10 on 2016-09-23 11:36
+# Generated by Django 1.10 on 2016-11-03 13:33
from __future__ import unicode_literals
from django.conf import settings
initial = True
dependencies = [
- migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('dashboard', '0001_initial'),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
('jira_issue_id', models.IntegerField(null=True)),
('jira_issue_status', models.CharField(max_length=50)),
('purpose', models.CharField(max_length=300)),
- ('resource', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='dashboard.Resource')),
- ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'booking',
},
),
+ migrations.CreateModel(
+ name='Installer',
+ fields=[
+ ('id', models.AutoField(primary_key=True, serialize=False)),
+ ('name', models.CharField(max_length=30)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='Scenario',
+ fields=[
+ ('id', models.AutoField(primary_key=True, serialize=False)),
+ ('name', models.CharField(max_length=300)),
+ ],
+ ),
+ migrations.AddField(
+ model_name='booking',
+ name='installer',
+ field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='booking.Installer'),
+ ),
+ migrations.AddField(
+ model_name='booking',
+ name='resource',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='dashboard.Resource'),
+ ),
+ migrations.AddField(
+ model_name='booking',
+ name='scenario',
+ field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='booking.Scenario'),
+ ),
+ migrations.AddField(
+ model_name='booking',
+ name='user',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
+ ),
]
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Generated by Django 1.10 on 2016-10-05 12:02
-from __future__ import unicode_literals
-
-from django.db import migrations, models
-import django.db.models.deletion
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('booking', '0001_initial'),
- ]
-
- operations = [
- migrations.CreateModel(
- name='Installer',
- fields=[
- ('id', models.AutoField(primary_key=True, serialize=False)),
- ('name', models.CharField(max_length=30)),
- ],
- ),
- migrations.CreateModel(
- name='Scenario',
- fields=[
- ('id', models.AutoField(primary_key=True, serialize=False)),
- ('name', models.CharField(max_length=300)),
- ],
- ),
- migrations.AddField(
- model_name='booking',
- name='installer',
- field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='booking.Installer'),
- ),
- migrations.AddField(
- model_name='booking',
- name='scenario',
- field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='booking.Scenario'),
- ),
- ]
admin.site.register(Resource)
admin.site.register(Server)
+admin.site.register(ResourceStatus)
# -*- coding: utf-8 -*-
-# Generated by Django 1.10 on 2016-09-23 11:36
+# Generated by Django 1.10 on 2016-11-03 13:33
from __future__ import unicode_literals
from django.conf import settings
initial = True
dependencies = [
- ('jenkins', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('jenkins', '0001_initial'),
]
operations = [
('url', models.CharField(blank=True, max_length=100, null=True)),
('owner', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='user_lab_owner', to=settings.AUTH_USER_MODEL)),
('slave', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to='jenkins.JenkinsSlave')),
- ('vpn_users', models.ManyToManyField(related_name='user_vpn_users', to=settings.AUTH_USER_MODEL)),
+ ('vpn_users', models.ManyToManyField(blank=True, related_name='user_vpn_users', to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'resource',
},
),
+ migrations.CreateModel(
+ name='ResourceStatus',
+ fields=[
+ ('id', models.AutoField(primary_key=True, serialize=False)),
+ ('timestamp', models.DateTimeField(auto_now_add=True)),
+ ('type', models.CharField(max_length=20)),
+ ('title', models.CharField(max_length=50)),
+ ('content', models.CharField(max_length=5000)),
+ ('resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.Resource')),
+ ],
+ options={
+ 'db_table': 'resource_status',
+ },
+ ),
migrations.CreateModel(
name='Server',
fields=[
+++ /dev/null
-# -*- coding: utf-8 -*-
-# Generated by Django 1.10 on 2016-10-05 12:02
-from __future__ import unicode_literals
-
-from django.conf import settings
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('dashboard', '0001_initial'),
- ]
-
- operations = [
- migrations.AlterField(
- model_name='resource',
- name='vpn_users',
- field=models.ManyToManyField(blank=True, related_name='user_vpn_users', to=settings.AUTH_USER_MODEL),
- ),
- ]
def __str__(self):
return self.name
-
class Server(models.Model):
id = models.AutoField(primary_key=True)
resource = models.ForeignKey(Resource, on_delete=models.CASCADE)
def __str__(self):
return self.name
+
+class ResourceStatus(models.Model):
+ id = models.AutoField(primary_key=True)
+ resource = models.ForeignKey(Resource, on_delete=models.CASCADE)
+ timestamp = models.DateTimeField(auto_now_add=True)
+ type = models.CharField(max_length=20)
+ title = models.CharField(max_length=50)
+ content = models.CharField(max_length=5000)
+
+ class Meta:
+ db_table = 'resource_status'
+
+ def __str__(self):
+ return self.resource.name + ': ' + self.title + ' ' + str(self.timestamp)
# -*- coding: utf-8 -*-
-# Generated by Django 1.10 on 2016-09-23 11:36
+# Generated by Django 1.10 on 2016-11-03 13:33
from __future__ import unicode_literals
from django.db import migrations, models
('last_job_branch', models.CharField(default='', max_length=50)),
('last_job_installer', models.CharField(default='', max_length=50)),
('last_job_result', models.CharField(default='', max_length=30)),
+ ('active', models.BooleanField(default=False)),
],
options={
'db_table': 'jenkins_slave',
</div>
</div>
</div>
+
+ <div class="col-lg-9">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ Status
+ </div>
+ <div class="panel-body">
+ <div class="list-group pre-scrollable">
+ {% for status in resource.resourcestatus_set.all %}
+ <a href="#" class="list-group-item">
+ <i class="fa fa-info fa-fw"></i> {{ status.title }}
+ <span class="pull-right text-muted small">
+ <em>{{ status.timestamp }}</em>
+ </span>
+ </a>
+ {% endfor %}
+ </div>
+ </div>
+ </div>
+ </div>
<div class="col-lg-9">
<div class="panel panel-default">
<div class="panel-heading">
</div>
</div>
</div>
-</div>
\ No newline at end of file
+</div>