Prevent configuring fixed IP if building more than one member
Changed test-requirements.txt to match kilo-eol requirements Change-Id: Ib2be0fa8742d0d066ec1115bfbfb3209a7c2d1f3 Closes-Bug: #1582527 (cherry picked from commit0d1f36ac0b
) (cherry picked from commit721f58a56f
)
This commit is contained in:
parent
8f059cdac1
commit
94a3cf79d6
|
@ -53,8 +53,8 @@
|
|||
<input id="fixed_ip" type="text"/>
|
||||
<input id="set_ip_button" type="button" value="Add"/>
|
||||
<input id="remove" type="button" value="Remove"/>
|
||||
<p id="errors" style="color:red" ></p>
|
||||
</div>
|
||||
<div id="errors" class="alert alert-message alert-danger" style="display:none"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
|
|
@ -298,7 +298,7 @@ def check_ip_availability(request):
|
|||
fixed_ip = request.GET.get('fixed_ip')
|
||||
response = {'error': 'IP address is not within the allocated pool range'}
|
||||
subnets = request.GET.get('subnets')
|
||||
subnets = subnets.split(";")
|
||||
subnets = subnets.split(":")
|
||||
for subnet in subnets:
|
||||
subnet_details = subnet.split(",")
|
||||
try:
|
||||
|
@ -306,7 +306,8 @@ def check_ip_availability(request):
|
|||
if IPAddress(fixed_ip) >= IPAddress(subnet_details[1]) and \
|
||||
IPAddress(fixed_ip) <= IPAddress(subnet_details[2]):
|
||||
fixed_ips = "ip_address=" + fixed_ip
|
||||
ports = api.neutron.port_list(request, fixed_ips=fixed_ips)
|
||||
ports = api.neutron.port_list(request,
|
||||
tenant_id=request.user.tenant_id, fixed_ips=fixed_ips)
|
||||
if ports:
|
||||
response = {"inuse": False,
|
||||
"error": "IP address already in use"}
|
||||
|
|
|
@ -415,7 +415,7 @@ class SetGroupAction(workflows.Action):
|
|||
if subnet_dedails is None:
|
||||
subnet_dedails = subnet['cidr']
|
||||
else:
|
||||
subnet_dedails = ";" + subnet['cidr']
|
||||
subnet_dedails = subnet_dedails + ";" + subnet['cidr']
|
||||
allocation_pools = subnet['allocation_pools']
|
||||
if allocation_pools:
|
||||
start = allocation_pools[0]['start']
|
||||
|
@ -430,7 +430,13 @@ class SetGroupAction(workflows.Action):
|
|||
|
||||
class Meta(object):
|
||||
name = _("Groups")
|
||||
help_text = _("Select groups for launching the member instance in.")
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(SetGroupAction, self).clean()
|
||||
if not cleaned_data.get("network", None):
|
||||
raise forms.ValidationError(_(
|
||||
'At least one group must be selected.'))
|
||||
return cleaned_data
|
||||
|
||||
def populate_network_choices(self, request, context):
|
||||
try:
|
||||
|
@ -446,7 +452,7 @@ class SetGroupAction(workflows.Action):
|
|||
if subnet_dedails is None:
|
||||
subnet_dedails = subnet['cidr']
|
||||
else:
|
||||
subnet_dedails = ";" + subnet['cidr']
|
||||
subnet_dedails += ";" + subnet['cidr']
|
||||
allocation_pools = subnet['allocation_pools']
|
||||
if allocation_pools:
|
||||
start = allocation_pools[0]['start']
|
||||
|
|
|
@ -59,9 +59,10 @@ member = {
|
|||
$("ul#available_group li[name^='"+ ptg +"']").css("background-color", "");
|
||||
$("#fixed_ip_div").hide()
|
||||
}
|
||||
member.control_max_instances()
|
||||
};
|
||||
var updateForm = function() {
|
||||
var groupListId = $("#groupListId");
|
||||
var groupListId = $("#groupListId .multiple-checkbox");
|
||||
var lists = groupListId.find("li").attr('data-index',100);
|
||||
var active_groups = $("#selected_network > li").map(function(){
|
||||
return $(this).attr("name");
|
||||
|
@ -83,7 +84,7 @@ member = {
|
|||
};
|
||||
|
||||
$("#groupListSortContainer").show();
|
||||
$("#groupListIdContainer").hide();
|
||||
$("#groupListId .form-group").hide()
|
||||
self.init_group_list();
|
||||
// Make sure we don't duplicate the groups in the list
|
||||
available_group.empty();
|
||||
|
@ -124,11 +125,25 @@ member = {
|
|||
}
|
||||
}).disableSelection();
|
||||
},
|
||||
|
||||
control_max_instances: function(){
|
||||
$("#id_count").attr('readonly', false)
|
||||
$("#id_network").each(function() {
|
||||
$input = $(this).find('li input');
|
||||
value = $input.val();
|
||||
fields = value.split(":")
|
||||
if ($input.is(":checked") && fields.length == 3){
|
||||
// fixed ip is associated, dont allow Instance Count > 1
|
||||
$("#id_count").attr('readonly', true)
|
||||
return
|
||||
}
|
||||
});
|
||||
},
|
||||
allow_fixed_ip: function(selected_group){
|
||||
if (member.allowed() == false)
|
||||
return
|
||||
fixed_ip = ""
|
||||
$("#fixed_ip").val("")
|
||||
$("#errors").text("")
|
||||
$("#errors").hide().text("")
|
||||
$("#fixed_ip_div").show()
|
||||
ptg = $(selected_group).attr('name')
|
||||
$(selected_group).siblings().css( "background-color", "");
|
||||
|
@ -152,12 +167,23 @@ member = {
|
|||
if (values.length == 3)
|
||||
$("#fixed_ip").val(values[2]);
|
||||
},
|
||||
allowed: function(){
|
||||
if($("#id_count").val() > 1){
|
||||
$("#errors").show().text("You cannot assign fixed IPs " +
|
||||
"if more than one instance is requested.")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
associate_fixed_ip: function(){
|
||||
if (member.allowed() == false)
|
||||
return
|
||||
ptg = $("#fixed_ip").attr("data-ptg")
|
||||
subnet = $("#fixed_ip").attr("data-subnet")
|
||||
subnet = subnet.replace(";", ":")
|
||||
fixed_ip = $("#fixed_ip").val()
|
||||
if (!fixed_ip || 0 === fixed_ip.length ){
|
||||
$("#errors").text("Enter valid IP address")
|
||||
$("#errors").show().text("Enter valid IP address")
|
||||
return
|
||||
}
|
||||
$.ajax({
|
||||
|
@ -167,6 +193,7 @@ member = {
|
|||
success: function(response) {
|
||||
if(response.inuse){
|
||||
horizon.alert('success', "IP address '" + fixed_ip +"' is available.")
|
||||
subnet = subnet.replace(":", ";")
|
||||
value = ptg + ":" + subnet + ":" + fixed_ip
|
||||
selected_element = $(".multiple-checkbox #id_network li input[value^='"+ ptg +"']");
|
||||
selected_element.val(value)
|
||||
|
@ -178,18 +205,21 @@ member = {
|
|||
}
|
||||
$("ul#selected_network li[name^='"+ ptg +"']").css("background-color", "");
|
||||
$("#fixed_ip_div").hide()
|
||||
$("#errors").hide().text("")
|
||||
member.control_max_instances()
|
||||
}
|
||||
else{
|
||||
$("#errors").text(response.error)
|
||||
$("#errors").show().text(response.error)
|
||||
}
|
||||
},
|
||||
error: function(response) {
|
||||
$("#errors").text(response)
|
||||
$("#errors").show().text(response)
|
||||
}
|
||||
});
|
||||
},
|
||||
disassociate_fixed_ip: function(){
|
||||
ptg = $("#fixed_ip").attr("data-ptg")
|
||||
$("#errors").hide().text("")
|
||||
subnet = $("#fixed_ip").attr("data-subnet")
|
||||
value = ptg + ":" + subnet
|
||||
selected_element = $(".multiple-checkbox #id_network li input[value^='"+ ptg +"']");
|
||||
|
@ -197,14 +227,16 @@ member = {
|
|||
$("#selected_network li[name^='"+ ptg +"'] strong").text("")
|
||||
$("#fixed_ip_div").hide()
|
||||
$("ul#selected_network li").css("background-color", "");
|
||||
member.control_max_instances()
|
||||
},
|
||||
groups_init: function() {
|
||||
// Initialise the drag and drop group list
|
||||
member.generate_grouplist_html();
|
||||
|
||||
// allocate fixed ip
|
||||
$(document).on('click', "ul#selected_network li", function(){
|
||||
$(document).on('click', "ul#selected_network li", function(e){
|
||||
member.allow_fixed_ip(this);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
$("#set_ip_button").click(function(){
|
||||
|
@ -214,5 +246,9 @@ member = {
|
|||
$("#remove").click(function(){
|
||||
member.disassociate_fixed_ip()
|
||||
});
|
||||
help = $("label[for=id_count]").parent().find('span.help-icon')
|
||||
title = help.attr("title")
|
||||
title = title + " Fixed IP can be assigned only when Instance Count is 1"
|
||||
help.attr("title", title)
|
||||
}
|
||||
};
|
||||
|
|
|
@ -330,10 +330,6 @@ function run_tests {
|
|||
export SKIP_UNITTESTS=1
|
||||
fi
|
||||
|
||||
if [ $with_selenium -eq 0 -a $integration -eq 0 ]; then
|
||||
testopts="$testopts --exclude-dir=gbpui/openstack_dashboard/test/integration_tests"
|
||||
fi
|
||||
|
||||
if [ $selenium_headless -eq 1 ]; then
|
||||
export SELENIUM_HEADLESS=1
|
||||
fi
|
||||
|
@ -554,4 +550,4 @@ if [ $runserver -eq 1 ]; then
|
|||
fi
|
||||
|
||||
# Full test suite
|
||||
run_tests || exit
|
||||
run_tests || exit
|
||||
|
|
|
@ -8,22 +8,22 @@
|
|||
#
|
||||
# Hacking should appear first in case something else depends on pep8
|
||||
|
||||
-e git://github.com/openstack/horizon.git@stable/kilo#egg=horizon
|
||||
hacking>=0.10.0,<0.11
|
||||
-e git://github.com/openstack/horizon.git@kilo-eol#egg=horizon
|
||||
hacking<0.11,>=0.10.0
|
||||
#
|
||||
coverage>=3.6
|
||||
django-nose
|
||||
mock>=1.0
|
||||
mock<1.1.0,>=1.0
|
||||
mox>=0.5.3
|
||||
nodeenv>=0.9.4 # BSD License
|
||||
nose
|
||||
nose-exclude
|
||||
nosehtmloutput>=0.0.3
|
||||
nosexcover
|
||||
openstack.nose_plugin>=0.7
|
||||
oslosphinx>=2.5.0,<2.6.0 # Apache-2.0
|
||||
openstack.nose-plugin>=0.7
|
||||
oslosphinx<2.6.0,>=2.5.0 # Apache-2.0
|
||||
selenium
|
||||
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
|
||||
testtools>=0.9.36,!=1.2.0
|
||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||
testtools!=1.2.0,<2.0.0,>=0.9.36
|
||||
# This also needs xvfb library installed on your OS
|
||||
xvfbwrapper>=0.1.3 #license: MIT
|
||||
|
|
Loading…
Reference in New Issue