Esempio n. 1
0
    def generateSysdump(self):
        fields = self.request().fields()
        if 'genSysdump' in fields:
            # Brief sysdumps are the sysdumps that are included in process dump
            # tarballs.  There's no good reason to allow a user to create one
            # manually, so we always create a full sysdump.  The user can still
            # create a brief sysdump from the CLI if they really want to.
            params = [('brief', 'bool', 'false')]

            if 'includeStats' in fields:
                params.append(('stats', 'bool', 'true'))

            if 'includeAllLogs' in fields:
                params.append(('all_logs', 'bool', 'true'))

            # The meaning of the 'rsp' option is flipped between Steelhead and
            # BOB.  For Steelhead, a value of "true" means "yes, include RSP in
            # the sysdump"; for BOB, a value of "true" means "no, don't include
            # ESXi in the sysdump".
            if ((not RVBDUtils.isBOB() and 'includeRsp' in fields) or
                (RVBDUtils.isBOB() and 'includeRsp' not in fields)):
                params.append(('rsp', 'bool', 'true'))

            response = self.sendAction('/debug/generate/dump', *params)

            msg = "System dump requested."
            if hasattr(response, 'keys') and 'dump_path' in response.keys():
                msg = '%s has been generated.' % response['dump_path'].split('/')[-1]

            self.setActionMessage(msg)
Esempio n. 2
0
    def tcpDumpsRunning(self):
        result = self.doc.createElement('tcp-dumps-running')
        self.doc.documentElement.appendChild(result)

        allCaptures = []

        # Look for all the running RiOS captures.
        riosCaptures = Nodes.getMgmtSetEntries(self.mgmt, '/rbt/tcpdump/state/capture')
        for name in riosCaptures:
            allCaptures.append((name, 'RiOS', riosCaptures[name]['start']))

        # Look for all the running hypervisor captures (for BOB).
        if RVBDUtils.isBOB():
            hostCaptures = Nodes.getMgmtSetEntries(self.mgmt, '/host/tcpdump/state/capture')
            for name in hostCaptures:
                allCaptures.append((name, 'Hypervisor', hostCaptures[name]['start']))

        # Sort by the capture name (which is basically a timestamp).
        allCaptures.sort(key=lambda x: x[0])

        for capture in allCaptures:
            dumpEl = self.doc.createElement('tcp-dump')
            result.appendChild(dumpEl)
            dumpEl.setAttribute('name', capture[0])
            dumpEl.setAttribute('runningOn', capture[1])
            dumpEl.setAttribute('start', capture[2])
            dumpEl.setAttribute('internalName', '%s/%s' % (capture[0], capture[1]))

        self.writeXmlDoc()
