Commit c457c4f8 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou

ui: Optionally group public networks by name

If setting ``UI_GROUP_PUBLIC_NETWORKS`` is set to True, public networks will
be grouped by their name in networks view.
parent 768d6d99
......@@ -240,6 +240,10 @@ Cyclades UI
- New setting ``UI_SSH_SUPPORT_OSFAMILY_EXCLUDE_LIST``. A list of image OS
families for which ui will disable ssh key injection in machine wizard.
- Setting ``UI_SUPPORT_SSH_OS_LIST`` removed and no longer used.
- Group public networks by name if setting ``UI_GROUP_PUBLIC_NETWORKS`` is set
to True.
- Setting ``UI_GROUPED_PUBLIC_NETWORK_NAME`` has been deprecated and no longer
used.
Cyclades Userdata
......
......@@ -158,12 +158,9 @@
## virtual machines from the network.
#UI_NETWORK_STRICT_DESTROY = True
#
## Whether or not to group public networks nics in a single network view
## Whether or not to group public networks by name in networks list view
#UI_GROUP_PUBLIC_NETWORKS = True
#
## The name of the grouped network view
#UI_GROUPED_PUBLIC_NETWORK_NAME = 'Internet'
#
################
## UI EXTENSIONS
################
......
......@@ -177,9 +177,6 @@ UI_NETWORK_STRICT_DESTROY = True
# Whether or not to group public networks nics in a single network view
UI_GROUP_PUBLIC_NETWORKS = True
# The name of the grouped network view
UI_GROUPED_PUBLIC_NETWORK_NAME = 'Internet'
###############
# UI EXTENSIONS
......
......@@ -398,7 +398,8 @@
return model;
},
get_fetcher: function(interval, increase, fast, increase_after_calls, max, initial_call, params) {
get_fetcher: function(interval, increase, fast, increase_after_calls,
max, initial_call, params) {
var fetch_params = params || {};
var handler_options = {};
......
......@@ -246,7 +246,7 @@
synnefo.storage.ports.create(data, {complete: cb});
}
});
models.CombinedPublicNetwork = models.Network.extend({
defaults: {
'admin_state_up': true,
......@@ -258,13 +258,18 @@
'rename_disabled': true,
'subnets': []
},
initialize: function() {
group_by: 'name',
group_networks: [],
initialize: function(attributes) {
this.groupKey = attributes.name;
var self = this;
this.ports = new Backbone.FilteredCollection(undefined, {
collection: synnefo.storage.ports,
collectionFilter: function(m) {
return m.get('network') && m.get('network').get('is_public');
return m.get('network') &&
m.get('network').get(self.group_by) == self.groupKey;
}
});
this.set({ports: this.ports});
......@@ -278,15 +283,16 @@
}
});
this.set({available_floating_ips: this.available_floating_ips});
models.Network.__super__.initialize.apply(this, arguments);
},
})
this.set({name: attributes.name || 'Internet'});
models.Network.__super__.initialize.apply(this, attributes);
}
});
models.Networks = models.NetworkCollection.extend({
model: models.Network,
path: 'networks',
details: true,
parse: function(resp) {
var data = _.map(resp.networks, function(net) {
if (!net.name) {
......
......@@ -246,6 +246,10 @@
views.NetworkPortView = views.ext.ModelView.extend({
tpl: '#network-port-view-tpl',
error_status: function(status) {
return status == "ERROR"
},
vm_logo_url: function(vm) {
if (!this.model.get('vm')) { return '' }
return synnefo.ui.helpers.vm_icon_path(this.model.get('vm'), 'medium');
......@@ -533,9 +537,14 @@
model_view_cls: views.NetworkView,
create_view_cls: views.NetworkCreateView,
quota_key: 'cyclades.network.private',
group_key: 'name',
group_network: function(n) {
return n.get('is_public')
},
init: function() {
this.public_added = false;
this.grouped_networks = {};
views.NetworksCollectionView.__super__.init.apply(this, arguments);
},
......@@ -549,29 +558,37 @@
},
add_model: function(m) {
if (m.get('is_public') && !this.public_added) {
this.combined_public = new models.networks.CombinedPublicNetwork();
this.combined_public_view = new views.NetworkView({
model: this.combined_public
});
this.add_model_view(this.combined_public_view, this.combined_public, 0);
this.public_added = true;
var CombinedPublic = models.networks.CombinedPublicNetwork;
if (this.group_network(m) && synnefo.config.group_public_networks) {
var group_value = m.get(this.group_key);
if (!(group_value in this.grouped_networks)) {
var combined_public = new CombinedPublic({name: group_value});
combined_public_view = new views.NetworkView({
model: combined_public
});
this.add_model_view(combined_public_view,
combined_public, 0);
this.grouped_networks[group_value] = combined_public;
}
}
return views.NetworksCollectionView.__super__.add_model.call(this, m);
},
remove_model: function(m) {
if (m.id == 'snf-combined-public-network') {
return;
if (m.id == 'snf-combined-public-network' ||
(this.group_network(m) &&
synnefo.config.group_public_networks)) {
return false;
} else {
return views.NetworksCollectionView.__super__.remove_model.call(this, m);
}
},
get_model_view_cls: function(m) {
if (!this.public_added) {
}
if (m.get('is_public')) {
if (m.id == 'snf-combined-public-network' ||
(this.group_network(m) &&
synnefo.config.group_public_networks)) {
return false;
}
return views.NetworksCollectionView.__super__.get_model_view_cls.apply(this, [m]);
......@@ -1061,11 +1078,11 @@
}
// combined public
this.combined_public = new models.networks.CombinedPublicNetwork();
this.combined_public.set({noselect: true,
this.floating_public = new models.networks.CombinedPublicNetwork('Internet');
this.floating_public.set({noselect: true,
name: 'Internet (public IPv4)',
forced: false});
this.public_networks.add(this.combined_public);
this.public_networks.add(this.floating_public);
model_attrs = {
public_collection: this.public_networks,
......
......@@ -668,7 +668,6 @@
synnefo.config.network_strict_destroy = {{ network_strict_destroy }};
synnefo.config.network_allow_multiple_destory = {{ network_allow_multiple_destroy }};
synnefo.config.group_public_networks = {{ group_public_networks }};
synnefo.config.grouped_public_network_name = {{ grouped_public_network_name|safe }};
synnefo.config.no_fqdn_message = {{ no_fqdn_message|safe }};
synnefo.config.automatic_network_range_format = {{ automatic_network_range_format|safe }};
synnefo.config.custom_image_help_url = '{{ custom_image_help_url|safe }}';
......
......@@ -62,7 +62,7 @@
<div id="vm-port-ips-tpl" class="hidden">
<div class="collection fixed-ips-list">
<div class="empty-list hidden">pending ...</div>
<div class="empty-list hidden">Not IPs set</div>
<div class="items-list clearfix"></div>
</div>
</div>
......
......@@ -111,7 +111,9 @@
src="{{ SYNNEFO_IMAGES_URL }}icons/indicators/small/progress.gif"
class="progress-indicator" />
</div>
<div data-rv-show="model.network.is_public" class="firewall">
<div data-rv-show="model.network.is_public"
class="firewall"
data-rv-hide="model.vm.status|error_status">
<img data-rv-show="model.firewall_running"
src="{{ SYNNEFO_IMAGES_URL }}icons/indicators/small/progress.gif"
class="progress-indicator" />
......
......@@ -158,9 +158,6 @@ AUTOMATIC_NETWORK_RANGE_FORMAT = getattr(settings,
"192.168.%d.0/24").replace("%d",
"{0}")
GROUP_PUBLIC_NETWORKS = getattr(settings, 'UI_GROUP_PUBLIC_NETWORKS', True)
GROUPED_PUBLIC_NETWORK_NAME = \
getattr(settings, 'UI_GROUPED_PUBLIC_NETWORK_NAME', 'Internet')
DEFAULT_FORCED_SERVER_NETWORKS = \
getattr(settings, "CYCLADES_FORCED_SERVER_NETWORKS", [])
......@@ -245,7 +242,6 @@ def home(request):
json.dumps(NETWORK_ALLOW_MULTIPLE_DESTROY),
'automatic_network_range_format':
json.dumps(AUTOMATIC_NETWORK_RANGE_FORMAT),
'grouped_public_network_name': json.dumps(GROUPED_PUBLIC_NETWORK_NAME),
'group_public_networks': json.dumps(GROUP_PUBLIC_NETWORKS),
'hotplug_enabled': json.dumps(HOTPLUG_ENABLED),
'diagnostics_update_interval': json.dumps(DIAGNOSTICS_UPDATE_INTERVAL),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment