Bug fix with folder handling and API enhancement

community
Steve L. Nyemba 7 years ago
parent ce08f55f81
commit ad2c911c0a

@ -152,7 +152,7 @@ def get_usage_detail():
""" """
r = {} r = {}
try: try:
id = request.args.get('node') id = request.args['id'] if 'id' in request.args else request.args.get('node')
app_id = request.args.get('app') app_id = request.args.get('app')
gReader = factory.instance(type=class_read,args=p) gReader = factory.instance(type=class_read,args=p)
r = gReader.view('summary/app_resource_usage_details',key=p['uid']) r = gReader.view('summary/app_resource_usage_details',key=p['uid'])
@ -270,10 +270,9 @@ def InitCollector():
lagents.append(agent) lagents.append(agent)
if id in a : if id in a :
#-- This variable should not be confused with defined namespace #-- This variable should not be confused with defined namespace
# The manager will properly initialize the objects
#
_actor = eval(a[id]+"()") _actor = eval(a[id]+"()")
print _actor.getName()
_actor.init(args)
lactors.append(_actor) lactors.append(_actor)
config = dict(CONFIG) config = dict(CONFIG)

@ -187,6 +187,7 @@ class Folders(Actor):
#self.action = args['action'] #{clear,archive} config['actions']['folders'] #self.action = args['action'] #{clear,archive} config['actions']['folders']
self.threshold = self.get_size( args['threshold']) #self.config['threshold']) self.threshold = self.get_size( args['threshold']) #self.config['threshold'])
def archive(self,item): def archive(self,item):
""" """
This function will archive all files in a given folder This function will archive all files in a given folder
@ -224,7 +225,9 @@ class Folders(Actor):
converts size values into MB and returns the value without units converts size values into MB and returns the value without units
""" """
units = {'MB':1000,'GB':1000000,'TB':1000000000} # converting to kb units = {'MB':1000,'GB':1000000,'TB':1000000000} # converting to kb
key = set(units) & set(re.split('(\d+)',value.upper())) key = set(units.keys()) & set(re.split('(\d+)',value.replace(' ','').upper()))
if len(key) == 0: if len(key) == 0:
return -1 return -1
key = key.pop() key = key.pop()
@ -242,9 +245,8 @@ class Folders(Actor):
def analyze(self,logs): def analyze(self,logs):
r = {'clean':self.clean,'archive':self.archive} r = {'clean':self.clean,'archive':self.archive}
self.lfolders = [ folder['label'] for folder in logs]
for item in logs : for item in logs :
if self.can_clean(item) : if self.can_clean(item) :
self.archive(item)
id = self.config['action'].strip() #self.clean(item)
pointer = r[id]
pointer (item)

@ -139,6 +139,7 @@ class Manager() :
if len(args.keys()) > 0 : if len(args.keys()) > 0 :
self.apply_setup('apps',args) self.apply_setup('apps',args)
args = couchdb.view('config/folders',key=self.key) args = couchdb.view('config/folders',key=self.key)
if 'folder_size' not in meta : if 'folder_size' not in meta :
args['threshold'] = meta['folder_size'] args['threshold'] = meta['folder_size']
self.apply_setup('folders',args) self.apply_setup('folders',args)
@ -146,8 +147,7 @@ class Manager() :
def apply_setup(self,name,args) : def apply_setup(self,name,args) :
for actor in self.actors : for actor in self.actors :
if args is not None and actor.getName() == name and len(args.keys()) > 0: if args is not None and actor.getName() == name and len(args.keys()) > 0:
pass actor.init(args)
#actor.init(args)
def __setup(self,meta): def __setup(self,meta):

Loading…
Cancel
Save