mirror of https://github.com/jumpserver/jumpserver
				
				
				
			perf: 优化 HUAWEI 设备判断逻辑
							parent
							
								
									1ecf8534f6
								
							
						
					
					
						commit
						ad0bc82539
					
				| 
						 | 
					@ -1,8 +1,7 @@
 | 
				
			||||||
from django.db import models
 | 
					from django.db import models
 | 
				
			||||||
from django.utils.translation import gettext_lazy as _
 | 
					from django.utils.translation import gettext_lazy as _
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from assets.const import AllTypes
 | 
					from assets.const import AllTypes, Category, Protocol
 | 
				
			||||||
from assets.const import Protocol
 | 
					 | 
				
			||||||
from common.db.fields import JsonDictTextField
 | 
					from common.db.fields import JsonDictTextField
 | 
				
			||||||
from common.db.models import JMSBaseModel
 | 
					from common.db.models import JMSBaseModel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -119,6 +118,15 @@ class Platform(LabeledMixin, JMSBaseModel):
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        return linux.id
 | 
					        return linux.id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def is_huawei(self):
 | 
				
			||||||
 | 
					        if self.category != Category.DEVICE:
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					        if 'huawei' in self.name.lower():
 | 
				
			||||||
 | 
					            return True
 | 
				
			||||||
 | 
					        if '华为' in self.name:
 | 
				
			||||||
 | 
					            return True
 | 
				
			||||||
 | 
					        return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return self.name
 | 
					        return self.name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -125,7 +125,7 @@ class JMSInventory:
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            host.update(self.make_account_ansible_vars(account, path_dir))
 | 
					            host.update(self.make_account_ansible_vars(account, path_dir))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if "huawei" in platform.name.lower() and platform.category == Category.DEVICE.value:
 | 
					        if platform.is_huawei():
 | 
				
			||||||
            host['ansible_connection'] = 'network_cli'
 | 
					            host['ansible_connection'] = 'network_cli'
 | 
				
			||||||
            host['ansible_network_os'] = 'asa'
 | 
					            host['ansible_network_os'] = 'asa'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue