create cluster can config kolla version

Change-Id: I034d900677e03a9894b3d7a85be1fe1e58999b43
Signed-off-by: Jing Sun <sun.jing22@zte.com.cn>
This commit is contained in:
Jing Sun
2017-01-20 17:47:25 +08:00
committed by Zhijiang Hu
parent 3240484de4
commit 23ff1895e0
6 changed files with 83 additions and 17 deletions

View File

@@ -17,6 +17,8 @@ from openstack_dashboard.dashboards.environment.cluster import net_plane \
from openstack_dashboard.dashboards.environment.cluster import role \
as cluster_role
from openstack_dashboard.dashboards.environment.deploy import deploy_rule_lib
from openstack_dashboard.dashboards.environment.version import views \
as version_views
import logging
LOG = logging.getLogger(__name__)
@@ -49,6 +51,17 @@ class CreateView(views.HorizonTemplateView):
cluster_lists = [c for c in clusters]
context['clusters'] = cluster_lists
context["roles"] = self.get_roles_data()
backend_types = api.daisy.backend_types_get(self.request)
backend_types_dict = backend_types.to_dict()
if len(backend_types_dict['default_backend_types']) == 0:
context['hide_templates'] = True
context['target_system_list'] = []
else:
context['target_system_list'] = \
backend_types_dict['default_backend_types'].split(',')
context['tecs_version_list'] = \
version_views.get_kolla_version_list(self.request)
return context
@@ -67,7 +80,9 @@ def create_submit(request):
name=cluster["cluster_name"],
description=cluster["description"],
networking_parameters=cluster["networking_parameters"],
use_dns=cluster["use_dns"])
use_dns=cluster["use_dns"],
target_systems=cluster["target_systems"],
tecs_version_id=cluster["tecs_version_id"])
cluster_new.append({
"id": cluster_created.id
})

View File

