Make command configurable, for restarting tempmon-client
can even configure it per client if necessary
This commit is contained in:
		
							parent
							
								
									051cb71956
								
							
						
					
					
						commit
						0e0b125d99
					
				
					 2 changed files with 22 additions and 22 deletions
				
			
		|  | @ -1,8 +1,8 @@ | ||||||
| ## -*- coding: utf-8; -*- | ## -*- coding: utf-8; -*- | ||||||
| <%inherit file="/master/view.mako" /> | <%inherit file="/master/view.mako" /> | ||||||
| 
 | 
 | ||||||
| <%def name="head_tags()"> | <%def name="extra_javascript()"> | ||||||
|   ${parent.head_tags()} |   ${parent.extra_javascript()} | ||||||
|   <script type="text/javascript"> |   <script type="text/javascript"> | ||||||
|     $(function() { |     $(function() { | ||||||
|         $('#restart-client').click(function() { |         $('#restart-client').click(function() { | ||||||
|  | @ -13,23 +13,15 @@ | ||||||
|   </script> |   </script> | ||||||
| </%def> | </%def> | ||||||
| 
 | 
 | ||||||
| <ul id="context-menu"> | <%def name="object_helpers()"> | ||||||
|   ${self.context_menu_items()} |   % if instance.enabled and master.restartable_client(instance) and request.has_perm('{}.restart'.format(route_prefix)): | ||||||
| </ul> |  | ||||||
| 
 |  | ||||||
| % if instance.enabled and master.restartable_client(instance) and request.has_perm('{}.restart'.format(route_prefix)): |  | ||||||
|       <div class="object-helper"> |       <div class="object-helper"> | ||||||
|         <h3>Client Tools</h3> |         <h3>Client Tools</h3> | ||||||
|         <div class="object-helper-content"> |         <div class="object-helper-content"> | ||||||
|           <button type="button" id="restart-client">Restart tempmon-client daemon</button> |           <button type="button" id="restart-client">Restart tempmon-client daemon</button> | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
| % endif |   % endif | ||||||
|  | </%def> | ||||||
| 
 | 
 | ||||||
| <div class="form-wrapper"> | ${parent.body()} | ||||||
|   ${form.render()|n} |  | ||||||
| </div><!-- form-wrapper --> |  | ||||||
| 
 |  | ||||||
| % if master.has_rows: |  | ||||||
|     ${rows_grid|n} |  | ||||||
| % endif |  | ||||||
|  |  | ||||||
|  | @ -28,6 +28,7 @@ from __future__ import unicode_literals, absolute_import | ||||||
| 
 | 
 | ||||||
| import subprocess | import subprocess | ||||||
| 
 | 
 | ||||||
|  | from rattail.config import parse_list | ||||||
| from rattail_tempmon.db import model as tempmon | from rattail_tempmon.db import model as tempmon | ||||||
| 
 | 
 | ||||||
| import colander | import colander | ||||||
|  | @ -199,7 +200,8 @@ class TempmonClientView(MasterView): | ||||||
|         g.set_sort_defaults('taken', 'desc') |         g.set_sort_defaults('taken', 'desc') | ||||||
| 
 | 
 | ||||||
|     def restartable_client(self, client): |     def restartable_client(self, client): | ||||||
|         return True |         cmd = self.get_restart_cmd(client) | ||||||
|  |         return bool(cmd) | ||||||
| 
 | 
 | ||||||
|     def restart(self): |     def restart(self): | ||||||
|         client = self.get_instance() |         client = self.get_instance() | ||||||
|  | @ -217,7 +219,13 @@ class TempmonClientView(MasterView): | ||||||
|         return self.redirect(self.get_action_url('view', client)) |         return self.redirect(self.get_action_url('view', client)) | ||||||
| 
 | 
 | ||||||
|     def get_restart_cmd(self, client): |     def get_restart_cmd(self, client): | ||||||
|         return ['ssh', client.hostname, 'sudo service tempmon-client restart'] |         name = 'rattail.tempmon.client.restart' | ||||||
|  |         cmd = self.rattail_config.get('rattail.tempmon', 'client.restart.{}'.format(client.config_key)) | ||||||
|  |         if not cmd: | ||||||
|  |             cmd = self.rattail_config.get('rattail.tempmon', 'client.restart') | ||||||
|  |         if cmd: | ||||||
|  |             cmd = cmd.format(hostname=client.hostname) | ||||||
|  |             return parse_list(cmd) | ||||||
| 
 | 
 | ||||||
|     @classmethod |     @classmethod | ||||||
|     def defaults(cls, config): |     def defaults(cls, config): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar