mirror of https://github.com/jumpserver/jumpserver
				
				
				
			perf: open svc account register on deploy
							parent
							
								
									48a9b2664a
								
							
						
					
					
						commit
						1e07cba545
					
				| 
						 | 
				
			
			@ -3,6 +3,7 @@
 | 
			
		|||
import time
 | 
			
		||||
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
from django.core.cache import cache
 | 
			
		||||
from rest_framework import permissions
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -30,6 +31,8 @@ class WithBootstrapToken(permissions.BasePermission):
 | 
			
		|||
    def check_can_register(self):
 | 
			
		||||
        enabled = settings.SECURITY_SERVICE_ACCOUNT_REGISTRATION
 | 
			
		||||
        if enabled == 'auto':
 | 
			
		||||
            if cache.get(f'APPLET_HOST_DELOYING'):
 | 
			
		||||
                return True
 | 
			
		||||
            return time.time() - settings.JUMPSERVER_UPTIME < 300
 | 
			
		||||
        elif enabled:
 | 
			
		||||
            return True
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
from collections import defaultdict
 | 
			
		||||
 | 
			
		||||
from django.core.cache import cache
 | 
			
		||||
from django.db import models
 | 
			
		||||
from django.utils import timezone
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
| 
						 | 
				
			
			@ -155,6 +155,8 @@ class AppletHostDeployment(JMSBaseModel):
 | 
			
		|||
            self.host.terminal = None
 | 
			
		||||
            self.host.save()
 | 
			
		||||
            terminal.delete()
 | 
			
		||||
 | 
			
		||||
        cache.set(f'APPLET_HOST_DELOYING', str(self.id), timeout=300)
 | 
			
		||||
        from ...automations.deploy_applet_host import DeployAppletHostManager
 | 
			
		||||
        manager = DeployAppletHostManager(self, **kwargs)
 | 
			
		||||
        manager.run()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue