Skip to content
Snippets Groups Projects
Commit 1a2f3786 authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Add extra default device types

- rename "Virtual" to "Virtual Machine"
- add "Virtual IOC"
- add several physical devices (Switch, Industrial PC IOC, MicroTCA,
  VME, PLC)
parent c96083b7
No related branches found
No related tags found
No related merge requests found
......@@ -21,5 +21,14 @@ defaults = [
models.Action(name='Set as parent'),
models.Action(name='Update'),
models.DeviceType(name='Physical'),
models.DeviceType(name='Virtual Machine'),
models.DeviceType(name='Switch'),
models.DeviceType(name='Virtual IOC'),
models.DeviceType(name='Industrial PC IOC'),
models.DeviceType(name='MicroTCA IOC'),
models.DeviceType(name='VME IOC'),
models.DeviceType(name='PLC'),
models.Tag(name='gateway', admin_only=True),
]
......@@ -111,7 +111,7 @@ def edit_host(name):
@login_groups_accepted('admin', 'create')
def create_interface(hostname):
host = models.Host.query.filter_by(name=hostname).first_or_404()
random_mac = host.device_type.name == 'Virtual'
random_mac = host.device_type.name.startsWith('Virtual')
form = InterfaceForm(request.form, host_id=host.id, interface_name=host.name,
random_mac=random_mac)
if form.validate_on_submit():
......
......@@ -15,10 +15,10 @@ $(document).ready(function() {
// And check / uncheck random_mac checkbox
function update_device_type_attributes() {
var device_type = $("#device_type_id option:selected").text();
if( device_type.startsWith("Physical") ) {
$("#random_mac").prop("checked", false).change();
} else {
if( device_type.startsWith("Virtual") ) {
$("#random_mac").prop("checked", true).change();
} else {
$("#random_mac").prop("checked", false).change();
}
}
......
"""Rename Virtual device type
Revision ID: 8f135d5efde2
Revises: 573560351033
Create Date: 2018-04-23 07:43:43.195703
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8f135d5efde2'
down_revision = '573560351033'
branch_labels = None
depends_on = None
def upgrade():
device_type = sa.sql.table('device_type', sa.sql.column('id'), sa.sql.column('name'))
op.execute(device_type.update().where(device_type.c.name == 'Virtual').values(name='Virtual Machine'))
def downgrade():
device_type = sa.sql.table('device_type', sa.sql.column('id'), sa.sql.column('name'))
op.execute(device_type.update().where(device_type.c.name == 'Virtual Machine').values(name='Virtual'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment