Ejemplo n.º 1
0
    def ticket(self, support, alerts):
        node = alert_node()
        dismisseds = [a.message_id
                      for a in mAlert.objects.filter(dismiss=True, node=node)]
        msgs = []
        for alert in alerts:
            if alert.getId() not in dismisseds:
                msgs.append(str(alert).encode('utf8'))
        if len(msgs) == 0:
            return

        serial = subprocess.Popen(
            ['/usr/local/sbin/dmidecode', '-s', 'system-serial-number'],
            stdout=subprocess.PIPE,
            encoding='utf8',
        ).communicate()[0].split('\n')[0].upper()

        license, reason = get_license()
        if license:
            company = license.customer_name
        else:
            company = 'Unknown'

        for name, verbose_name in (
            ('name', 'Contact Name'),
            ('title', 'Contact Title'),
            ('email', 'Contact E-mail'),
            ('phone', 'Contact Phone'),
            ('secondary_name', 'Secondary Contact Name'),
            ('secondary_title', 'Secondary Contact Title'),
            ('secondary_email', 'Secondary Contact E-mail'),
            ('secondary_phone', 'Secondary Contact Phone'),
        ):
            value = getattr(support, name)
            if value:
                msgs += ['', '{}: {}'.format(verbose_name, value)]

        success, msg, ticketnum = new_ticket({
            'title': 'Automatic alert (%s)' % serial,
            'body': '\n'.join(msgs),
            'version': get_sw_version().split('-', 1)[-1],
            'debug': False,
            'company': company,
            'serial': serial,
            'department': 20,
            'category': 'Hardware',
            'criticality': 'Loss of Functionality',
            'environment': 'Production',
            'name': 'Automatic Alert',
            'email': '*****@*****.**',
            'phone': '-',
        })
        if not success:
            log.error("Failed to create a support ticket: %s", msg)
        else:
            log.debug("Automatic alert ticket successfully created: %s", msg)
Ejemplo n.º 2
0
    def ticket(self, alerts):
        node = alert_node()
        dismisseds = [a.message_id
                      for a in mAlert.objects.filter(dismiss=True, node=node)]
        msgs = []
        for alert in alerts:
            if alert.getId() not in dismisseds:
                msgs.append(unicode(alert).encode('utf8'))
        if len(msgs) == 0:
            return

        serial = subprocess.Popen(
            ['/usr/local/sbin/dmidecode', '-s', 'system-serial-number'],
            stdout=subprocess.PIPE
        ).communicate()[0].split('\n')[0].upper()

        license, reason = get_license()
        if license:
            company = license.customer_name
        else:
            company = 'Unknown'

        success, msg, ticketnum = new_ticket({
            'title': 'Automatic alert (%s)' % serial,
            'body': '\n'.join(msgs),
            'version': get_sw_version().split('-', 1)[-1],
            'debug': False,
            'company': company,
            'serial': serial,
            'department': 20,
            'category': 'Hardware',
            'criticality': 'Loss of Functionality',
            'environment': 'Production',
            'name': 'Automatic Alert',
            'email': '*****@*****.**',
            'phone': '-',
        })
        if not success:
            log.error("Failed to create a support ticket: %s", msg)
        else:
            log.debug("Automatic alert ticket successfully created: %s", msg)
