import { find } from 'lodash';

export const parseEntityFunc = (host) => {
  const { network_interfaces: networkInterfaces } = host;
  const networkInterface = networkInterfaces && find(networkInterfaces, { id: host.primary_ip_id });
  const clockSpeed = host.cpu_brand.split('@ ')[1] || host.cpu_brand.split('@')[1];
  const clockSpeedFlt = parseFloat(clockSpeed.split('GHz')[0].trim());

  const additionalAttrs = {
    host_cpu: `${host.cpu_physical_cores} x ${Math.floor(clockSpeedFlt * 10) / 10} GHz`,
    target_type: 'hosts',
  };

  if (networkInterface) {
    additionalAttrs.host_ip_address = networkInterface.address;
    additionalAttrs.host_mac = networkInterface.mac;
  }

  return {
    ...host,
    ...additionalAttrs,
  };
};

export default { parseEntityFunc };

@@ -227,23 +227,134 @@
 _id %7D);%0A
+%0A
   
-const
+let clockSpeed = null;%0A  let clockSpeedFlt = null;%0A  let hostCpuOutput = null;%0A%0A  if (host && host.cpu_brand) %7B%0A   
  clockSp
@@ -424,21 +424,17 @@
 )%5B1%5D;%0A  
-const
+ 
  clockSp
@@ -493,50 +493,27 @@
 ));%0A
-%0A  const additionalAttrs = %7B%0A    host_cpu:
+    hostCpuOutput =
  %60$%7B
@@ -582,16 +582,78 @@
 10%7D GHz%60
+;%0A  %7D%0A%0A  const additionalAttrs = %7B%0A    host_cpu: hostCpuOutput
 ,%0A    ta

Fix busted delete host modal (#1359)