コード例 #1
0
def display(request, oid):
    pm = helpers.PageManager(request,
                             'stweb/views/commands/display_command.html')

    node = pm.setVar('command', pm.object_store.getOID(oid))
    pm.render_var['parent'] = node.parent
    pm.render_var['attribute_list'] = attribute.parse_attributes(node)
    pm.path(node)
    return pm.render()
コード例 #2
0
ファイル: queue.py プロジェクト: tkuennen/siptrackweb
def display(request, oid):
    pm = helpers.PageManager(request, 'stweb/commands/display_queue.html')

    node = pm.setVar('queue', pm.object_store.getOID(oid))
    pm.render_var['parent'] = node.parent
    pm.render_var['attribute_list'] = attribute.parse_attributes(node)
    pm.render_var['command_list'] = node.listChildren(include = ['command'])
    pm.path(node)
    return pm.render()
コード例 #3
0
def delete_post(request, oid):
    pm = helpers.PageManager(
        request, 'stweb/views/networktrees/networks/delete_range.html')
    range = pm.object_store.getOID(oid)

    parent_oid = range.parent.oid
    range.delete()

    return pm.redirect('network.display', (parent_oid, ))
コード例 #4
0
ファイル: tree.py プロジェクト: tkuennen/siptrackweb
def index(request, parent_oid):
    pm = helpers.PageManager(request, 'stweb/views/networktrees/index.html')
    parent = pm.setVar('parent', pm.object_store.getOID(parent_oid))
    pm.path(parent)
    pm.section('network')

    pm.render_var['network_tree_list'] = list(
        parent.listChildren(include=['network tree']))
    return pm.render()
