Re-enable network-level egress UI

-Adds complete egress rules tab to the network detail view

-Updated server calls per functional spec

-Add localization labels
This commit is contained in:
Brian Federle 2012-11-28 11:57:22 -08:00
parent 936f84bb7b
commit 66e04c9bf9
3 changed files with 178 additions and 2 deletions

View File

@ -17,6 +17,7 @@
#new labels (begin) **********************************************************************************************
label.egress.rules=Egress rules
message.acquire.new.ip.vpc=Please confirm that you would like to acquire a new IP for this VPC.
label.zoneWizard.trafficType.management=Mangement: Traffic between CloudStack\'s internal resources, including any components that communicate with the Management Server, such as hosts and CloudStack system VMs
label.zoneWizard.trafficType.public=Public: Traffic between the internet and virtual machines in the cloud.

View File

@ -25,6 +25,7 @@ under the License.
<% long now = System.currentTimeMillis(); %>
<script language="javascript">
dictionary = {
'label.egress.rules': '<fmt:message key="label.egress.rules"/>',
'message.acquire.new.ip.vpc': '<fmt:message key="message.acquire.new.ip.vpc"/>',
'label.quickview': '<fmt:message key="label.quickview"/>',
'label.migrate.to.host': '<fmt:message key="label.migrate.to.host"/>',

View File

@ -833,13 +833,13 @@
}
});
var hiddenTabs = ['egressRules']; // Disable egress UI, for now
var hiddenTabs = [];
if (!networkOfferingHavingELB) {
hiddenTabs.push("addloadBalancer");
}
if (!hasNetworkACL || isVPC) {
if (isVPC) {
hiddenTabs.push('egressRules');
}
@ -1016,6 +1016,180 @@
}
},
egressRules: {
title: 'label.egress.rules',
custom: function(args) {
var context = args.context;
return $('<div>').multiEdit({
context: context,
noSelect: true,
noHeaderActionsColumn: true,
fields: {
'cidrlist': { edit: true, label: 'label.cidr', isOptional: true },
'protocol': {
label: 'label.protocol',
select: function(args) {
args.$select.change(function() {
var $inputs = args.$form.find('th, td');
var $icmpFields = $inputs.filter(function() {
var name = $(this).attr('rel');
return $.inArray(name, [
'icmptype',
'icmpcode'
]) > -1;
});
var $otherFields = $inputs.filter(function() {
var name = $(this).attr('rel');
return name != 'cidrlist' &&
name != 'icmptype' &&
name != 'icmpcode' &&
name != 'protocol' &&
name != 'add-rule';
});
if ($(this).val() == 'icmp') {
$icmpFields.show();
$otherFields.hide();
} else if ($(this).val() == 'all') {
$icmpFields.hide();
$otherFields.hide();
} else {
$icmpFields.hide();
$otherFields.show();
}
});
args.response.success({
data: [
{ name: 'tcp', description: 'TCP' },
{ name: 'udp', description: 'UDP' },
{ name: 'icmp', description: 'ICMP' },
{ name: 'all', description: 'All' }
]
});
}
},
'startport': { edit: true, label: 'label.start.port' },
'endport': { edit: true, label: 'label.end.port' },
'icmptype': { edit: true, label: 'ICMP.type', isHidden: true },
'icmpcode': { edit: true, label: 'ICMP.code', isHidden: true },
'add-rule': {
label: 'label.add',
addButton: true
}
},
add: {
label: 'label.add',
action: function(args) {
var data = {
protocol: args.data.protocol,
cidrlist: args.data.cidrlist,
networkid: args.context.networks[0].id
};
if (args.data.icmptype && args.data.icmpcode) { // ICMP
$.extend(data, {
icmptype: args.data.icmptype,
icmpcode: args.data.icmpcode
});
} else { // TCP/UDP
$.extend(data, {
startport: args.data.startport,
endport: args.data.endport
});
}
$.ajax({
url: createURL('createEgressFirewallRule'),
data: data,
dataType: 'json',
async: true,
success: function(json) {
var jobId = json.createegressfirewallruleresponse.jobid;
args.response.success({
_custom: {
jobId: jobId
},
notification: {
label: 'label.add.egress.rule',
poll: pollAsyncJobResult
}
});
},
error: function(json) {
args.response.error(parseXMLHttpResponse(json));
}
});
}
},
actions: {
destroy: {
label: 'label.remove.rule',
action: function(args) {
$.ajax({
url: createURL('deleteEgressFirewallRule'),
data: {
id: args.context.multiRule[0].id
},
dataType: 'json',
async: true,
success: function(data) {
var jobID = data.deleteegressfirewallruleresponse.jobid;
args.response.success({
_custom: {
jobId: jobID
},
notification: {
label: 'label.remove.egress.rule',
poll: pollAsyncJobResult
}
});
},
error: function(json) {
args.response.error(parseXMLHttpResponse(json));
}
});
}
}
},
ignoreEmptyFields: true,
dataProvider: function(args) {
$.ajax({
url: createURL('listEgressFirewallRules'),
data: {
listAll: true,
networkid: args.context.networks[0].id
},
dataType: 'json',
async: true,
success: function(json) {
var response = json.listegressfirewallrulesresponse.firewallrule ?
json.listegressfirewallrulesresponse.firewallrule : [];
args.response.success({
data: $.map(response, function(rule) {
if (rule.protocol == 'all') {
$.extend(rule, {
startport: 'All',
endport: 'All'
});
}
return rule;
})
});
}
});
}
});
}
},
addloadBalancer: {
title: 'label.add.load.balancer',
custom: function(args) {