zoukankan      html  css  js  c++  java
  • CMDB服务器管理系统【s5day91】:资产采集相关问题

    资产采集唯一标识和允许临时修改主机名

    class AgentClient(BaseClient):
    
        def exec(self):
            obj = PluginManager()
            server_dict = obj.exec_plugin()
            new_hostname = server_dict['basic']['data']['hostname']
            cert_path = os.path.join(settings.BASEDIR,'conf','cert')
    
            f = open(cert_path,mode='r')
            old_hostname = f.read()
            f.close()
    
            if not old_hostname:
                """第一次运行"""
                with open(cert_path,mode='w') as ff:
                    ff.write(new_hostname)
            else:
                server_dict['basic']['data']['hostname'] = old_hostname
            print('采集到的服务器信息:',server_dict)
            self.post_server_info(server_dict)

    Django补充之事务操作

    def tran(request):
    	from django.db import transactio
    	try:
    		with transaction.atomic():
    			models.UserProfile.objec
    			models.Server.objects.cr
    	except Exception as e:
    		return HttpResponse('出现错误
    
    	return HttpResponse('执行成功')
    

     

  • 相关阅读:
    HDU 2717 Catch That Cow
    补题列表
    Codeforces 862C 异或!
    HDU 2084
    HDU 2037
    Codeforces 492B
    POJ 2262
    Codeforces 1037A
    HDU 1276
    itertools — Functions creating iterators for efficient looping
  • 原文地址:https://www.cnblogs.com/luoahong/p/9367487.html
Copyright © 2011-2022 走看看