Exclude networks with no subnets angular

Nova doesnt allow to boot from a network which has
no subnet, so we should not show those networks on the
new instance launch angular panel.
On the python launch instance this was solved in patch
1b6807baf3

Change-Id: I8b94d45e95f8e22b579d04f6cec7345d947f8e12
Closes-Bug: #1237711
This commit is contained in:
Itxaka 2015-12-14 12:55:57 +01:00 committed by Itxaka
parent 1772f2da8a
commit feb0ad027f
2 changed files with 12 additions and 4 deletions

View File

@ -401,7 +401,10 @@
if (data.data.items.length === 1) {
model.newInstanceSpec.networks.push(data.data.items[0]);
}
push.apply(model.networks, data.data.items);
push.apply(model.networks,
data.data.items.filter(function(net) {
return net.subnets.length > 0;
}));
return data;
}

View File

@ -86,7 +86,11 @@
var neutronApi = {
getNetworks: function() {
var networks = [ { id: 'net-1' }, { id: 'net-2' } ];
var networks = [
{ id: 'net-1', subnets: [ { id: 'subnet1' } ] },
{ id: 'net-2', subnets: [ { id: 'subnet2' } ] },
{ id: 'net-3', subnets: []}
];
var deferred = $q.defer();
deferred.resolve({ data: { items: networks } });
@ -102,7 +106,8 @@
'net-2': [
{ name: 'port-3', device_owner: 'owner', fixed_ips: [], admin_state: 'DOWN' },
{ name: 'port-4', device_owner: '', fixed_ips: [], admin_state: 'DOWN' }
]
],
'net-3': []
};
var deferred = $q.defer();
@ -471,7 +476,7 @@
);
it('should set a network by default if only one network is available', function () {
var networks = [ { id: 'net-1' } ];
var networks = [ { id: 'net-1', subnets: [ { id: 'subnet1' } ] } ];
spyOn(neutronApi, 'getNetworks').and.callFake(function () {
var deferred = $q.defer();
deferred.resolve({ data: { items: networks } });