Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
Separate cloud networks from lans
Browse files Browse the repository at this point in the history
The current implmentation does not differentiate between lans and
cloud_networks when constructing an infra mapping's list view item.
Consequently, ID collisions are possible, resulting with the
visualization incorrectly reporting that networks are missing.

#795
https://bugzilla.redhat.com/show_bug.cgi?id=1650374
  • Loading branch information
michaelkro committed Nov 17, 2018
1 parent 8957e39 commit 6146aa3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 9 deletions.
Expand Up @@ -25,3 +25,18 @@ export const INFRA_MAPPINGS_SORT_FIELDS = [
isNumeric: true
}
];

export const MAPPING_TYPE_RESOURCE_MAP = {
openstack: {
networks: {
source: 'Lan',
target: 'CloudNetwork'
}
},
rhevm: {
networks: {
source: 'Lan',
target: 'Lan'
}
}
};
@@ -1,5 +1,7 @@
import Immutable from 'seamless-immutable';

import { networkKey } from '../../../common/networkKey';
import { MAPPING_TYPE_RESOURCE_MAP } from './InfrastructureMappingsListConstants';

export const getMappingType = transformation_mapping_items => {
const isOSPMapping =
Expand Down Expand Up @@ -145,7 +147,12 @@ export const mapInfrastructureMappings = (
openstack: [],
rhevm: {}
};
const clusterLans = {};

const networksMap = {
CloudNetwork: {},
Lan: {}
};

clusters.forEach(cluster => {
if (cluster.storages && cluster.storages.length) {
cluster.storages.forEach(datastore => {
Expand All @@ -154,7 +161,7 @@ export const mapInfrastructureMappings = (
}
if (cluster.lans && cluster.lans.length) {
cluster.lans.forEach(lan => {
clusterLans[lan.id] = cluster.id;
networksMap.Lan[lan.id] = cluster.id;
});
}
});
Expand All @@ -166,7 +173,7 @@ export const mapInfrastructureMappings = (
}
if (tenant.cloud_networks && tenant.cloud_networks.length) {
tenant.cloud_networks.forEach(network => {
clusterLans[network.id] = tenant.id;
networksMap.CloudNetwork[network.id] = tenant.id;
});
}
});
Expand Down Expand Up @@ -211,18 +218,23 @@ export const mapInfrastructureMappings = (
const targetNetworks = {};
let missingNetworks = false;
for (const networkMapping of networkMappingItems) {
if (!(networkMapping.source_id in clusterLans)) {
if (!(networkMapping.source_id in networksMap[networkMapping.source_type])) {
missingNetworks = true;
break;
}
if (!(networkMapping.destination_id in clusterLans)) {
if (!(networkMapping.destination_id in networksMap[networkMapping.destination_type])) {
missingNetworks = true;
break;
}
const sourceCluster = clusters.find(c => c.id === clusterLans[networkMapping.source_id]);
const targetCluster = targetComputeMap[mappingType].find(c => c.id === clusterLans[networkMapping.destination_id]);
const sn = networks.find(d => d.id === networkMapping.source_id);
const tn = targetNetworksMap[mappingType].find(d => d.id === networkMapping.destination_id);

const sourceCluster = clusters.find(
c => c.id === networksMap[MAPPING_TYPE_RESOURCE_MAP[mappingType].networks.source][networkMapping.source_id]
);
const targetCluster = targetComputeMap[mappingType].find(
c => c.id === networksMap[MAPPING_TYPE_RESOURCE_MAP[mappingType].networks.target][networkMapping.destination_id]
);
const sn = networks.find(network => network.id === networkMapping.source_id);
const tn = targetNetworksMap[mappingType].find(network => network.id === networkMapping.destination_id);

if (sourceCluster && targetCluster && sn && tn) {
const sourceNetwork = Immutable.set(sn, 'clusterId', sourceCluster.id);
Expand Down

0 comments on commit 6146aa3

Please sign in to comment.