Ejemplo n.º 3
0
def ticket(request):

    step = 2 if request.FILES.getlist('attachment') else 1

    files = []
    if request.POST.get('debug') == 'on':
        debug = True
        with open(TICKET_PROGRESS, 'w') as f:
            f.write(json.dumps({'indeterminate': True, 'step': step}))
        step += 1

        mntpt, direc, dump = debug_get_settings()
        debug_run(direc)
        files.append(File(open(dump, 'rb'), name=os.path.basename(dump)))
    else:
        debug = False

    with open(TICKET_PROGRESS, 'w') as f:
        f.write(json.dumps({'indeterminate': True, 'step': step}))
    step += 1

    data = {
        'title': request.POST.get('subject'),
        'body': request.POST.get('desc'),
        'version': get_sw_version().split('-', 1)[-1],
        'category': request.POST.get('category'),
        'debug': debug,
    }

    if get_sw_name().lower() == 'freenas':
        data.update({
            'user': request.POST.get('username'),
            'password': request.POST.get('password'),
            'type': request.POST.get('type'),
        })
    else:

        serial = subprocess.Popen(
            ['/usr/local/sbin/dmidecode', '-s', 'system-serial-number'],
            stdout=subprocess.PIPE
        ).communicate()[0].split('\n')[0].upper()

        license, reason = utils.get_license()
        if license:
            company = license.customer_name
        else:
            company = 'Unknown'

        data.update({
            'phone': request.POST.get('phone'),
            'name': request.POST.get('name'),
            'company': company,
            'email': request.POST.get('email'),
            'criticality': request.POST.get('criticality'),
            'environment': request.POST.get('environment'),
            'serial': serial,
        })

    success, msg, tid = utils.new_ticket(data)

    with open(TICKET_PROGRESS, 'w') as f:
        f.write(json.dumps({'indeterminate': True, 'step': step}))
    step += 1

    data = {'message': msg, 'error': not success}

    if not success:
        pass
    else:

        files.extend(request.FILES.getlist('attachment'))
        for f in files:
            success, attachmsg = utils.ticket_attach({
                'user': request.POST.get('username'),
                'password': request.POST.get('password'),
                'ticketnum': tid,
            }, f)

    data = (
        '<html><body><textarea>%s</textarea></boby></html>' % (
            json.dumps(data),
        )
    )
    return HttpResponse(data)
Ejemplo n.º 4
0
def ticket(request):

    step = 2 if request.FILES.getlist('attachment') else 1

    files = []
    if request.POST.get('debug') == 'on':
        debug = True
        with open(TICKET_PROGRESS, 'w') as f:
            f.write(json.dumps({'indeterminate': True, 'step': step}))
        step += 1

        mntpt, direc, dump = debug_get_settings()
        debug_run(direc)
        files.append(File(open(dump, 'rb'), name=os.path.basename(dump)))
    else:
        debug = False

    with open(TICKET_PROGRESS, 'w') as f:
        f.write(json.dumps({'indeterminate': True, 'step': step}))
    step += 1

    data = {
        'title': request.POST.get('subject'),
        'body': request.POST.get('desc'),
        'version': get_sw_version().split('-', 1)[-1],
        'category': request.POST.get('category'),
        'debug': debug,
    }

    if get_sw_name().lower() == 'freenas':
        data.update({
            'user': request.POST.get('username'),
            'password': request.POST.get('password'),
            'type': request.POST.get('type'),
        })
    else:

        serial = subprocess.Popen(
            ['/usr/local/sbin/dmidecode', '-s', 'system-serial-number'],
            stdout=subprocess.PIPE).communicate()[0].split('\n')[0].upper()

        license, reason = utils.get_license()
        if license:
            company = license.customer_name
        else:
            company = 'Unknown'

        data.update({
            'phone': request.POST.get('phone'),
            'name': request.POST.get('name'),
            'company': company,
            'email': request.POST.get('email'),
            'criticality': request.POST.get('criticality'),
            'environment': request.POST.get('environment'),
            'serial': serial,
        })

    success, msg, tid = utils.new_ticket(data)

    with open(TICKET_PROGRESS, 'w') as f:
        f.write(json.dumps({'indeterminate': True, 'step': step}))
    step += 1

    data = {'message': msg, 'error': not success}

    if not success:
        pass
    else:

        files.extend(request.FILES.getlist('attachment'))
        for f in files:
            success, attachmsg = utils.ticket_attach(
                {
                    'user': request.POST.get('username'),
                    'password': request.POST.get('password'),
                    'ticketnum': tid,
                }, f)

    data = ('<html><body><textarea>%s</textarea></boby></html>' %
            (json.dumps(data), ))
    return HttpResponse(data)
