修改getresource

pull/26/head
ibuler 9 years ago
parent 8ac369b925
commit a0ae7ff139

@ -108,7 +108,7 @@ def get_add_sudo_script(sudo_chosen_aliase, sudo_chosen_obj):
sudo_file = NamedTemporaryFile(delete=False) sudo_file = NamedTemporaryFile(delete=False)
sudo_file.write(sudo_content) sudo_file.write(sudo_content)
sudo_file.close() sudo_file.close()
print(sudo_file.name)
return sudo_file.name return sudo_file.name

@ -356,7 +356,6 @@ def perm_role_edit(request):
if request.method == "GET": if request.method == "GET":
return my_render('jperm/perm_role_edit.html', locals(), request) return my_render('jperm/perm_role_edit.html', locals(), request)
if request.method == "POST": if request.method == "POST":
# 获取 POST 数据 # 获取 POST 数据
role_name = request.POST.get("role_name") role_name = request.POST.get("role_name")
@ -423,23 +422,25 @@ def perm_role_push(request):
group_assets_obj = [] group_assets_obj = []
for asset_group in asset_groups_obj: for asset_group in asset_groups_obj:
group_assets_obj.extend(asset_group.asset_set.all()) group_assets_obj.extend(asset_group.asset_set.all())
calc_assets = set(assets_obj) | set(group_assets_obj) calc_assets = list(set(assets_obj) | set(group_assets_obj))
# 生成Inventory # 生成Inventory
push_resource = [] # push_resource = []
for asset in calc_assets: # for asset in calc_assets:
if asset.use_default_auth: # if asset.use_default_auth:
username = Setting.field1 # username = Setting.field1
port = Setting.field2 # port = Setting.field2
password = Setting.field3 # password = Setting.field3
else: # else:
username = asset.username # username = asset.username
password = asset.password # password = asset.password
port = asset.port # port = asset.port
push_resource.append({"hostname": asset.ip, # push_resource.append({"hostname": asset.ip,
"port": port, # "port": port,
"username": username, # "username": username,
"password": password}) # "password": password})
push_resource = gen_resource(calc_assets)
print push_resource
# 获取角色的推送方式,以及推送需要的信息 # 获取角色的推送方式,以及推送需要的信息
roles_obj = [PermRole.objects.get(name=role_name) for role_name in role_names] roles_obj = [PermRole.objects.get(name=role_name) for role_name in role_names]
@ -486,7 +487,9 @@ def perm_role_push(request):
if ret_sudo["step1"] != "ok" or ret_sudo["step2"] != "ok": if ret_sudo["step1"] != "ok" or ret_sudo["step2"] != "ok":
ret_failed["step3"] = "failed" ret_failed["step3"] = "failed"
os.remove(add_sudo_script) # os.remove(add_sudo_script)
print ret
# 结果汇总统计 # 结果汇总统计

@ -1,9 +1,4 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block self_head_css_js %}
<link href="/static/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
<link href="/static/css/plugins/chosen/chosen.css" rel="stylesheet">
<script src="/static/js/plugins/chosen/chosen.jquery.js"></script>
{% endblock %}
{% load mytags %} {% load mytags %}
{% block content %} {% block content %}
{% include 'nav_cat_bar.html' %} {% include 'nav_cat_bar.html' %}
@ -69,52 +64,7 @@
{% endblock %} {% endblock %}
{% block self_footer_js %} {% block self_footer_js %}
<script> <script>
$(document).ready(function(){
$("input.role").click(function(){
if($("input.role[value=GA]").is( ":checked" )){
$("#admin_groups").css("display", 'none');
}
else {
$("#admin_groups").css("display", 'block');
}
});
$('#use_password').click(function(){
if ($(this).is(':checked')){
$('#admin_account_password').css('display', 'block')
}
else {
$('#admin_account_password').css('display', 'none')
}
});
$('#use_publicKey').click(function(){
if ($(this).is(':checked')){
$('#admin_account_publicKey').css('display', 'block')
}
else {
$('#admin_account_publicKey').css('display', 'none')
}
});
});
var config = {
'.chosen-select' : {},
'.chosen-select-deselect' : {allow_single_deselect:true},
'.chosen-select-no-single' : {disable_search_threshold:10},
'.chosen-select-no-results': {no_results_text:'Oops, nothing found!'},
'.chosen-select-width' : {width:"95%"}
};
for (var selector in config) {
$(selector).chosen(config[selector]);
}
</script> </script>
<script src="/static/js/cropper/cropper.min.js"></script>
<script src="/static/js/datapicker/bootstrap-datepicker.js"></script>
{% endblock %} {% endblock %}

Loading…
Cancel
Save