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('执行成功')
作者:罗阿红
出处:http://www.cnblogs.com/luoahong/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。