Ejemplo n.º 5
0
def ticket(request):

    step = 2 if request.FILES.getlist('attachment') else 1

    files = []
    if request.POST.get('debug') == 'on':
        debug = True
        with open(TICKET_PROGRESS, 'w') as f:
            f.write(json.dumps({'indeterminate': True, 'step': step}))
        step += 1

        mntpt, direc, dump = debug_get_settings()
        debug_generate()

        _n = notifier()
        if not _n.is_freenas() and _n.failover_licensed():
            debug_file = '%s/debug.tar' % direc
            debug_name = 'debug-%s.tar' % time.strftime('%Y%m%d%H%M%S')
        else:
            gc = GlobalConfiguration.objects.all().order_by('-id')[0]
            debug_file = dump
            debug_name = 'debug-%s-%s.txz' % (
                gc.gc_hostname.encode('utf-8'),
                time.strftime('%Y%m%d%H%M%S'),
            )

        files.append(File(open(debug_file, 'rb'), name=debug_name))
    else:
        debug = False

    with open(TICKET_PROGRESS, 'w') as f:
        f.write(json.dumps({'indeterminate': True, 'step': step}))
    step += 1

    data = {
        'title': request.POST.get('subject'),
        'body': request.POST.get('desc'),
        'version': get_sw_version().split('-', 1)[-1],
        'category': request.POST.get('category'),
        'debug': debug,
    }

    if get_sw_name().lower() == 'freenas':
        data.update({
            'user': request.POST.get('username'),
            'password': request.POST.get('password'),
            'type': request.POST.get('type'),
        })
    else:

        serial = subprocess.Popen(
            ['/usr/local/sbin/dmidecode', '-s', 'system-serial-number'],
            stdout=subprocess.PIPE).communicate()[0].split('\n')[0].upper()

        license, reason = utils.get_license()
        if license:
            company = license.customer_name
        else:
            company = 'Unknown'

        data.update({
            'phone': request.POST.get('phone'),
            'name': request.POST.get('name'),
            'company': company,
            'email': request.POST.get('email'),
            'criticality': request.POST.get('criticality'),
            'environment': request.POST.get('environment'),
            'serial': serial,
        })

    success, msg, tid = utils.new_ticket(data)

    with open(TICKET_PROGRESS, 'w') as f:
        f.write(json.dumps({'indeterminate': True, 'step': step}))
    step += 1

    data = {'message': msg, 'error': not success}

    if not success:
        pass
    else:

        files.extend(request.FILES.getlist('attachment'))
        for f in files:
            success, attachmsg = utils.ticket_attach(
                {
                    'user': request.POST.get('username'),
                    'password': request.POST.get('password'),
                    'ticketnum': tid,
                }, f)

    data = ('<html><body><textarea>%s</textarea></boby></html>' %
            (json.dumps(data), ))
    return HttpResponse(data)
Ejemplo n.º 6
0
    def ticket(self, alerts):
        node = alert_node()
        dismisseds = [
            a.message_id
            for a in mAlert.objects.filter(dismiss=True, node=node)
        ]
        msgs = []
        for alert in alerts:
            if alert.getId() not in dismisseds:
                msgs.append(unicode(alert).encode('utf8'))
        if len(msgs) == 0:
            return

        serial = subprocess.Popen(
            ['/usr/local/sbin/dmidecode', '-s', 'system-serial-number'],
            stdout=subprocess.PIPE).communicate()[0].split('\n')[0].upper()

        license, reason = get_license()
        if license:
            company = license.customer_name
        else:
            company = 'Unknown'

        adv = Advanced.objects.order_by('-id')[0]
        if adv.adv_ixfailsafe_email:
            msgs += [
                '',
                'Failsafe Support Contact: {}'.format(adv.adv_ixfailsafe_email)
            ]

        success, msg, ticketnum = new_ticket({
            'title':
            'Automatic alert (%s)' % serial,
            'body':
            '\n'.join(msgs),
            'version':
            get_sw_version().split('-', 1)[-1],
            'debug':
            False,
            'company':
            company,
            'serial':
            serial,
            'department':
            20,
            'category':
            'Hardware',
            'criticality':
            'Loss of Functionality',
            'environment':
            'Production',
            'name':
            'Automatic Alert',
            'email':
            '*****@*****.**',
            'phone':
            '-',
        })
        if not success:
            log.error("Failed to create a support ticket: %s", msg)
        else:
            log.debug("Automatic alert ticket successfully created: %s", msg)
