def get_stripe_mult(pass_type=None): multipliers = {} pass_key = None if pass_type in _valid_keys: pass_key = '%s_pass' % pass_type defaults = {'full':1, 'long':500, 'short':2000, 'quick':10} default = defaults[pass_type] else: print 'unrecognized stripe multiplier pass type: %s' % pass_type raise ValueError constant_scrub_multipliers = {'full_pass':1, 'quick_pass':10} if pass_key is not None: multipliers['Default'] = default multipliers['bandwidth'] = {} ctx = gconfig.open(hal.gcfg_driveconfig).ctx_new() dcs = ctx.read('driveconfigs') for dc in dcs: key = dc.get('model') if pass_key in constant_scrub_multipliers: scrub_multipliers = constant_scrub_multipliers else: scrub_multipliers = dc.get('scrub_multipliers') if not key or not scrub_multipliers: print 'unregognized key and/or scrub_multipliers in drive ' \ 'configuration' raise ValueError multipliers[key] = scrub_multipliers[pass_key] scrub_bandwidth = scrub_multipliers.get('bandwidth') if scrub_bandwidth: multipliers['bandwidth'][key] = scrub_bandwidth return multipliers
def run(): ShareDict = dict() cfg = gcfg.open(gcfg.gcfg_main) ctx = cfg.ctx_new() allShares = ctx.read(g.REGPATH_SRV_SHARES) for share in allShares: if options.verbrose==True: print "found share ", share[g.nameKey] ShareDict[share[g.nameKey]] = "SRV" # Now look at the onefs share parts and we must # match 1:1 for the data to be okay allShares = ctx.read(g.REGPATH_ONEFS_SHARES) for share in allShares: if share[g.nameKey] not in ShareDict: if options.verbrose==True: print "deleting ophaned share",expandString(share[g.nameKey]) ctx.delete(g.REGPATH_ONEFS_SHARES+"."+expandString(share[g.nameKey])) else: del ShareDict[share[g.nameKey]] # Now we have to remove the leftover shares for shareName in ShareDict: if options.verbrose==True: print "removing removing",expandString(shareName) ctx.delete(g.REGPATH_SRV_SHARES+"."+expandString(shareName)) # For next pass a valid share list is needed ShareDict = dict() allShares = ctx.read(g.REGPATH_SRV_SHARES) for share in allShares: if options.verbrose==True: print "Found complete share ", share[g.nameKey] ShareDict[share[g.nameKey]] = "SRV" # check for any abandoned ACLs allShares = ctx.read(g.REGPATH_SRV_SHARE_ACLS) for share in allShares: if share[g.nameKey] not in ShareDict: if options.verbrose==True: print "Removing abandoned ACLs for share", share[g.nameKey] ctx.delete(g.REGPATH_SRV_SHARE_ACLS+"."+expandString(share[g.nameKey])) ctx.commit() # needed to actually updated the file.
def run(): ShareDict = dict() cfg = gcfg.open(gcfg.gcfg_main) ctx = cfg.ctx_new() allShares = ctx.read(g.REGPATH_SRV_SHARES) for share in allShares: if options.verbrose==True: print("found share ", share[g.nameKey]) ShareDict[share[g.nameKey]] = "SRV" # Now look at the onefs share parts and we must # match 1:1 for the data to be okay allShares = ctx.read(g.REGPATH_ONEFS_SHARES) for share in allShares: if share[g.nameKey] not in ShareDict: if options.verbrose==True: print("deleting ophaned share",expandString(share[g.nameKey])) ctx.delete(g.REGPATH_ONEFS_SHARES+"."+expandString(share[g.nameKey])) else: del ShareDict[share[g.nameKey]] # Now we have to remove the leftover shares for shareName in ShareDict: if options.verbrose==True: print("removing removing",expandString(shareName)) ctx.delete(g.REGPATH_SRV_SHARES+"."+expandString(shareName)) # For next pass a valid share list is needed ShareDict = dict() allShares = ctx.read(g.REGPATH_SRV_SHARES) for share in allShares: if options.verbrose==True: print("Found complete share ", share[g.nameKey]) ShareDict[share[g.nameKey]] = "SRV" # check for any abandoned ACLs allShares = ctx.read(g.REGPATH_SRV_SHARE_ACLS) for share in allShares: if share[g.nameKey] not in ShareDict: if options.verbrose==True: print("Removing abandoned ACLs for share", share[g.nameKey]) ctx.delete(g.REGPATH_SRV_SHARE_ACLS+"."+expandString(share[g.nameKey])) ctx.commit() # needed to actually updated the file.