Esempio n. 3
0
    def tcpDumps(self):
        # dump capture files table on top
        if 'removeFiles' in self.fields:
            self.removeDiagnosticFile()

        # running tcp dumps table below:
        elif 'addTcpDump' in self.fields:
            ifaces = FormUtils.getPrefixedFieldNames('iface_', self.fields)

            # We need to handle RiOS interfaces and host interfaces (BOB boxes).
            riosIfaces = []
            hostIfaces = []
            for iface in ifaces:
                if iface == 'All':
                    pass
                elif iface.startswith('host_'):
                    hostIfaces.append(iface[5:])
                else:
                    riosIfaces.append(iface)

            name = self.fields.get('addDump_captureName', '').strip()
            bufferSize = self.fields.get('addDump_bufferSize')
            snapLength = self.fields.get('addDump_snapLength')
            rotateCount = self.fields.get('addDump_rotation', '0')
            fileSize = self.fields.get('addDump_captureMax', '0')
            duration = self.fields.get('addDump_captureDuration', '0')
            flags = self.fields.get('addDump_flags', '')
            vlan = self.fields.get('addDump_vlanEnable')

            # for the ip and port fields, parse the comma-delimited list
            # return an empty list for the default cases
            def listOrEmpty(name):
                val = self.fields.get(name, '').strip().lower()
                if val in ('', 'all', '0.0.0.0', '0'):
                    return []
                return map(str.strip, val.split(','))

            sched = self.fields.get('addDump_schedule')

            args = [('rotate_count', 'uint32', rotateCount),
                    ('custom', 'string', flags)] + \
                   [('sip', 'ipv4addr', si) for si in listOrEmpty('addDump_srcIps')] + \
                   [('sport', 'uint16', sp) for sp in listOrEmpty('addDump_srcPorts')] + \
                   [('dip', 'ipv4addr', di) for di in listOrEmpty('addDump_dstIps')] + \
                   [('dport', 'uint16', dp) for dp in listOrEmpty('addDump_dstPorts')]

            if '0' != duration:
                args.append(('duration', 'duration_sec', duration))

            if '0' != fileSize:
                args.append(('file_size', 'uint32', fileSize))

            if bufferSize:
                args.append(('buffer_size', 'uint32', bufferSize))

            if snapLength:
                args.append(('snap_len', 'uint32', snapLength))

            if name:
                args.append(('cap_name', 'string', name))

            if 'true' == vlan:
                args.append(('dot1q', 'bool', 'true'))

            if 'true' == sched:
                schedDate = self.fields.get('addDump_scheduleDate', '')
                schedTime = self.fields.get('addDump_scheduleTime', '')
                args.append(('sched_date', 'date', schedDate))
                args.append(('sched_time', 'time_sec', schedTime))

            if riosIfaces:
                riosArgs = list(args)
                riosArgs += [('interface', 'string', iface) for iface in riosIfaces]
                self.sendAction('/rbt/tcpdump/action/start', *riosArgs)

            if hostIfaces:
                hostArgs = list(args)
                hostArgs += [('interface', 'string', iface) for iface in hostIfaces]
                self.sendAction('/host/tcpdump/action/start', *hostArgs)

            if not riosIfaces and not hostIfaces:
                self.setFormError('An interface must be selected.')

        elif 'removeTcpCaptures':
            captures = FormUtils.getPrefixedFieldNames('select_', self.fields)
            riosCaptures = Nodes.getMgmtLocalChildrenNames(self.mgmt, '/rbt/tcpdump/state/capture')
            if RVBDUtils.isBOB():
                hostCaptures = Nodes.getMgmtLocalChildrenNames(self.mgmt, '/host/tcpdump/state/capture')

            for capture in captures:
                name, runningOn = capture.split('/')

                # it could have finished while the user was admiring the page
                if runningOn == 'RiOS' and name in riosCaptures:
                    self.sendAction('/rbt/tcpdump/action/stop',
                                    ('cap_name', 'string', name))
                elif runningOn == 'Hypervisor' and name in hostCaptures:
                    self.sendAction('/host/tcpdump/action/stop',
                                    ('cap_name', 'string', name))
Esempio n. 4
0
    'tcpdump': {
        'dir': '/var/opt/tms/tcpdumps',
        'rbaNode': '/rbm_fake/debug/generate/tcpdump',
        'mode': 'binary',
    }
}

if RVBDUtils.isRspSupported():
    import rsp
    _TARGETS['rspbackup'] = {
        'dir': rsp.rsp_backupdir,
        'rbaNode': '/rbt/rsp2/action/backup/create',
        'mode': 'binary'
    }

if RVBDUtils.isBOB():
    import rsp3
    _TARGETS['rsp3backup'] = {
        'dir': rsp3.rsp_backupdir,
        'rbaNode': '/rbt/rsp3/action/backup/create',
        'mode': 'binary'
    }


## Transfer a file to the client/browser.
#
# This handles the basic case where we have a file on the disk that we
# want to send to the user.  Input sanitization and RBA checks are
# performed by this class.  The file is returned through the following
# URL:
#