Ejemplo n.º 7
0
def ticket(request):

    step = 2 if request.FILES.getlist("attachment") else 1

    files = []
    if request.POST.get("debug") == "on":
        debug = True
        with open(TICKET_PROGRESS, "w") as f:
            f.write(json.dumps({"indeterminate": True, "step": step}))
        step += 1

        mntpt, direc, dump = debug_get_settings()
        debug_run(direc)
        files.append(File(open(dump, "rb"), name=os.path.basename(dump)))
    else:
        debug = False

    with open(TICKET_PROGRESS, "w") as f:
        f.write(json.dumps({"indeterminate": True, "step": step}))
    step += 1

    data = {
        "title": request.POST.get("subject"),
        "body": request.POST.get("desc"),
        "version": get_sw_version().split("-", 1)[-1],
        "category": request.POST.get("category"),
        "debug": debug,
    }

    if get_sw_name().lower() == "freenas":
        data.update(
            {
                "user": request.POST.get("username"),
                "password": request.POST.get("password"),
                "type": request.POST.get("type"),
            }
        )
    else:

        serial = (
            subprocess.Popen(["/usr/local/sbin/dmidecode", "-s", "system-serial-number"], stdout=subprocess.PIPE)
            .communicate()[0]
            .split("\n")[0]
            .upper()
        )

        license, reason = utils.get_license()
        if license:
            company = license.customer_name
        else:
            company = "Unknown"

        data.update(
            {
                "phone": request.POST.get("phone"),
                "name": request.POST.get("name"),
                "company": company,
                "email": request.POST.get("email"),
                "criticality": request.POST.get("criticality"),
                "environment": request.POST.get("environment"),
                "serial": serial,
            }
        )

    success, msg, tid = utils.new_ticket(data)

    with open(TICKET_PROGRESS, "w") as f:
        f.write(json.dumps({"indeterminate": True, "step": step}))
    step += 1

    data = {"message": msg, "error": not success}

    if not success:
        pass
    else:

        files.extend(request.FILES.getlist("attachment"))
        for f in files:
            success, attachmsg = utils.ticket_attach(
                {"user": request.POST.get("username"), "password": request.POST.get("password"), "ticketnum": tid}, f
            )

    data = "<html><body><textarea>%s</textarea></boby></html>" % (json.dumps(data),)
    return HttpResponse(data)
