Commit debec5da authored by Rémi Duraffort's avatar Rémi Duraffort Committed by Neil Williams
Browse files

Remove unused models and fields

Change-Id: Idadcd27aa9fbd40c750af9e257f62fbc8dd03858
parent 6e8c08e4
......@@ -286,7 +286,7 @@ class TestJobAdmin(admin.ModelAdmin):
('Request', {
'fields': ('requested_device', 'requested_device_type', 'priority', 'health_check')}),
('Advanced properties', {
'fields': ('description', 'tags', 'sub_id', 'target_group', 'vm_group')}),
'fields': ('description', 'tags', 'sub_id', 'target_group')}),
('Current status', {
'fields': ('actual_device', 'status')}),
('Results & Failures', {
......@@ -392,7 +392,7 @@ show_worker_action.short_description = "Show selected worker(s)"
class WorkerAdmin(admin.ModelAdmin):
actions = [hide_worker_action, show_worker_action]
list_display = ('hostname', 'display', 'is_master')
list_display = ('hostname', 'display')
ordering = ['hostname']
......
......@@ -769,7 +769,7 @@ class SchedulerAPI(ExposedAPI):
The elements available in XML-RPC structure include:
_results_link, _state, submitter_id, submit_token_id, is_pipeline,
id, failure_comment, multinode_definition, user_id,
priority, _actual_device_cache, vm_group, original_definition,
priority, _actual_device_cache, original_definition,
status, health_check, description, admin_notifications, start_time,
target_group, visibility, requested_device_id, pipeline_compatibility,
submit_time, is_public, _old_status, actual_device_id, definition,
......
......@@ -182,7 +182,6 @@ class SchedulerWorkersAPI(ExposedV2API):
return {"hostname": worker.hostname,
"description": worker.description,
"master": worker.is_master,
"hidden": not worker.display,
"devices": worker.device_set.count()}
......
......@@ -341,7 +341,7 @@ def get_job_queue():
'requested_device', 'requested_device_type', 'actual_device')
jobs = jobs.prefetch_related('tags')
jobs = jobs.order_by('-health_check', '-priority', 'submit_time',
'vm_group', 'target_group', 'id')
'target_group', 'id')
# evaluate in database
if len(jobs):
logger.info("Job queue length: %d", len(jobs))
......
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-11-15 09:43
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('lava_scheduler_app', '0029_remove_testjob__results_bundle'),
]
operations = [
migrations.RemoveField(
model_name='devicetype',
name='health_check_job',
),
migrations.RemoveField(
model_name='testjob',
name='vm_group',
),
migrations.RemoveField(
model_name='testjob',
name='vmgroup_definition',
),
migrations.RemoveField(
model_name='worker',
name='is_master',
),
migrations.RemoveField(
model_name='worker',
name='rpc2_url',
),
migrations.DeleteModel(
name='TemporaryDevice',
),
]
......@@ -305,11 +305,6 @@ class DeviceType(models.Model):
default=None
)
# FIXME: deprecated, should be removed in 2017.5
# Replaced by Device.get_health_check()
health_check_job = models.TextField(
null=True, blank=True, default=None, validators=[validate_job])
health_frequency = models.IntegerField(
verbose_name="How often to run health checks",
default=24
......@@ -425,17 +420,6 @@ class Worker(models.Model):
editable=True
)
rpc2_url = models.CharField(
verbose_name=_(u"Master RPC2 URL"),
max_length=200,
null=True,
blank=True,
editable=True,
default=None,
help_text=("Corresponds to the master node's RPC2 url. Does not have"
" any impact when set on a worker node.")
)
display = models.BooleanField(
default=True,
help_text=("Should this be displayed in the GUI or not. This will be"
......@@ -443,12 +427,6 @@ class Worker(models.Model):
" linked device status transitions and devices should be"
" intact."))
is_master = models.BooleanField(
verbose_name=_(u"Is Master?"),
default=False,
editable=True
)
description = models.TextField(
verbose_name=_(u"Worker Description"),
max_length=200,
......@@ -948,27 +926,6 @@ class Device(RestrictedResource):
return None
class TemporaryDevice(Device):
"""
A temporary device which inherits all properties of a normal Device.
Heavily used by vm-groups implementation.
This uses "Multi-table inheritance" of django models, since we need a
separate table to maintain the temporary devices.
See: https://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance
"""
vm_group = models.CharField(
verbose_name=_(u"VM Group"),
blank=True,
max_length=64,
null=True,
default=None
)
class Meta:
pass
class JobFailureTag(models.Model):
"""
Allows us to maintain a set of common ways jobs fail. These can then be
......@@ -1374,14 +1331,6 @@ class TestJob(RestrictedResource):
default=None
)
vm_group = models.CharField(
verbose_name=_(u"VM Group"),
blank=True,
max_length=64,
null=True,
default=None
)
submitter = models.ForeignKey(
User,
verbose_name=_(u"Submitter"),
......@@ -1509,11 +1458,6 @@ class TestJob(RestrictedResource):
blank=True
)
vmgroup_definition = models.TextField(
editable=False,
blank=True
)
is_pipeline = models.BooleanField(
verbose_name="Pipeline job?",
default=False,
......
......@@ -441,11 +441,7 @@ class DeviceHealthTable(LavaTable):
<a href="{{ record.get_absolute_url }}">{{ record.hostname }}</a>
''')
worker_host = tables.TemplateColumn('''
{% if record.is_master %}
<b><a href="{{ record.worker_host.get_absolute_url }}">{{ record.worker_host }}</a></b>
{% else %}
<a href="{{ record.worker_host.get_absolute_url }}">{{ record.worker_host }}</a>
{% endif %}
''')
health_status = tables.Column()
last_report_time = tables.DateColumn(
......@@ -508,7 +504,7 @@ class DeviceTypeTable(LavaTable):
class Meta(LavaTable.Meta): # pylint: disable=too-few-public-methods,no-init,no-self-use
model = DeviceType
exclude = [
'display', 'disable_health_check', 'health_check_job', 'owners_only',
'display', 'disable_health_check', 'owners_only',
'architecture', 'health_denominator', 'health_frequency',
'processor', 'cpu_model', 'bits', 'cores', 'core_count', 'description'
]
......@@ -530,11 +526,7 @@ class DeviceTable(LavaTable):
<a href="{{ record.get_absolute_url }}">{{ record.hostname }}</a>
''')
worker_host = tables.TemplateColumn('''
{% if record.is_master %}
<b><a href="{{ record.worker_host.get_absolute_url }}">{{ record.worker_host }}</a></b>
{% else %}
<a href="{{ record.worker_host.get_absolute_url }}">{{ record.worker_host }}</a>
{% endif %}
''')
device_type = tables.Column()
status = ExpandedStatusColumn("status")
......@@ -592,22 +584,16 @@ class WorkerTable(tables.Table): # pylint: disable=too-few-public-methods,no-in
self.show_help = True
hostname = tables.TemplateColumn('''
{% if record.is_master %}
<b><a href="{{ record.get_absolute_url }}">{{ record.hostname }}</a></b>
{% else %}
<a href="{{ record.get_absolute_url }}">{{ record.hostname }}</a>
{% endif %}
''')
is_master = tables.Column()
class Meta(LavaTable.Meta): # pylint: disable=too-few-public-methods,no-init,no-self-use
model = Worker
exclude = [
'rpc2_url', 'display'
'display'
]
sequence = [
'hostname', 'description', 'is_master'
'hostname', 'description'
]
......@@ -832,6 +818,6 @@ class RunningTable(LavaTable):
'name', 'reserved', 'running', 'jobs'
]
exclude = [
'display', 'disable_health_check', 'health_check_job', 'owners_only', 'architecture',
'display', 'disable_health_check', 'owners_only', 'architecture',
'processor', 'cpu_model', 'bits', 'cores', 'core_count', 'description'
]
......@@ -14,7 +14,7 @@
</li>
</ul>
{% if user.is_staff and device.device_type.name != 'dynamic-vm' and not device.get_health_check and not device.device_type.disable_health_check %}
{% if user.is_staff and not device.get_health_check and not device.device_type.disable_health_check %}
<div class="alert alert-warning">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>The device has no
......
......@@ -62,10 +62,8 @@
<dd>{{ running_jobs_num }}</dd>
<dt>Queued jobs</dt>
<dd>{{ queued_jobs_num }}</dd>
{% if device_type.name != 'dynamic-vm' %}
<dt>Checks/failures</dt>
<dd><a href="{% url 'lava.scheduler.device_type_report' device_type %}">Graphical reports</a></dd>
{% endif %}
<dt>Health Checks</dt>
<dd>{{ health_freq }}</dd>
</dl>
......@@ -78,10 +76,8 @@
<dd>{{ idle_num }}</dd>
<dt>Offline</dt>
<dd>{{ offline_num }}</dd>
{% if device_type.name != 'dynamic-vm' %}
<dt>Retired</dt>
<dd>{{ retired_num }}</dd>
{% endif %}
</dl>
</div>
</div>
......@@ -131,10 +127,8 @@
<h4 class="modal-header">Devices list</h4>
{% render_table devices_table_no_dt %}
{% if device_type.name != 'dynamic-vm' %}
<h4 class="modal-header">Health Job Summary</h4>
{% render_table health_job_summary_table %}
{% endif %}
<h4 class="modal-header">Jobs for devices of type {{ device_type }}</h4>
{% render_table device_type_jobs_table %}
......
......@@ -22,8 +22,6 @@
<div class="col-md-6">
<h4 class="modal-header">LAVA details</h4>
<dl class="dl-horizontal">
<dt>Is Master</dt>
<dd>{{ worker.is_master }}</dd>
<dt>Description</dt>
{% if can_admin %}
<form method="POST" action="{% url 'lava.scheduler.edit_worker_desc' %}">
......
{
"timeout": 900,
"job_name": "test multinode submission",
"logging_level": "INFO",
"vm_group": {
"host": {
"device_type": "beaglebone-black",
"role": "host"
},
"auto_start_vms": false,
"vms": [{
"device_type": "kvm-aarch32",
"role": "guest-nonsecure"
}, {
"device_type": "kvm-aarch64",
"role": "guest-secure"
}, {
"device_type": "kvm-aarch64",
"role": "guest-grub-secure"
}]
},
"actions": [{
"command": "deploy_linaro_kernel",
"parameters": {
"dtb": "",
"kernel": "",
"nfsrootfs": "",
"target_type": "ubuntu",
"role": "host"
}
}, {
"command": "deploy_linaro_kernel",
"parameters": {
"kernel": "",
"ramdisk": "",
"firmware": "",
"role": "guest-nonsecure"
}
}, {
"command": "deploy_linaro_kernel",
"parameters": {
"kernel": "",
"ramdisk": "",
"role": "guest-secure"
}
}, {
"command": "deploy_linaro_kernel",
"parameters": {
"kernel": "",
"rootfs": "",
"role": "guest-grub-secure"
}
}, {
"command": "lava_test_shell",
"parameters": {
"testdef_repos": [{
"url": "https://git.linaro.org/ci/uefi.git/blob_plain/HEAD:/lava/kvm-install-qemu-host.yaml"
}],
"timeout": 1800,
"role": "host"
}
}]
}
......@@ -267,8 +267,7 @@ class DeviceTableView(JobTableView):
"current_job__submitter",
"user", "group") \
.prefetch_related("tags") \
.filter(temporarydevice=None,
device_type__in=visible,
.filter(device_type__in=visible,
is_pipeline=True) \
.order_by("hostname")
......@@ -637,9 +636,7 @@ class DeviceTypeOverView(JobTableView):
class NoDTDeviceView(DeviceTableView):
def get_queryset(self):
return Device.objects.filter(
Q(temporarydevice=None) and ~Q(status__in=[Device.RETIRED])
).order_by('hostname')
return Device.objects.exclude(status=Device.RETIRED).order_by('hostname')
@BreadCrumb("Device Type {pk}", parent=index, needs=['pk'])
......
# Copyright (C) 2017 Linaro Limited
#
# Author: Remi Duraffort <remi.duraffort@linaro.org>
#
# This file is part of LAVA Dispatcher.
#
# LAVA Dispatcher is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LAVA Dispatcher is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along
# with this program; if not, see <http://www.gnu.org/licenses>.
from django.core.management.base import BaseCommand
from lava_scheduler_app.models import (
Device,
DeviceType,
)
import errno
import os
import re
def is_device_type_retired(dt):
"""
Return True if all devices of this type are RETIRED.
"""
return all([device.status == Device.RETIRED for device in dt.device_set.all()])
def is_device_type_exclusive(dt):
return all([device.is_exclusive or device.status == Device.RETIRED for device in dt.device_set.all()])
class Command(BaseCommand):
help = """
Writes health check jobs into /etc/lava-server/dispatcher-config/health-checks
using the existing database entry for the health check job
of the device-type. Optionally deletes the health check job
entry from the database as long as all devices of this type
are exclusive to V2.
If devices of one type extend different jinja templates, one
health check will be used for each variant."""
def add_arguments(self, parser):
parser.add_argument("--clean", action="store_true", default=False,
help="Remove from the database the health-checks that were moved")
def handle(self, *_, **options):
health_dir = "/etc/lava-server/dispatcher-config/health-checks"
self.stdout.write("Moving health checks to %s:" % health_dir)
# Create the directory
try:
os.mkdir(health_dir, 0o755)
except OSError as exc:
if exc.errno != errno.EEXIST:
self.stderr.write("Unable to create the directory: %s" % str(exc))
return
dt_skipped = []
extends_pattern = re.compile(r"^{% extends '([^.]+).jinja2' %}$")
for dt in DeviceType.objects.order_by('name'):
if not dt.health_check_job or not dt.display or is_device_type_retired(dt):
dt_skipped.append((dt.name, False))
continue
# Dump to the filesystem
self.stdout.write("* %s" % dt.name)
filename = os.path.join(health_dir, dt.name + '.yaml')
with open(filename, 'w') as f_out:
f_out.write(dt.health_check_job)
# Remove the health check from the data base (if needed)
if options["clean"]:
if is_device_type_exclusive(dt) or is_device_type_retired(dt) or not dt.display:
dt.health_check_job = None
dt.save(update_fields=["health_check_job"])
else:
self.stderr.write("-> Not cleaning %s, some devices still support V1" % dt.name)
self.stdout.write("Device types skipped:")
for (dt, has_health_check) in dt_skipped:
if has_health_check:
self.stdout.write("* %s (v1 health check)" % dt)
else:
self.stdout.write("* %s" % dt)
self.stdout.write("Checking devices:")
for device in Device.objects.exclude(status=Device.RETIRED).order_by('hostname'):
device_dict = device.load_configuration(output_format="raw")
if not device_dict:
self.stderr.write("* %s => no device dictionary" % device.hostname)
continue
extends = device.get_extends()
if not extends:
self.stderr.write("* %s => no 'extends' found" % device.hostname)
continue
filename = os.path.join("/etc/lava-server/dispatcher-config/health-checks",
"%s.yaml" % extends)
if os.path.exists(filename):
self.stdout.write("* %s => %s.yaml" % (device.hostname, extends))
else:
self.stderr.write("* %s => no health check found for %s.yaml" % (device.hostname, extends))
......@@ -106,7 +106,6 @@ class Command(BaseCommand):
raise CommandError("Unable to find worker '%s'" % hostname)
self.stdout.write("hostname : %s" % hostname)
self.stdout.write("master : %s" % worker.is_master)
self.stdout.write("display : %s" % worker.display)
self.stdout.write("description: %s" % worker.description)
if not print_devices:
......@@ -131,16 +130,12 @@ class Command(BaseCommand):
writer.writerow({
"hostname": worker.hostname,
"description": worker.description,
"master": worker.is_master,
"hidden": not worker.display,
"devices": worker.device_set.count()})
else:
self.stdout.write("Workers:")
for worker in workers:
string = "* %s (%d devices)"
if worker.is_master:
string += " (master)"
self.stdout.write(string % (worker.hostname, worker.device_set.count()))
self.stdout.write("* %s (%d devices)" % (worker.hostname, worker.device_set.count()))
def handle_set(self, hostname, description, display):
""" Set worker properties """
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment