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/' % host
query_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)