#!/usr/bin/python import subprocess class Epoptes: # Some Hostname Values EPOPTES_CONFIGURATION_FILE="/etc/default/epoptes" def startup(self,options): ''' This function set the epoptes configuration at startup, only works on classroom model ''' # executed when launching n4d pass #def startup def info(self): ''' Show basic info about this plugin ''' return {'status':True, 'msg':'[Epoptes] Manage Epoptes server'} #def apt # service test and backup functions # def test(self): pass #def test def backup(self): pass #def backup def restore(self): pass #def restore def set_epoptes_server(self,epoptes_server): ''' Set the hostname for a machine ''' try: # First set at file f=open(Epoptes.EPOPTES_CONFIGURATION_FILE,"w") # TODO f.close() # TODO #Inicialize at N4D EPOPTES list_variables['EPOPTES_SRV'] = objects['VariablesManager'].get_variable('EPOPTES_SRV') #If variable EPOPTES_SRV is not defined calculate it with args values if list_variables['EPOPTES_SRV'] == None: status,list_variables['EPOPTES_SRV'] = objects['VariablesManager'].init_variable('EPOPTES_SRV',{'EPOPTES_SRV':epoptes_server}) return {'status': True, 'msg':'[Epoptes] is setted by n4d to '+epoptes_server+' '} except Exception as e: return {'status': False, 'msg':'[Epoptes] Epoptes server not setted :'+ str(e)} #def set_hostname def get_epoptes_server(self): ''' Get the epoptes_srv value at n4d values ''' try: #list_variables['HOSTNAME'] = objects['VariablesManager'].get_variable('HOSTNAME') list_variables['EPOPTES_SRV'] = objects['VariablesManager'].get_variable('EPOPTES_SRV') return {'status': True,'EPOPTES_SRV':list_variables['EPOPTES_SRV']} except Exception as e: return {'status': False, 'msg':'[Epoptes] Epoptes srv not setted at n4d : '+ str(e)} #def get_n4d_hostname(self): def get_current_epoptes_server (self): ''' Get the current hostname at file /etc/default/epoptes ''' try: # Get Hostname from f=open(Epoptes.EPOPTES_CONFIGURATION_FILE,"r") epoptes_srv=f.read() f.close() return {'status': True, 'EPOPTES_SRV':epoptes_srv.rstrip()} except Exception as e: return {'status': False, 'msg':'[Epoptes] Epoptes srv not getted '+ str(e)} #def get_current_hostname(self): #Hostname