Example #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)
Example #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()
    def monitoredPorts(self):
        base = RVBDUtils.monitoredPortsPath(self.fields)

        portMap = Nodes.getMgmtTabularSubtree(self.mgmt, base, Nodes.parentKeyStringIntCmp)
        result = self.doc.createElement('monitoredPorts')
        for eachPort in portMap:
            portEl = self.doc.createElement('port')
            portEl.setAttribute('number', eachPort['parentKey'])
            portEl.setAttribute('desc', eachPort['desc'])
            result.appendChild(portEl)
        self.doc.documentElement.appendChild(result)
        self.writeXmlDoc()
Example #4
0
    def rspVNIIO(self):
        vni = self.fields.get('vni', 'none')
        if not vni or vni == 'none':
            return
        gg, doc = ReportGenerationHelper.rspVNIIO(self.mgmt,
                                                  self.fields,
                                                  ProductGfxContext)
        if RVBDUtils.isSH():
            import rsp
            rspText = '%s VNI IO' % rsp.publicName()
        else:
            rspText = 'RSP VNI IO'

        self.render(gg, rspText)
        self.saveTabularInfo(doc)
    def monitoredPorts(self):
        if 'editPolicy' in self.fields:
            base = self.cmcPolicyRetarget('/rbt/sport/reports/config/bandwidth/port')
        else:
            base = RVBDUtils.monitoredPortsPath()

        portMap = Nodes.getMgmtTabularSubtree(self.mgmt, base, Nodes.parentKeyStringIntCmp)
        result = self.doc.createElement('monitoredPorts')
        for eachPort in portMap:
            portEl = self.doc.createElement('port')
            portEl.setAttribute('number', eachPort['parentKey'])
            portEl.setAttribute('desc', eachPort['desc'])
            result.appendChild(portEl)
        self.doc.documentElement.appendChild(result)
        self.writeXmlDoc()
    def monitoredPorts(self):
        base = RVBDUtils.monitoredPortsPath(self.fields)

        if 'addPort' in self.fields.keys():
            number = self.fields.get('addPort_number')
            if Nodes.present(self.mgmt, '%s/%s' % (base, number)):
                self.setFormError("Port %s is already being monitored." % number)
                return
            else:
                desc = self.fields.get('addPort_desc')
                self.setNodes(('%s/%s/desc' % (base, number), 'string', desc))
        elif 'removePorts' in self.fields.keys():
            FormUtils.deleteNodesFromConfigForm(self.mgmt, base, 'ck_', self.fields)
        elif 'editPort' in self.fields.keys():
            number = self.fields.get('editPort_number', None)
            desc = self.fields.get('editPort_desc', None)
            self.setNodes(('%s/%s/desc' % (base, number), 'string', desc))
Example #7
0
        'rbaNode': '/debug/generate/dump',
        'mode': 'binary',
    },
    'snapshot': {
        'dir': '/var/opt/tms/snapshots',
        'rbaNode': '/rbm_fake/debug/download/snapshot',
        'mode': 'binary',
    },
    'tcpdump': {
        'dir': '/var/opt/tms/tcpdumps',
        'rbaNode': '/rbm_fake/debug/generate/tcpdump',
        'mode': 'binary',
    }
}

if RVBDUtils.isCMC():
    _TARGETS['apptcpdump'] = {
        'dir': '/var/opt/tms/tcpdumps/appliance',
        '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.isGW():
Example #8
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))
Example #9
0
import Logging
import OSUtils
import HTTPUtils
import Nodes
import FormUtils
import GfxUtils
import GraphUtils
from PagePresentation import PagePresentation
from XMLContent import XMLContent
import logDownload

basicPathName = "/var/opt/tms/"
allowedDirs = ["sysdumps", "snapshots", "tcpdumps"]

# Enable these booleans if per-product code is needed.
isCMC = RVBDUtils.isCMC()
# isIB  = RVBDUtils.isIB()
isSH  = RVBDUtils.isSH()

def findSysFiles(directory="sysdumps"):
    if directory not in allowedDirs:
        raise OSError, "%s is not a permitted system file category." % directory
    path = basicPathName + directory
    sysFiles = [f for f in os.listdir(path)
        if not f.startswith('.')
        and stat.S_ISREG(os.stat("%s/%s" % (path, f))[stat.ST_MODE])]
    sysFiles.sort()
    return sysFiles

class gui_Diagnostics(PagePresentation):
    # actions handled here
Example #10
0
        'rbaNode': '/debug/generate/dump',
        'mode': 'binary',
    },
    'snapshot': {
        'dir': '/var/opt/tms/snapshots',
        'rbaNode': '/rbm_fake/debug/download/snapshot',
        'mode': 'binary',
    },
    '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'
    }