changes with utils

community
Steve Nyemba 7 years ago
parent 52af677bf5
commit 833407dd4c

@ -15,7 +15,7 @@ import monitor
import requests import requests
class Manager() : class Manager() :
def version(self): def version(self):
return 1.0 return 1.1
""" """
delay : <value> delay : <value>
@ -29,7 +29,7 @@ class Manager() :
def init(self,**args) : def init(self,**args) :
self.id = args['node'] self.id = args['node']
self.agents = args['agents'] self.agents = args['agents']
self.config = args['config'] self.config = dict(args['config'])
self.key = args['key'] self.key = args['key']
self.actors = args['actors'] self.actors = args['actors']
self.update() #-- Initializing status information self.update() #-- Initializing status information
@ -42,7 +42,6 @@ class Manager() :
url="https://the-phi.com/store/status/monitor" url="https://the-phi.com/store/status/monitor"
r = requests.get(url,headers={"uid":self.key}) r = requests.get(url,headers={"uid":self.key})
plans = json.loads(r.text) plans = json.loads(r.text)
meta = [item['metadata'] for item in plans if item['status']=='active' ] meta = [item['metadata'] for item in plans if item['status']=='active' ]
if len(meta) > 0 : if len(meta) > 0 :
self.DELAY = 60* max([ int(item['delay']) for item in meta]) self.DELAY = 60* max([ int(item['delay']) for item in meta])
@ -58,7 +57,7 @@ class Manager() :
meta = meta[0] meta = meta[0]
self.agents = self.filter('agents',meta,self.agents) self.agents = self.filter('agents',meta,self.agents)
self.actors = self.filter('actors',meta,self.actors) self.actors = self.filter('actors',meta,self.actors)
self.setup(meta) #self.setup(meta)
def filter_collectors(self,meta) : def filter_collectors(self,meta) :
""" """

@ -20,7 +20,7 @@ class Register :
""" """
self.class_write = args['write'] self.class_write = args['write']
self.class_read = args['read'] self.class_read = args['read']
self.store_args = args['store'] self.store_args = dict(args['store'])
self.default_plan = args['default'] self.default_plan = args['default']
self.factory = DataSourceFactory() self.factory = DataSourceFactory()
self.uid = args['uid'] self.uid = args['uid']
@ -70,8 +70,8 @@ class Register :
key = self.get_key() key = self.get_key()
return {"key":key,"name":plan['name'],"info":[plan['metadata']]} return {"key":key,"name":plan['name'],"info":[plan['metadata']]}
except Exception,e: except Exception as e:
print e print (str(e))
return None return None
def get_key(self) : def get_key(self) :
store = self.factory.instance(type=self.class_read,args=self.store_args) store = self.factory.instance(type=self.class_read,args=self.store_args)
@ -106,7 +106,13 @@ class Register :
def get_active_plan(self): def get_active_plan(self):
store = self.factory.instance(type=self.class_read,args=self.store_args) store = self.factory.instance(type=self.class_read,args=self.store_args)
id = store.view('federation/uid_map',key=self.uid) id = store.view('federation/uid_map',key=self.uid)
return store.view('plans/active',key=id) try:
r = store.view('plans/active',key=id)
return r
except Exception as e:
print (e)
return {}
def cancel(self,pid): def cancel(self,pid):
pass pass
def upgrade(self,pid): def upgrade(self,pid):

Loading…
Cancel
Save