Changeset 2482
- Timestamp:
- Sep 19, 2016, 6:34:05 PM (4 years ago)
- Location:
- lliurex-mirror/trunk/fuentes
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-mirror/trunk/fuentes/admin-center-lliurex-mirror.install/lliurex-mirror/src/js/lliurex-mirror.js
r2437 r2482 394 394 var credentials=[sessionStorage.username , sessionStorage.password]; 395 395 var n4dclass="MirrorManager"; 396 var n4dmethod="is_ mirror_update";396 var n4dmethod="is_update_available"; 397 397 var arglist=[self.activedistro]; 398 398 var mirrorupdatemessage=document.querySelector('#llxmirrorupdatepanel'); -
lliurex-mirror/trunk/fuentes/lliurex-mirror-cli/usr/bin/lliurex-mirror
r2278 r2482 87 87 88 88 def isMirrorUpdate(self,distro): 89 result = self.client.is_ mirror_update(self.credentials,"MirrorManager",distro)89 result = self.client.is_update_available(self.credentials,"MirrorManager",distro) 90 90 print str(result['msg']) 91 91 sys.exit( 0 if result['status'] else 1 ) -
lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install/etc/n4d/conf.d/MirrorManager
r2261 r2482 12 12 get_mirror_orig=anonymous,* 13 13 set_mirror_orig=adm,admins 14 get_option_update=anonymous,* 15 set_option_update=adm,admins 14 16 get_percentage=anonymous,* 15 17 build_debmirror_config=adm,admins 18 render_debmirror_config=adm,admins 16 19 enable_webserver_into_folder=adm,admins 17 20 stop_webserver=adm,admins … … 20 23 get_available_mirrors=anonymous,* 21 24 stopupdate=adm,admins 22 is_mirror_update=anonymous,* 25 download_time_file=adm,admins 26 get_time_file=anonymous,* 27 is_update_available=anonymous,* 28 new_mirror_config=adm,admins 29 get_all_configs=anonymous,* 30 update_mirror_config=adm,admins 31 get_client_ip=anonymous,* 32 watch_update_finish=adm,admins 33 is_alive_get_mirror=anonymous,* 34 get_mirror=adm,admins -
lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install/usr/share/n4d/python-plugins/MirrorManager.py
r2437 r2482 313 313 314 314 def set_mirror_orig(self,distro,url,option): 315 if url == None: 316 return {'status':False,'msg':'url is None'} 315 317 configpath = os.path.join(self.configpath, distro + ".json") 316 318 config = json.load(open(configpath,'r')) … … 360 362 361 363 def build_debmirror_config(self,distro): 362 template = self.tpl_env.get_template('debmirror.conf') 363 configpath = os.path.join(self.configpath,distro + ".json") 364 config = json.load(open(configpath,'r')) 365 string_template = template.render(config).encode('utf-8') 364 result = self.render_debmirror_config(distro) 365 string_template = result['msg'] 366 366 f = open(os.path.join(self.debmirrorconfpath,distro),'w') 367 367 f.write(string_template) 368 368 f.close() 369 369 #def build_debmirror_config 370 371 def render_debmirror_config(self,distro): 372 template = self.tpl_env.get_template('debmirror.conf') 373 configpath = os.path.join(self.configpath,distro + ".json") 374 config = json.load(open(configpath,'r')) 375 return {'status':True,'msg':template.render(config).encode('utf-8')} 376 377 #def render_debmirror_config 370 378 371 379 def enable_webserver_into_folder(self,path): … … 469 477 # def get_time_file 470 478 471 def is_ mirror_update(self,distro):479 def is_update_available(self,distro): 472 480 473 481 configpath = os.path.join(self.configpath,distro + ".json") … … 513 521 return {'status':False,'msg':file_local_mirror + ' does not exist.','action':'nothing'} 514 522 515 # def is_ mirror_update523 # def is_update_available 516 524 517 525 def new_mirror_config(self,config): … … 524 532 if name == "": 525 533 return {'status':False,'msg':"Name can't void"} 526 newconfigpath = os.path.join(self.configpath,name,'.json') 527 if os.path.exists(newconfigpath): 528 return {'status':False,'msg':'Path for %s already exists'%config["NAME"]} 534 while True: 535 newconfigpath = os.path.join(self.configpath,name,'.json') 536 if not os.path.exists(newconfigpath): 537 break 538 name = name + "1" 529 539 530 540 data=unicode(json.dumps(config,indent=4,encoding="utf-8",ensure_ascii=False)).encode("utf-8") … … 532 542 f.write(data) 533 543 f.close() 534 return {'status':True,'msg': 'Config has been created'}544 return {'status':True,'msg':name} 535 545 #def new_mirror_config 536 546 … … 557 567 return {'status':True,'msg':'Updated config'} 558 568 #def update_mirror_config 569 570 def get_client_ip(self,ip): 571 return {'status':True,'msg':ip} 572 #def get_client_ip 573 574 def watch_update_finish(self,credentials,server): 575 self.watch_thread=threading.Thread(target=self._update,args=(credentials,server,)) 576 self.watch_thread.daemon=True 577 self.watch_thread.start() 578 579 #def watch_update_finish 580 581 def _watch_update_finish(self,credentials,server) 582 import time 583 import xmlrpclib as x 584 while True: 585 try: 586 time.sleep(240) 587 c = x.ServerProxy('https://'+ server +':9779') 588 result = c.is_alive(credentials,'MirrorManager') 589 if ! result: 590 self.stop_webserver() 591 break 592 except: 593 break 594 #def _watch_update_finish 595 596 def is_alive_get_mirror(self): 597 return {'status':self.get_mirror_thread.is_alive(),'msg':} 598 #def is_alive_get_mirror 599 600 def get_mirror(self,config_path): 601 self.get_mirror_thread = threading.Thread(target=self._get_mirror,args=(config_path)) 602 self.get_mirror_thread.daemon = True 603 self.get_mirror_thread.start() 604 #def get_mirror 605 606 def _get_mirror(self,config_path): 607 self.get_mirror_process = pexpect.spawn("/usr/bin/debmirror --config-file="+config_path) 608 while True: 609 try: 610 self.get_mirror_process.expect('\n') 611 line =self.get_mirror_process.before 612 line1=line.strip("\n") 613 if line1.startswith("[") and line1[5] == "]": 614 self.exportpercentage = (int(line1[1:4].strip()),self.get_mirror_process.exitstatus) 615 except pexpect.EOF: 616 line1 = self.get_mirror_process.before 617 if line1 != "" and line1.startswith("[") and line1[5] == "]": 618 self.exportpercentage=(int(line1[1:4].strip()),self.get_mirror_process.exitstatus) 619 self.get_mirror_process.close() 620 status = self.get_mirror_process.exitstatus 621 self.exportpercentage=(self.exportpercentage[0],status) 622 break 623 except Exception as e: 624 break 625 #def _get
Note: See TracChangeset
for help on using the changeset viewer.