def dropRead(): """Drop read cache """ _logger.debug("Dropping read cache") try: disks = vsi.list("/vmkModules/lsom/disks/") components = None except ValueError: _logger.warning("Using old lsom nodes") node = "/vmkModules/vsan/lsom/components/" components = [node + c for c in vsi.list(node)] if components is None: components = [] for disk in disks: node = "/vmkModules/lsom/disks/%s/components/" % disk try: components.extend([node + c for c in vsi.list(node)]) except: _logger.warning("No components in %s", disk) if len(components): _logger.warning("Clearing out read-cache for %d components", len(components)) for comp in components: vsi.set(comp + "/dropRcCache", 1) time.sleep(10)
def TestInterleavesetInfo(self, setinfo): """ Test NVDIMM Interleaveset information """ global vsi self.assertIsNotNone( setinfo, "NVDIMM Interleave set properties should not be None") # Loop lists to check if interleave set property contents are the same for s in setinfo: # Get NVDIMM interleave set properties through VSI call setidstr = "{0:#0{1}x}".format(s.setId, 10) v = vsi.get('/hardware/nvd/interleaveset/%s/properties' % setidstr) self.assertIsNotNone( v, "NVDIMM interleave set properties obtained via VSI should" " not be None") self.assertEqual( s.setId, v['id'], "Interleave set ID did not match vsi set property") self.checkRangeType(v['type'], s.rangeType) self.assertEqual( s.baseAddress, v['baseAddress'], "Interleave set Base Address did not match vsi" " set property") self.assertEqual( s.size, v['size'], "Interleave set size did not match vsi set property") self.assertEqual( s.availableSize, v['availableSize'], "Interleave set available size did not match vsi" " set property") self.checkInterleaveSetState(v['state'], s.state) dimmList = vsi.list('/hardware/nvd/interleaveset/%s/dimm' % setidstr) self.assertIsNotNone( dimmList, "List of dimms part of interleave set obtained via VSI should" " not be None") for d, l in zip(s.deviceList, dimmList): # Match device list dimmstr = "{0:#0{1}x}".format(d, 10) self.assertEqual( dimmstr, l, "Interleave set dimm ID did not match vsi" " device list")
def buildList(): """Build list of ssds """ ssds = {} node = "/vmkModules/plog/devices/" for disk in vsi.list(node): isSSD = vsi.get(node + disk + "/info")["isSSD"] if isSSD: elevNode = node + disk + "/elevStats" ssds[disk] = { "state": "QUERY", "stateval": 0, "prevval": vsi.get(elevNode)["plogDataUsage"], "node": elevNode, } return ssds
def TestNamespaceList(self, ns): """ Test NVDIMM Namespace list """ global vsi self.assertIsNotNone(ns, "NVDIMM namespace list should not be None") # Get NVDIMM namespace list through VSI call nsVsi = vsi.list("/hardware/nvd/namespace") self.assertIsNotNone( nsVsi, "NVDIMM namespace list obtained via VSI should not be None") # Loop lists to check if dimm handles are the same for n, v in zip(ns, nsVsi): self.assertEqual( n.uuid, v, "Namespace UUID did not match vsi namespace UUID")
def TestInterleavesetList(self, sets): """ Test NVDIMM Interleaveset list """ global vsi self.assertIsNotNone(sets, "NVDIMM interleave sets should not be None") # Get NVDIMM interleave set list through VSI call setVsi = vsi.list('/hardware/nvd/interleaveset') self.assertIsNotNone( setVsi, "NVDIMM Interleave set list obtained via VSI should not be None") # Loop lists to check if interleave set contents are the same for s, v in zip(sets, setVsi): setidstr = "{0:#0{1}x}".format(s, 10) self.assertEqual(setidstr, v, "Interleave set ID did not match vsi healthinfo")
def TestDimmList(self, dimms): """ Test NVDIMM list """ global vsi self.assertIsNotNone(dimms, "NVDIMM list should not be None") # Get NVDIMM list through VSI call dimmsVsi = vsi.list("/hardware/nvd/dimm") self.assertIsNotNone( dimmsVsi, "NVDIMM list obtained via VSI should not be None") # Loop lists to check if dimm handles are the same for d, v in zip(dimms, dimmsVsi): # Convert dimm handle in hex to zero filled hex format dimmstr = "{0:#0{1}x}".format(d, 10) self.assertEqual(dimmstr, v, "Dimm Handle did not match vsi dimm handle")
import vmware.vsi as vsi import time from collections import defaultdict def calculate(xyz,nics): if xyz[0] == 0 and xyz[1] == 0: print "Lets wait for packets to come to %s" %(nics) else: print "The number of packets received for %s in the last 10 seconds are " %(nics.upper())+ str(xyz[2]-xyz[0]) print "The number of packets sent from %s in the last 10 seconds are " %(nics.upper())+ str(xyz[3]-xyz[1]) vmnics = defaultdict(list) no_nics=vsi.list('/net/pNics/') print "There are total of %d network cards in the machine " %(len(no_nics)) for i in no_nics: vmnics[i]=[0,0] while True: for nics in no_nics: ReceivePackets=vsi.get('/net/pNics/%s/stats' % nics)['rxpkt'] vmnics[nics].append(ReceivePackets) SendPackets=vsi.get('/net/pNics/%s/stats' % nics)['txpkt'] vmnics[nics].append(SendPackets) calculate(vmnics[nics],nics) del vmnics[nics][0:2] print "-"*20 + "Sleeping for 10 seconds" + "-"*20 print 2*'\n' time.sleep(10)
import time from collections import defaultdict def calculate(xyz, nics): if xyz[0] == 0 and xyz[1] == 0: print "Lets wait for packets to come to %s" % (nics) else: print "The number of packets received for %s in the last 10 seconds are " % ( nics.upper()) + str(xyz[2] - xyz[0]) print "The number of packets sent from %s in the last 10 seconds are " % ( nics.upper()) + str(xyz[3] - xyz[1]) vmnics = defaultdict(list) no_nics = vsi.list('/net/pNics/') print "There are total of %d network cards in the machine " % (len(no_nics)) for i in no_nics: vmnics[i] = [0, 0] while True: for nics in no_nics: ReceivePackets = vsi.get('/net/pNics/%s/stats' % nics)['rxpkt'] vmnics[nics].append(ReceivePackets) SendPackets = vsi.get('/net/pNics/%s/stats' % nics)['txpkt'] vmnics[nics].append(SendPackets) calculate(vmnics[nics], nics) del vmnics[nics][0:2] print "-" * 20 + "Sleeping for 10 seconds" + "-" * 20 print 2 * '\n' time.sleep(10)
def TestDimmInfo(self, dimminfo): """ Test NVDIMM Information """ global vsi self.assertIsNotNone(dimminfo, "NVDIMM Information should not be None") # Loop lists to check if dimminfo contents are the same for d in dimminfo: # Get NVDIMM Information through VSI call dimmstr = "{0:#0{1}x}".format(d.dimmHandle, 10) v = vsi.get('/hardware/nvd/dimm/%s/dimminfo' % dimmstr) self.assertIsNotNone( v, "NVDIMM information obtained via VSI should" " not be None") self.assertEqual(d.dimmHandle, v['dimmHandle'], "Dimm Handle did not match vsi dimm handle") self.assertEqual( d.totalCapacity, v['totalCapacity'], "Total Capacity did not match vsi dimm information") self.assertEqual( d.persistentCapacity, v['persistentCapacity'], "Persistent Capacity did not match vsi" " dimm information") self.assertEqual( d.availablePersistentCapacity, v['availablePersistentCapacity'], "Available Persistent Capacity did not match vsi" " dimm information") self.assertEqual( d.volatileCapacity, v['volatileCapacity'], "Volatile Capacity did not match vsi dimm" " information") self.assertEqual( d.availableVolatileCapacity, v['availableVolatileCapacity'], "Available Volatile Capacity did not match vsi" " dimm information") # Get list of regions part of DIMM regionList = vsi.list('/hardware/nvd/dimm/%s/region' % dimmstr) self.assertIsNotNone(regionList, "Region list cannot be none") stateFlags = 0 """ Get vsi region information and match with hostd obtained region information. """ for vsiregion, r in zip(regionList, d.regionInfo): regionInfo = vsi.get( '/hardware/nvd/dimm/%s/region/%s/regioninfo' % (dimmstr, vsiregion)) self.assertIsNotNone(regionInfo, "Region information cannot be none") self.assertEqual(r.regionId, regionInfo['id'], "Region ID does not match") self.assertEqual(r.setId, regionInfo['setId'], "Setid does not match vsi information") self.checkRangeType(regionInfo['type'], r.rangeType) self.assertEqual( r.startAddr, regionInfo['startAddr'], "Region start address does not match vsi information") self.assertEqual(r.size, regionInfo['size'], "Region Size does not match vsi information") self.assertEqual( r.offset, regionInfo['offset'], "Region offset does not match vsi information") stateFlags = stateFlags | regionInfo['stateFlags'] ## Get NVDIMM topology vsiTopo = vsi.get('/hardware/nvd/dimm/%s/topology' % dimmstr) ## Test NVDIMM representation string self.assertIsNotNone(vsiTopo, "Topology can not be null") self.assertEqual( vsiTopo['representationStr'], d.representationString, "Representation string does not match vsi information") ## Check health information for DIMM vsiHealth = vsi.get('/hardware/nvd/dimm/%s/healthinfo' % dimmstr) self.assertIsNotNone(vsiHealth, "Health information cannot be none") self.TestDimmHealthinfo(stateFlags, d.healthInfo, vsiHealth)