Browse Source

Adds connected VMs to migration/replica networks detail view

George Vrancianu 8 years ago
parent
commit
fa06ffd658
1 changed files with 10 additions and 17 deletions
  1. 10 17
      src/components/MigrationNetworks/MigrationNetworks.js

+ 10 - 17
src/components/MigrationNetworks/MigrationNetworks.js

@@ -50,11 +50,16 @@ class MigrationNetworks extends Component {
 
 
   getConnectedVms(networkId) {
   getConnectedVms(networkId) {
     let vms = []
     let vms = []
-    this.props.migration.instances.forEach((item) => {
-      if (item.networks.indexOf(networkId) != -1) {
-        vms.push(item.name)
+    for (let instanceName in this.props.migration.info) {
+      let instance = this.props.migration.info[instanceName]
+      if (instance.export_info.devices.nics.length) {
+        instance.export_info.devices.nics.forEach(nic => {
+          if (nic.network_name == networkId) {
+            vms.push(instanceName)
+          }
+        })
       }
       }
-    })
+    }
     return vms
     return vms
   }
   }
 
 
@@ -63,24 +68,12 @@ class MigrationNetworks extends Component {
       for (let i in props.migration.destination_environment.network_map) {
       for (let i in props.migration.destination_environment.network_map) {
         let newItem = {
         let newItem = {
           source_network: i,
           source_network: i,
-          connected_vms: "-",
+          connected_vms: this.getConnectedVms(i),
           destination_network: props.migration.destination_environment.network_map[i],
           destination_network: props.migration.destination_environment.network_map[i],
           destination_type: "Existing network"
           destination_type: "Existing network"
         }
         }
         this.listItems.push(newItem)
         this.listItems.push(newItem)
       }
       }
-      /*
-       props.migration.destination_environment.network_map.forEach((item) => {
-       //let connectedVms = this.getConnectedVms(item.id).join(", ")
-       let connectedVms = "-"
-       let newItem = {
-       source_network: item.name,
-       connected_vms: connectedVms,
-       destination_network: item.migrateNetwork,
-       destination_type: item.migrateNetwork == "Create new" ? "New network" : "Existing network"
-       }
-       this.listItems.push(newItem)
-       }*/
     }
     }
   }
   }