@@ -12,7 +12,7 @@
return false;
return true;
}
$(function(){
$('.form-cluster-validator').bootstrapValidator({
message: 'This value is not valid',
@@ -45,7 +45,19 @@
}
});
});
function get_target_system_values(){
var systems = "os"
{% for target in target_system_list %}
if ($("#target_system_{{ target }}").attr("checked")){
systems += "+" + $("#target_system_{{ target }}").val();
}
{% endfor %}
return systems;
}
function get_network_values(){
var networking_parameters = {
"base_mac": $("#base_mac").val(),
@@ -85,6 +97,31 @@
</select>
</div>
</div>
<div style="clear:both" class="form-group">
<label style="text-align:right;" for="target_system_os" class="col-sm-3 control-label">{% trans 'Target system' %}</label>
<div style="float:left;" class="col-sm-4">
<label class="radio-inline" style="font-size:120%;">
<input type="checkbox" id="target_system_os" value="os" checked="checked" disabled="disabled">os
</label>
{% for target in target_system_list %}
{% if target != "proton" %}
<label class="radio-inline" style="font-size:120%;">
<input type="checkbox" id="target_system_{{ target }}" class="target_system NO_CHANGE" value="{{ target }}">{{ target }}
</label>
{% endif %}
{% endfor %}
</div>
</div>
<div style="clear:both" class="form-group form-default-tecs">
<label style="text-align:right;" for="default_tecs" class="col-sm-3 control-label">{% trans 'Default KOLLA' %}</label>
<div style="float:left;" class="col-sm-4">
<select id="default_tecs" name="default_tecs" class="form-control">
{% for tecs in tecs_version_list %}
<option value="{{ tecs.version_id }}">{{ tecs.version_name }}</option>
{% endfor %}
</select>
</div>
</div>
<div style="clear:both" class="form-group">
<label style="text-align:right;" for="description" class="col-sm-3 control-label">{% trans 'Description' %}</label>
<div style="float:left;" class="col-sm-4">

View File

@@ -1,4 +1,4 @@
{% extends 'base.html' %}
{% extends 'base.html' %}
{% load i18n %}
{% block title %}
@@ -19,6 +19,8 @@
"cluster_name": $("#cluster_name").val(),
"networking_parameters": get_network_values(),
"use_dns": $("#use_dns").val(),
"target_systems": get_target_system_values(),
"tecs_version_id": $("#default_tecs").val(),
"description":$("#description").val()
}
var role_info = {};
@@ -68,12 +70,12 @@
var url = "{% url 'horizon:environment:cluster:create_submit' %}";
do_post(url, JSON.stringify(params), goto_select_host, goto_modify_host);
}
}
function goto_select_host(cluster_list){
if (cluster_list.length > 0){
window.location = "/dashboard/environment/deploy/"
+ cluster_list[0].id
window.location = "/dashboard/environment/deploy/"
+ cluster_list[0].id
+ "/selecthosts";
}
}
@@ -81,14 +83,14 @@
function goto_modify_host(cluster_list){
if (cluster_list.length > 0){
$("#cluster_create_modal").data("cluster_id", cluster_id);
}
}
}
function operate_cluster(){
$(".form-cluster-validator").data('bootstrapValidator').resetForm();
$(".form-roles-validator").data('bootstrapValidator').resetForm();
$(".form-net-plane").data('bootstrapValidator').resetForm();
$(".form-cluster-validator").data('bootstrapValidator').validate()
if (!$(".form-cluster-validator").data('bootstrapValidator').isValid()){
$('#cluster_create_modal a[href="#cluster_baseinfo"]').tab('show')
@@ -97,13 +99,13 @@
$(".form-roles-validator").data('bootstrapValidator').validate()
if (!$(".form-roles-validator").data('bootstrapValidator').isValid()){
$('#cluster_create_modal a[href="#cluster_role"]').tab('show')
$('#cluster_create_modal a[href="#cluster_role"]').tab('show')
return;
}
$(".form-net-plane").data("bootstrapValidator").validate()
if (!$(".form-net-plane").data('bootstrapValidator').isValid()){
$('#cluster_create_modal a[href="#cluster_netplane"]').tab('show')
$('#cluster_create_modal a[href="#cluster_netplane"]').tab('show')
return;
}

View File

@@ -9,11 +9,11 @@
function reload_cluster_window(){
window.location = "/dashboard/environment/";
}
function operate_close(){
$(".form-cluster-validator").data('bootstrapValidator').resetForm()
}
function delete_cluster(cluster_id){
title = '{% trans "Confirm to delete" %}'
body = '{% trans "Are you sure to delete this cluster?" %}'
@@ -29,7 +29,7 @@
modal.modal('hide')
});
}
</script>
{% endblock %}
@@ -59,7 +59,7 @@
</div>
<div>
<div STYLE="float:left;width:60%;height:25px">{% trans "Target system:" %}</div>
<div STYLE="float:left;width:40%;">{{cluster.target_system}}</div>
<div STYLE="float:left;width:40%;">{{cluster.target_systems}}</div>
</div>
<div>
<div STYLE="float:left;width:60%;height:25px">{% trans "Auto scale:" %}</div>

View File

@@ -24,8 +24,6 @@ class OverviewView(views.HorizonTemplateView):
qp = {"cluster_id": cluster.id}
host_list = api.daisy.host_list(self.request, filters=qp)
cluster.host_count = len(host_list)
cluster.target_system = "OS+TECS"
cluster.os = "CGSL"
cluster.model = _("Default")
host_info = deploy_view.format_deploy_info(host_list)
cluster.host_deploying = host_info[0]['count']

View File

@@ -673,3 +673,17 @@ class UpdateVersionView(forms.ModalFormView):
def get_initial(self):
ret = {'version_id': self.kwargs["version_id"]}
return ret
def get_kolla_version_list(request):
kolla_version_list = []
versions = api.daisy.version_list(request, filters={"type": "kolla"})
version_lists = [c for c in versions]
version_lists.reverse()
for version in version_lists:
tecs_version_list.append({
"version_id": version.id,
"version_name": version.name
})
return kolla_version_list