Ejemplo n.º 8
0
def ticket(request):
    if request.method == 'POST':

        step = 2 if request.FILES.getlist('attachment') else 1

        files = []
        if request.POST.get('debug') == 'on':
            with open(TICKET_PROGRESS, 'w') as f:
                f.write(json.dumps({'indeterminate': True, 'step': step}))
            step += 1

            mntpt, direc, dump = debug_get_settings()
            debug_run(direc)
            files.append(File(open(dump, 'rb'), name=os.path.basename(dump)))

        with open(TICKET_PROGRESS, 'w') as f:
            f.write(json.dumps({'indeterminate': True, 'step': step}))
        step += 1

        success, msg, tid = utils.new_ticket({
            'user':
            request.POST.get('username'),
            'password':
            request.POST.get('password'),
            'type':
            request.POST.get('type'),
            'title':
            request.POST.get('subject'),
            'body':
            request.POST.get('desc'),
            'version':
            get_sw_login_version(),
        })

        with open(TICKET_PROGRESS, 'w') as f:
            f.write(json.dumps({'indeterminate': True, 'step': step}))
        step += 1

        if not success:
            response = render(request, 'support/ticket.html', {
                'error_message': msg,
                'initial': json.dumps(request.POST.dict()),
            })
        else:

            files.extend(request.FILES.getlist('attachment'))
            for f in files:
                success, attachmsg = utils.ticket_attach(
                    {
                        'user': request.POST.get('username'),
                        'password': request.POST.get('password'),
                        'ticketnum': tid,
                    }, f)

            response = render(request, 'support/ticket_response.html', {
                'success': success,
                'message': msg,
            })
        if not request.is_ajax():
            response.content = (
                '<html><body><textarea>%s</textarea></boby></html>' %
                (response.content, ))
        return response
    return render(request, 'support/ticket.html')
Ejemplo n.º 9
0
def ticket(request):

    step = 2 if request.FILES.getlist('attachment') else 1

    files = []
    if request.POST.get('debug') == 'on':
        debug = True
        with open(TICKET_PROGRESS, 'w') as f:
            f.write(json.dumps({'indeterminate': True, 'step': step}))
        step += 1

        mntpt, direc, dump = debug_get_settings()
        debug_generate()

        _n = notifier()
        if not _n.is_freenas() and _n.failover_licensed():
            debug_file = '%s/debug.tar' % direc
            debug_name = 'debug-%s.tar' % time.strftime('%Y%m%d%H%M%S')
        else:
            gc = GlobalConfiguration.objects.all().order_by('-id')[0]
            debug_file = dump
            debug_name = 'debug-%s-%s.txz' % (
                gc.gc_hostname.encode('utf-8'),
                time.strftime('%Y%m%d%H%M%S'),
            )

        files.append(File(open(debug_file, 'rb'), name=debug_name))
    else:
        debug = False

    with open(TICKET_PROGRESS, 'w') as f:
        f.write(json.dumps({'indeterminate': True, 'step': step}))
    step += 1

    data = {
        'title': request.POST.get('subject'),
        'body': request.POST.get('desc'),
        'version': get_sw_version().split('-', 1)[-1],
        'category': request.POST.get('category'),
        'debug': debug,
    }

    if get_sw_name().lower() == 'freenas':
        data.update({
            'user': request.POST.get('username'),
            'password': request.POST.get('password'),
            'type': request.POST.get('type'),
        })
    else:

        serial = subprocess.Popen(
            ['/usr/local/sbin/dmidecode', '-s', 'system-serial-number'],
            stdout=subprocess.PIPE
        ).communicate()[0].split('\n')[0].upper()

        license, reason = utils.get_license()
        if license:
            company = license.customer_name
        else:
            company = 'Unknown'

        data.update({
            'phone': request.POST.get('phone'),
            'name': request.POST.get('name'),
            'company': company,
            'email': request.POST.get('email'),
            'criticality': request.POST.get('criticality'),
            'environment': request.POST.get('environment'),
            'serial': serial,
        })

    success, msg, tid = utils.new_ticket(data)

    with open(TICKET_PROGRESS, 'w') as f:
        f.write(json.dumps({'indeterminate': True, 'step': step}))
    step += 1

    data = {'message': msg, 'error': not success}

    if not success:
        pass
    else:

        files.extend(request.FILES.getlist('attachment'))
        for f in files:
            success, attachmsg = utils.ticket_attach({
                'user': request.POST.get('username'),
                'password': request.POST.get('password'),
                'ticketnum': tid,
            }, f)

    data = (
        '<html><body><textarea>%s</textarea></boby></html>' % (
            json.dumps(data),
        )
    )
    return HttpResponse(data)