コード例 #5
0
def delete(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    device = pm.setVar('device', pm.object_store.getOID(oid))
    url = '/device/delete/post/%s/' % (device.oid)
    pm.addForm(DeleteForm(), url,
            'remove device', message = 'Removing device.')
    pm.path(device)

    return pm.render()
コード例 #6
0
def rack_unit_reserved(request, device_oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    device = pm.setVar('device', pm.object_store.getOID(device_oid))
    url = '/rack/unit/reserved/post/%s/' % (device.oid)
    pm.addForm(RackUnitReservedForm(), url,
               'rack unit reserved')
    pm.path(device)

    return pm.render()
コード例 #7
0
def disable(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    device = pm.setVar('device', pm.object_store.getOID(oid))
    url = '/device/disable/post/%s/' % (device.oid)
    pm.addForm(EmptyForm(), url,
            'disable device', message = 'Disabling device.')
    pm.path(device)

    return pm.render()
コード例 #8
0
def copy(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    device = pm.setVar('device', pm.object_store.getOID(oid))
    url = '/device/copy/post/%s/' % (device.oid)
    pm.addForm(DeviceCopyForm(), url,
            'copy device', message = 'Copying device.')
    pm.path(device)

    return pm.render()
コード例 #9
0
def add_with_target(request, oid):
    pm = helpers.PageManager(request, '')
    target = request.session.get('tagged_oid')
    device1 = pm.object_store.getOID(target)
    device2 = pm.object_store.getOID(oid)

    try:
        device1.associate(device2)
    except siptracklib.errors.SiptrackError, e:
        request.session['error_msg'] = 'association failed: %s' % (str(e))
コード例 #10
0
def delete_post(request, device_oid, network_oid):
    pm = helpers.PageManager(request, 'stweb/views/devices/networks/delete.html')
    device = pm.object_store.getOID(device_oid)
    pm.path(device)
    network = pm.object_store.getOID(network_oid)

    device.unlink(network)
    network.prune()

    return pm.redirect('device.display', (device.oid,))
コード例 #11
0
ファイル: config.py プロジェクト: tkuennen/siptrackweb
def submit(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    config = pm.setVar('config', pm.object_store.getOID(oid))
    url = '/device/config/submit/post/%s/' % (config.oid)
    pm.addForm(DeviceConfigSubmitForm(),
               url,
               'submit config',
               message='Submit configuration.')
    pm.path(config)
    return pm.render()
コード例 #12
0
ファイル: config.py プロジェクト: tkuennen/siptrackweb
def delete(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    config = pm.setVar('config', pm.object_store.getOID(oid))
    url = '/device/config/delete/post/%s/' % (config.oid)
    pm.addForm(DeleteForm(),
               url,
               'remove config',
               message='Removing configuration.')
    pm.path(config)
    return pm.render()
コード例 #13
0
def update(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')

    node = pm.setVar('command', pm.object_store.getOID(oid))
    form_data = {'freetext': node.freetext}
    url = '/command/update/post/%s/' % (node.oid)
    pm.addForm(CommandUpdateForm(form_data), url, 'update command')
    pm.render_var['parent'] = node.parent
    pm.path(node)
    return pm.render()
コード例 #14
0
ファイル: attribute.py プロジェクト: tkuennen/siptrackweb
def add_select(request, target_oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    target = pm.object_store.getOID(target_oid)
    pm.path(target)

    form = AttributeAddSelectTypeForm()
    path = '/attribute/add/set/%s/' % (target_oid)
    pm.addForm(form, path, 'add attribute')

    return pm.render()
コード例 #15
0
ファイル: template.py プロジェクト: tkuennen/siptrackweb
def rule_delete(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')

    rule = pm.object_store.getOID(oid)
    pm.addForm(DeleteForm(),
               '/template/rule/delete/post/%s/' % (oid),
               'remove template rule',
               message='Removing template rule.')
    pm.path(rule.parent)
    return pm.render()
コード例 #16
0
ファイル: specification.py プロジェクト: tkuennen/siptrackweb
def display(request, oid):
    pm = helpers.PageManager(
        request, 'stweb/views/devices/specifications/display.html')
    spec = pm.setVar('device_spec', pm.object_store.getOID(oid))
    pm.path(spec)

    pm.render_var['device_spec_combined_rule_list'] = spec.combinedRules()
    pm.render_var['device_spec_rule_list'] = spec.listChildren(
        include=['device specification rule'])
    return pm.render()
コード例 #17
0
ファイル: trigger.py プロジェクト: tkuennen/siptrackweb
def delete(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')

    node = pm.setVar('trigger', pm.object_store.getOID(oid))
    pm.addForm(DeleteForm(),
               '/event/trigger/delete/post/%s/' % (node.oid),
               'remove event trigger',
               message='Removing event trigger.')
    pm.path(node)
    return pm.render()
コード例 #18
0
ファイル: specification.py プロジェクト: tkuennen/siptrackweb
def delete_post(request, oid):
    pm = helpers.PageManager(request,
                             'stweb/views/devices/specifications/delete.html')
    spec = pm.setVar('device_spec', pm.object_store.getOID(oid))
    pm.path(spec)

    parent = spec.parent
    spec.delete()

    return pm.redirect('device.display', (parent.oid, ))
コード例 #19
0
ファイル: trigger.py プロジェクト: tkuennen/siptrackweb
def display(request, oid):
    pm = helpers.PageManager(request, 'stweb/events/display_trigger.html')

    node = pm.setVar('trigger', pm.object_store.getOID(oid))
    pm.render_var['parent'] = node.parent
    pm.render_var['attribute_list'] = attribute.parse_attributes(node)
    pm.render_var['python_rule_list'] = node.listChildren(
        include=['event trigger rule python'])
    pm.path(node)
    return pm.render()
コード例 #20
0
ファイル: trigger.py プロジェクト: tkuennen/siptrackweb
def update(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')

    node = pm.setVar('trigger', pm.object_store.getOID(oid))
    form_data = {'name': node.attributes.get('name', '')}
    url = '/event/trigger/update/post/%s/' % (node.oid)
    pm.addForm(EventTriggerUpdateForm(form_data), url, 'update event trigger')
    pm.render_var['parent'] = node.parent
    pm.path(node)
    return pm.render()
コード例 #21
0
ファイル: network.py プロジェクト: tkuennen/siptrackweb
def add(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    device = pm.setVar('device', pm.object_store.getOID(oid))
    pm.path(device)
    view = device.getParent('view')
    network_trees = view.listChildren(include=['network tree'])

    url = '/device/network/add/post/%s/' % (oid)
    pm.addForm(DeviceNetworkAddForm(network_trees), url)
    return pm.render()
コード例 #22
0
def add_post(request, target_oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    target = pm.object_store.getOID(target_oid)
    pm.path(target)

    ruletype = request.POST.get('ruletype', '')
    path = '/attribute/add/post/%s/' % (target_oid)
    if ruletype == 'text':
        form = AttributeAddTextForm(request.POST)
    elif ruletype == 'bool':
        form = AttributeAddBoolForm(request.POST)
    elif ruletype == 'int':
        form = AttributeAddIntForm(request.POST)
    else:
        return pm.error('bad, invalid ruletype')
    pm.addForm(form, path, 'add attribute')
    if not form.is_valid():
        return pm.error('')

    attr_name = form.cleaned_data['name']
    if ruletype == 'text':
        attr_value = form.cleaned_data['value']
        if form.cleaned_data['versions'] == 1:
            attr = target.add('attribute', attr_name, 'text', attr_value)
        else:
            attr = target.add('versioned attribute', attr_name, 'text',
                              attr_value, form.cleaned_data['versions'])
    elif ruletype == 'bool':
        attr_value = form.cleaned_data['value']
        if attr_value == 'true':
            attr_value = True
        else:
            attr_value = False
        if form.cleaned_data['versions'] == 1:
            attr = target.add('attribute', attr_name, 'bool', attr_value)
        else:
            attr = target.add('versioned attribute', attr_name, 'bool',
                              attr_value, form.cleaned_data['versions'])
    if ruletype == 'int':
        attr_value = form.cleaned_data['value']
        if form.cleaned_data['versions'] == 1:
            attr = target.add('attribute', attr_name, 'int', attr_value)
        else:
            attr = target.add('versioned attribute', attr_name, 'int',
                              attr_value, form.cleaned_data['versions'])
    if form.cleaned_data.get('wikitext', False):
        attr.attributes['wikitext'] = True
    if form.cleaned_data.get('large', False):
        attr.attributes['large'] = True
    if form.cleaned_data.get('hidden', False):
        attr.attributes['hidden'] = True
    if form.cleaned_data.get('important', False):
        attr.attributes['important'] = True

    return pm.redirect('display.display', (target_oid, ))
コード例 #23
0
def edit_notes(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    target = pm.setVar('target', pm.object_store.getOID(oid))
    url = '/attribute/notes/post/%s/' % (target.oid)
    pm.addForm(AttributeEditNotesForm(
        initial={'notes': target.attributes.get('Notes', '')}),
               url,
               'edit notes',
               message='')
    pm.path(target)
    return pm.render()
コード例 #24
0
ファイル: attribute.py プロジェクト: tkuennen/siptrackweb
def quickedit_post(request, oid, attr_name):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    target = pm.setVar('target', pm.object_store.getOID(oid))
    pm.path(target)
    url = '/attribute/quickedit/%s/post/%s/' % (attr_name, target.oid)
    pm.addForm(AttributeQuickeditForm(request.POST), url,
               'Edit %s' % attr_name, message = '')
    if not pm.form.is_valid():
        return pm.render()
    target.attributes[attr_name] = pm.form.cleaned_data['value']
    return pm.redirect('display.display', (oid,))
コード例 #25
0
def autoassign_post(request, oid):
    pm = helpers.PageManager(request, 'stweb/views/devices/networks/autoassign.html')
    device = pm.setVar('device', pm.object_store.getOID(oid))
    pm.path(device)

    network = device.autoassignNetwork()
    if len(device.listNetworks()) > 0:
        network.attributes['secondary'] = True
    request.session['assigned network'] = network.oid

    return pm.redirect('device.display', (device.oid,))
コード例 #26
0
ファイル: tree.py プロジェクト: tkuennen/siptrackweb
def add(request, parent_oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    parent = pm.setVar('parent', pm.object_store.getOID(parent_oid))
    pm.path(parent)
    pm.section('network')

    pm.render_var['network_tree_list'] = parent.listChildren(
        include=['network tree'])
    pm.addForm(NetworkTreeAddForm(),
               '/networktree/add/post/%s/' % (parent_oid))
    return pm.render()
コード例 #27
0
ファイル: queue.py プロジェクト: tkuennen/siptrackweb
def delete_post(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    node = pm.object_store.getOID(oid)
    parent_oid = node.parent.oid
    pm.addForm(DeleteForm(request.POST), '/command/queue/delete/post/%s/' % (node.oid),
            'remove command', message = 'Removing command.')
    if not pm.form.is_valid():
        return pm.render()
    node.delete()

    return pm.redirect('display.display', (parent_oid,))
コード例 #28
0
ファイル: tree.py プロジェクト: tkuennen/siptrackweb
def delete_post(request, oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    pm.addForm(DeleteForm(request.POST),
               '/networktree/delete/post/%s/' % (oid),
               message='Removing network tree.')
    pm.section('network')
    nt = pm.object_store.getOID(oid)
    parent_oid = nt.parent.oid
    nt.delete()

    return pm.redirect('network.tree.index', (parent_oid, ))
コード例 #29
0
ファイル: attribute.py プロジェクト: Major81/siptrackweb
def quickedit(request, oid, attr_name):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    target = pm.setVar('target', pm.object_store.getOID(oid))
    url = '/attribute/quickedit/%s/post/%s/' % (attr_name, target.oid)
    pm.addForm(AttributeQuickeditForm(
        initial={'value': target.attributes.get(attr_name, '')}),
               url,
               'Edit %s' % attr_name,
               message='')
    pm.path(target)
    return pm.render()
コード例 #30
0
def add(request, parent_oid):
    pm = helpers.PageManager(request, 'stweb/generic_form.html')
    network = pm.object_store.getOID(parent_oid)
    network_tree = network.getNetworkTree()
    pm.render_var['network_tree_list'] = network_tree.parent.listChildren(
        include=['network tree'])

    pm.render_var['network_tree'] = network_tree
    pm.render_var['network'] = network
    pm.addForm(NetworkAddForm(), '/network/add/post/%s/' % (parent_oid))
    pm.path(network)
    return pm.render()