本文主要是介绍jumpserver资产录入,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.clear-test
truncate table ops_adhoc_hosts;
TRUNCATE table assets_asset_nodes;
TRUNCATE table assets_systemuser_assets;
delete from assets_asset;
update assets_node set assets_amount=0;
2.cmdb--->jumpserver--api
def get_token(self):# 主要用户获取jumpserver的token值url = 'https://%s/api/v1/authentication/auth/' % hostquery_args = {"username": username,"password": password}response = requests.post(url, data=query_args)print(response.json())return json.loads(response.text)['token']header_info = {"Authorization": 'Bearer ' + token}data = {"ip": ip,"id": assets_asset_id,"hostname": result_host_name,"platform": platform,"admin_user": jumpserver_admin,"nodes": node_id,"is_active": True}req = requests.post('https://%s/api/v1/assets/assets/' % host, headers=self.header_info(), data=data)
这篇关于jumpserver资产录入的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!