From a16f5f1da53fa5a3c1a8ec26b6d0cba6f0ed8983 Mon Sep 17 00:00:00 2001 From: Xabier Arbulu Insausti Date: Mon, 22 Jul 2024 09:49:10 +0200 Subject: [PATCH] Add IP addresses netmask discovery and visualization (#2793) * Discover agent network interfaces * Use simplied version of host payload with netmasks * Add netmask field and projection to host read model * Update host frontend views to combine netmask with ip address * Update e2e fixtures * Add netmasks to scenarios * Export function to build cidr notation address * Add missing netmask in scenario --- assets/js/lib/test-utils/data/hosts.js | 27 ++++++++ assets/js/lib/test-utils/factories/hosts.js | 1 + .../js/pages/HostDetailsPage/HostDetails.jsx | 12 +++- .../HostDetailsPage/HostDetails.stories.jsx | 8 +++ .../HostDetailsPage/HostDetails.test.jsx | 64 ++++++++++++++----- .../pages/HostDetailsPage/HostDetailsPage.jsx | 1 + assets/js/pages/HostsList/HostsList.jsx | 3 +- assets/js/pages/HostsList/HostsList.test.jsx | 4 +- .../payloads/host_discovery_payload.ex | 1 + lib/trento/discovery/policies/host_policy.ex | 63 ++++++++++-------- .../hosts/projections/host_projector.ex | 21 +++++- .../hosts/projections/host_read_model.ex | 1 + lib/trento_web/openapi/v1/schema/host.ex | 6 ++ ...716143321_add_netmasks_host_read_model.exs | 9 +++ .../fixtures/host-details/selected_host.js | 2 +- .../hosts-overview/available_hosts.js | 20 +++--- test/fixtures/discovery/host_discovery.json | 1 + ...st_discovery_with_installation_source.json | 1 + ...54ce-ac9c-ae3fedaf40d4_host_discovery.json | 8 ++- ...5a9a-95c8-51ec38e50cfc_host_discovery.json | 7 ++ ...55d6-9874-8efde4d84c90_host_discovery.json | 7 ++ ...5849-aaa7-7c4a98b0c9ce_host_discovery.json | 7 ++ ...5013-9cf0-5eb4cf89898f_host_discovery.json | 7 ++ ...5969-a6b7-8b5a42de1971_host_discovery.json | 7 ++ ...54ce-ac9c-ae3fedaf40d4_host_discovery.json | 6 ++ ...5a9a-95c8-51ec38e50cfc_host_discovery.json | 7 ++ ...55d6-9874-8efde4d84c90_host_discovery.json | 7 ++ ...5849-aaa7-7c4a98b0c9ce_host_discovery.json | 7 ++ ...5013-9cf0-5eb4cf89898f_host_discovery.json | 7 ++ ...5969-a6b7-8b5a42de1971_host_discovery.json | 7 ++ ...495e-9f2d-bc50b872efaf_host_discovery.json | 8 +++ ...4254-b53a-3ff1d3b2a0ff_host_discovery.json | 6 ++ ...4c37-955a-fe16cadaaef4_host_discovery.json | 7 ++ ...4796-b073-f4cc04d2ca55_host_discovery.json | 6 ++ ...4eda-81c8-1e24578d9973_host_discovery.json | 6 ++ ...46ff-b6d0-9bfed42e387b_host_discovery.json | 7 ++ ...487e-a4eb-f3d4cf7c9543_host_discovery.json | 6 ++ ...-453b-b6b2-f3f971582dc_host_discovery.json | 6 ++ ...4214-afd4-b15160b0d521_host_discovery.json | 6 ++ ...46a4-a344-9e918648b117_host_discovery.json | 6 ++ ...44c3-a40b-b32d22872e74_host_discovery.json | 7 ++ ...58e7-91be-38fda8a833ea_host_discovery.json | 7 ++ ...54ce-ac9c-ae3fedaf40d4_host_discovery.json | 6 ++ ...54ca-b0de-fb27ffdc5deb_host_discovery.json | 7 ++ ...5e59-b820-83f66db8800c_host_discovery.json | 7 ++ ...5a9a-95c8-51ec38e50cfc_host_discovery.json | 7 ++ ...55d6-9874-8efde4d84c90_host_discovery.json | 7 ++ ...5804-b643-7f4ef22fecfd_host_discovery.json | 6 ++ ...53b7-9e99-ffb0f2e735bf_host_discovery.json | 7 ++ ...5005-896c-9275b1284534_host_discovery.json | 7 ++ ...5b07-8f9d-042be449d72b_host_discovery.json | 7 ++ ...5092-93e8-a744854f5085_host_discovery.json | 6 ++ ...5bda-bccb-f2248a12c992_host_discovery.json | 7 ++ ...5a16-8bc8-01df7dbb7384_host_discovery.json | 6 ++ ...5849-aaa7-7c4a98b0c9ce_host_discovery.json | 7 ++ ...538f-bff1-47d3a6580522_host_discovery.json | 7 ++ ...524e-b18c-3ef5187f504f_host_discovery.json | 6 ++ ...57a4-b302-6e4482227ab6_host_discovery.json | 7 ++ ...597c-9fe5-152a6875f214_host_discovery.json | 6 ++ ...5013-9cf0-5eb4cf89898f_host_discovery.json | 7 ++ ...59aa-993e-cf3736c71053_host_discovery.json | 7 ++ ...505c-8fb8-4b0a71a9114e_host_discovery.json | 7 ++ ...5ac5-b8a3-55eebc2b8d12_host_discovery.json | 7 ++ ...587e-a442-541d093b86b9_host_discovery.json | 6 ++ ...5c10-8b39-80685f6eaaba_host_discovery.json | 7 ++ ...55c6-a9eb-2b82dd21bc8b_host_discovery.json | 6 ++ ...5192-a944-20f66a6a8449_host_discovery.json | 6 ++ ...5969-a6b7-8b5a42de1971_host_discovery.json | 7 ++ ...4b0a-88cf-e6b8db4606f6_host_discovery.json | 17 ++++- ...4c29-b768-cfb97efcc585_host_discovery.json | 6 ++ ...4763-9917-655af1bb4b58_host_discovery.json | 17 ++++- ...4883-af81-8b06d836db37_host_discovery.json | 6 ++ ...4162-b82a-d5cfafe1c4e9_host_discovery.json | 17 ++++- ...553a-9a52-e9b562e210e5_host_discovery.json | 6 ++ ...5381-bb59-5af8639d52a4_host_discovery.json | 13 ++++ test/support/factory.ex | 5 +- .../discovery/policies/host_policy_test.exs | 18 +++++- .../hosts/projections/host_projector_test.exs | 43 +++++++++++-- 78 files changed, 652 insertions(+), 76 deletions(-) create mode 100644 priv/repo/migrations/20240716143321_add_netmasks_host_read_model.exs diff --git a/assets/js/lib/test-utils/data/hosts.js b/assets/js/lib/test-utils/data/hosts.js index c9e8218238..ccf44e03df 100644 --- a/assets/js/lib/test-utils/data/hosts.js +++ b/assets/js/lib/test-utils/data/hosts.js @@ -6,6 +6,7 @@ export default [ hostname: 'vmdrbddev01', id: '240f96b1-8d26-53b7-9e99-ffb0f2e735bf', ip_addresses: ['10.100.1.31', '10.100.1.33'], + netmasks: [24, 32], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -119,6 +120,7 @@ export default [ hostname: 'vmdrbddev02', id: '21de186a-e38f-5804-b643-7f4ef22fecfd', ip_addresses: ['10.100.1.32'], + netmasks: [24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -232,6 +234,7 @@ export default [ hostname: 'vmdrbdprd01', id: 'a09d9cf3-46c1-505c-8fb8-4b0a71a9114e', ip_addresses: ['10.80.1.31', '10.80.1.33'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -345,6 +348,7 @@ export default [ hostname: 'vmdrbdprd02', id: '927901fa-2c87-524e-b18c-3ef5187f504f', ip_addresses: ['10.80.1.32'], + netmasks: [24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -458,6 +462,7 @@ export default [ hostname: 'vmdrbdqas01', id: 'ddcb7992-2ffb-5c10-8b39-80685f6eaaba', ip_addresses: ['10.90.1.31', '10.90.1.33'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -571,6 +576,7 @@ export default [ hostname: 'vmdrbdqas02', id: '422686d6-b2d1-5092-93e8-a744854f5085', ip_addresses: ['10.90.1.32'], + netmasks: [24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -684,6 +690,7 @@ export default [ hostname: 'vmhdbdev01', id: '13e8c25c-3180-5a9a-95c8-51ec38e50cfc', ip_addresses: ['10.100.1.11', '10.100.1.13'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -797,6 +804,7 @@ export default [ hostname: 'vmhdbdev02', id: '0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4', ip_addresses: ['10.100.1.12'], + netmasks: [24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -910,6 +918,7 @@ export default [ hostname: 'vmhdbprd01', id: '9cd46919-5f19-59aa-993e-cf3736c71053', ip_addresses: ['10.80.1.11', '10.80.1.13'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -1023,6 +1032,7 @@ export default [ hostname: 'vmhdbprd02', id: 'b767b3e9-e802-587e-a442-541d093b86b9', ip_addresses: ['10.80.1.12'], + netmasks: [24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -1136,6 +1146,7 @@ export default [ hostname: 'vmhdbqas01', id: '99cf8a3a-48d6-57a4-b302-6e4482227ab6', ip_addresses: ['10.90.1.11', '10.90.1.13'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -1249,6 +1260,7 @@ export default [ hostname: 'vmhdbqas02', id: 'e0c182db-32ff-55c6-a9eb-2b82dd21bc8b', ip_addresses: ['10.90.1.12'], + netmasks: [24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -1362,6 +1374,7 @@ export default [ hostname: 'vmiscsi01', id: '69f4dcbb-efa2-5a16-8bc8-01df7dbb7384', ip_addresses: ['10.100.1.4'], + netmasks: [24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -1475,6 +1488,7 @@ export default [ hostname: 'vmiscsi01', id: '9a26b6d0-6e72-597c-9fe5-152a6875f214', ip_addresses: ['10.80.1.4'], + netmasks: [24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -1588,6 +1602,7 @@ export default [ hostname: 'vmiscsi01', id: 'f0c808b3-d869-5192-a944-20f66a6a8449', ip_addresses: ['10.90.1.4'], + netmasks: [24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -1701,6 +1716,7 @@ export default [ hostname: 'vmnwdev01', id: '7269ee51-5007-5849-aaa7-7c4a98b0c9ce', ip_addresses: ['10.100.1.21', '10.100.1.25'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -1814,6 +1830,7 @@ export default [ hostname: 'vmnwdev02', id: 'fb2c6b8a-9915-5969-a6b7-8b5a42de1971', ip_addresses: ['10.100.1.22', '10.100.1.26'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -1927,6 +1944,7 @@ export default [ hostname: 'vmnwdev03', id: '9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f', ip_addresses: ['10.100.1.23', '10.100.1.27'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -2040,6 +2058,7 @@ export default [ hostname: 'vmnwdev04', id: '1b0e9297-97dd-55d6-9874-8efde4d84c90', ip_addresses: ['10.100.1.24', '10.100.1.28'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -2153,6 +2172,7 @@ export default [ hostname: 'vmnwprd01', id: '116d49bd-85e1-5e59-b820-83f66db8800c', ip_addresses: ['10.80.1.21', '10.80.1.25'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -2266,6 +2286,7 @@ export default [ hostname: 'vmnwprd02', id: '4b30a6af-4b52-5bda-bccb-f2248a12c992', ip_addresses: ['10.80.1.22', '10.80.1.26'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -2379,6 +2400,7 @@ export default [ hostname: 'vmnwprd03', id: 'a3297d85-5e8b-5ac5-b8a3-55eebc2b8d12', ip_addresses: ['10.80.1.23', '10.80.1.27'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -2492,6 +2514,7 @@ export default [ hostname: 'vmnwprd04', id: '0fc07435-7ee2-54ca-b0de-fb27ffdc5deb', ip_addresses: ['10.80.1.24', '10.80.1.28'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -2605,6 +2628,7 @@ export default [ hostname: 'vmnwqas01', id: '25677e37-fd33-5005-896c-9275b1284534', ip_addresses: ['10.90.1.21', '10.90.1.25'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -2718,6 +2742,7 @@ export default [ hostname: 'vmnwqas02', id: '3711ea88-9ccc-5b07-8f9d-042be449d72b', ip_addresses: ['10.90.1.22', '10.90.1.26'], + netmasks: [24, 24], provider: 'azure', provider_data: { admin_username: 'cloudadmin', @@ -2831,6 +2856,7 @@ export default [ hostname: 'vmnwqas03', id: '098fc159-3ed6-58e7-91be-38fda8a833ea', ip_addresses: ['10.90.1.27', '10.90.1.23'], + netmasks: [24, 32], provider: null, provider_data: null, sles_subscriptions: [ @@ -2935,6 +2961,7 @@ export default [ hostname: 'vmnwqas04', id: '81e9b629-c1e7-538f-bff1-47d3a6580522', ip_addresses: ['10.90.1.28', '10.90.1.24'], + netmasks: [24, 24], provider: null, provider_data: null, sles_subscriptions: [ diff --git a/assets/js/lib/test-utils/factories/hosts.js b/assets/js/lib/test-utils/factories/hosts.js index fb5942762d..6ffefb00ae 100644 --- a/assets/js/lib/test-utils/factories/hosts.js +++ b/assets/js/lib/test-utils/factories/hosts.js @@ -109,6 +109,7 @@ export const hostFactory = Factory.define(({ params, sequence }) => { hostname: `${faker.person.firstName()}_${sequence}`, cluster_id: faker.string.uuid(), ip_addresses: [faker.internet.ip()], + netmasks: [faker.helpers.arrayElement([8, 16, 24, 32])], provider: cloudProviderEnum(), health: healthEnum(), heartbeat: heartbeatEnum(), diff --git a/assets/js/pages/HostDetailsPage/HostDetails.jsx b/assets/js/pages/HostDetailsPage/HostDetails.jsx index 408cf56de7..54aa8c027c 100644 --- a/assets/js/pages/HostDetailsPage/HostDetails.jsx +++ b/assets/js/pages/HostDetailsPage/HostDetails.jsx @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { get } from 'lodash'; +import { get, zipWith } from 'lodash'; import classNames from 'classnames'; import { EOS_CLEAR_ALL, @@ -48,6 +48,13 @@ function formatBytes(bytes, decimals = 2) { return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`; } +export const buildCidrNotation = (ipAddresses, netmasks) => + zipWith( + ipAddresses, + netmasks, + (address, netmask) => `${address}${netmask ? `/${netmask}` : ''}` + ); + function HostDetails({ agentVersion, chartsEnabled, @@ -59,6 +66,7 @@ function HostDetails({ hostID, hostname, ipAddresses = [], + netmasks = [], provider, providerData, sapInstances, @@ -213,7 +221,7 @@ function HostDetails({
faker.internet.ipv4()), + netmasks: Array.from({ length: 10 }, () => + faker.helpers.arrayElement([8, 16, 24, 32]) + ), }, }; diff --git a/assets/js/pages/HostDetailsPage/HostDetails.test.jsx b/assets/js/pages/HostDetailsPage/HostDetails.test.jsx index 62ef691b51..ca62626edf 100644 --- a/assets/js/pages/HostDetailsPage/HostDetails.test.jsx +++ b/assets/js/pages/HostDetailsPage/HostDetails.test.jsx @@ -79,24 +79,56 @@ describe('HostDetails component', () => { }); }); - describe('agent version', () => { - const message = - 'The Agent version is outdated, some features might not work properly. It is advised to keep the Agents up to date with the Server.'; - - it('should not show any warning message if the agent version is correct', () => { - renderWithRouter( - - ); - - expect(screen.queryByText(message)).not.toBeInTheDocument(); + describe('Summary box', () => { + describe('agent version', () => { + const message = + 'The Agent version is outdated, some features might not work properly. It is advised to keep the Agents up to date with the Server.'; + + it('should not show any warning message if the agent version is correct', () => { + renderWithRouter( + + ); + + expect(screen.queryByText(message)).not.toBeInTheDocument(); + }); + + it('should show a warning message if the agent version is outdated', () => { + renderWithRouter( + + ); + + expect(screen.getByText(message)).toBeInTheDocument(); + }); }); - it('should show a warning message if the agent version is outdated', () => { - renderWithRouter( - - ); - - expect(screen.getByText(message)).toBeInTheDocument(); + describe('IP addresses', () => { + it('should show IP addresses with CIDR notation', () => { + renderWithRouter( + + ); + + expect( + screen.getByText('10.0.0.5/24, 10.0.0.6/32') + ).toBeInTheDocument(); + }); + + it('should show plain IP addresses if netmasks are null', () => { + renderWithRouter( + + ); + + expect(screen.getByText('10.0.0.5, 10.0.0.6')).toBeInTheDocument(); + }); }); }); diff --git a/assets/js/pages/HostDetailsPage/HostDetailsPage.jsx b/assets/js/pages/HostDetailsPage/HostDetailsPage.jsx index ed906e777d..d65c67f330 100644 --- a/assets/js/pages/HostDetailsPage/HostDetailsPage.jsx +++ b/assets/js/pages/HostDetailsPage/HostDetailsPage.jsx @@ -106,6 +106,7 @@ function HostDetailsPage() { hostID={host.id} hostname={host.hostname} ipAddresses={host.ip_addresses} + netmasks={host.netmasks} provider={host.provider} providerData={host.provider_data} sapInstances={sapInstances} diff --git a/assets/js/pages/HostsList/HostsList.jsx b/assets/js/pages/HostsList/HostsList.jsx index e4999801e8..ef6f7154e8 100644 --- a/assets/js/pages/HostsList/HostsList.jsx +++ b/assets/js/pages/HostsList/HostsList.jsx @@ -23,6 +23,7 @@ import ClusterLink from '@pages/ClusterDetails/ClusterLink'; import DeregistrationModal from '@pages/DeregistrationModal'; import HealthSummary from '@pages/HealthSummary'; import { getCounters } from '@pages/HealthSummary/summarySelection'; +import { buildCidrNotation } from '@pages/HostDetailsPage/HostDetails'; import { addTagToHost, removeTagFromHost, deregisterHost } from '@state/hosts'; import { getAllSAPInstances } from '@state/selectors/sapSystem'; @@ -224,7 +225,7 @@ function HostsList() { return { health: host.health, hostname: host.hostname, - ip: host.ip_addresses, + ip: buildCidrNotation(host.ip_addresses, host.netmasks), provider: host.provider, sid: sapSystemList.map((sapSystem) => sapSystem.sid), cluster, diff --git a/assets/js/pages/HostsList/HostsList.test.jsx b/assets/js/pages/HostsList/HostsList.test.jsx index 6784e062f1..5b095d2ebd 100644 --- a/assets/js/pages/HostsList/HostsList.test.jsx +++ b/assets/js/pages/HostsList/HostsList.test.jsx @@ -27,7 +27,7 @@ describe('HostsLists component', () => { [ { host: 'vmhdbdev01', - ip: '10.100.1.1110.100.1.13', + ip: '10.100.1.11/2410.100.1.13/24', provider: 'Azure', cluster: 'hana_cluster_1', sid: 'HDD', @@ -37,7 +37,7 @@ describe('HostsLists component', () => { }, { host: 'vmnwqas03', - ip: '10.90.1.2710.90.1.23', + ip: '10.90.1.27/2410.90.1.23/32', provider: '', cluster: '', sid: 'NWQ', diff --git a/lib/trento/discovery/payloads/host_discovery_payload.ex b/lib/trento/discovery/payloads/host_discovery_payload.ex index abb6344ea6..d1ebdcece4 100644 --- a/lib/trento/discovery/payloads/host_discovery_payload.ex +++ b/lib/trento/discovery/payloads/host_discovery_payload.ex @@ -18,6 +18,7 @@ defmodule Trento.Discovery.Payloads.HostDiscoveryPayload do deftype do field :hostname, :string field :ip_addresses, {:array, :string} + field :netmasks, {:array, :integer} field :agent_version, :string field :cpu_count, :integer field :total_memory_mb, :integer diff --git a/lib/trento/discovery/policies/host_policy.ex b/lib/trento/discovery/policies/host_policy.ex index 3983c52e96..f80ad92ed2 100644 --- a/lib/trento/discovery/policies/host_policy.ex +++ b/lib/trento/discovery/policies/host_policy.ex @@ -128,22 +128,24 @@ defmodule Trento.Discovery.Policies.HostPolicy do end end - defp build_register_host_command(agent_id, %HostDiscoveryPayload{ - hostname: hostname, - ip_addresses: ip_addresses, - agent_version: agent_version, - cpu_count: cpu_count, - total_memory_mb: total_memory_mb, - socket_count: socket_count, - os_version: os_version, - installation_source: installation_source, - fully_qualified_domain_name: fqdn - }), + defp build_register_host_command( + agent_id, + %HostDiscoveryPayload{ + hostname: hostname, + agent_version: agent_version, + cpu_count: cpu_count, + total_memory_mb: total_memory_mb, + socket_count: socket_count, + os_version: os_version, + installation_source: installation_source, + fully_qualified_domain_name: fqdn + } = payload + ), do: RegisterHost.new(%{ host_id: agent_id, hostname: hostname, - ip_addresses: Enum.filter(ip_addresses, &non_loopback_ipv4?/1), + ip_addresses: build_ip_addresses(payload), agent_version: agent_version, cpu_count: cpu_count, total_memory_mb: total_memory_mb, @@ -153,6 +155,30 @@ defmodule Trento.Discovery.Policies.HostPolicy do fully_qualified_domain_name: fqdn }) + defp build_ip_addresses(%{ip_addresses: ip_addresses, netmasks: nil}) do + Enum.filter(ip_addresses, &non_loopback_ipv4?/1) + end + + defp build_ip_addresses(%{ip_addresses: ip_addresses, netmasks: netmasks}) do + [ip_addresses, netmasks] + |> Enum.zip_with(fn [address, netmask] -> %{address: address, netmask: netmask} end) + |> Enum.filter(fn %{address: address} -> non_loopback_ipv4?(address) end) + |> Enum.map(fn %{address: address, netmask: netmask} -> "#{address}/#{netmask}" end) + end + + @spec non_loopback_ipv4?(String.t()) :: boolean + defp non_loopback_ipv4?("127.0.0.1"), do: false + + defp non_loopback_ipv4?(address) do + case :inet.parse_ipv4_address(String.to_charlist(address)) do + {:ok, _} -> + true + + {:error, :einval} -> + false + end + end + defp build_update_saptune_command( agent_id, package_version, @@ -231,19 +257,6 @@ defmodule Trento.Discovery.Policies.HostPolicy do end) }) - @spec non_loopback_ipv4?(String.t()) :: boolean - defp non_loopback_ipv4?("127.0.0.1"), do: false - - defp non_loopback_ipv4?(ip) do - case :inet.parse_ipv4_address(String.to_charlist(ip)) do - {:ok, _} -> - true - - {:error, :einval} -> - false - end - end - @spec parse_cloud_provider_metadata(Provider.t(), map) :: map defp parse_cloud_provider_metadata( diff --git a/lib/trento/hosts/projections/host_projector.ex b/lib/trento/hosts/projections/host_projector.ex index a40cbf1ab5..c7a8dd18ac 100644 --- a/lib/trento/hosts/projections/host_projector.ex +++ b/lib/trento/hosts/projections/host_projector.ex @@ -42,10 +42,13 @@ defmodule Trento.Hosts.Projections.HostProjector do heartbeat: heartbeat }, fn multi -> + {addresses, netmasks} = parse_address_netmask(ip_addresses) + changeset = HostReadModel.changeset(%HostReadModel{id: id}, %{ hostname: hostname, - ip_addresses: ip_addresses, + ip_addresses: addresses, + netmasks: netmasks, agent_version: agent_version, fully_qualified_domain_name: fully_qualified_domain_name, heartbeat: heartbeat @@ -143,12 +146,15 @@ defmodule Trento.Hosts.Projections.HostProjector do agent_version: agent_version }, fn multi -> + {addresses, netmasks} = parse_address_netmask(ip_addresses) + changeset = HostReadModel |> Repo.get!(id) |> HostReadModel.changeset(%{ hostname: hostname, - ip_addresses: ip_addresses, + ip_addresses: addresses, + netmasks: netmasks, fully_qualified_domain_name: fully_qualified_domain_name, agent_version: agent_version }) @@ -423,4 +429,15 @@ defmodule Trento.Hosts.Projections.HostProjector do end def after_update(_, _, _), do: :ok + + defp parse_address_netmask(ip_addresses) do + ip_addresses + |> Enum.map(fn address -> + case String.split(address, "/") do + [ip, mask] -> {ip, String.to_integer(mask)} + [ip] -> {ip, nil} + end + end) + |> Enum.unzip() + end end diff --git a/lib/trento/hosts/projections/host_read_model.ex b/lib/trento/hosts/projections/host_read_model.ex index cb9e8576ee..52d9ebedd0 100644 --- a/lib/trento/hosts/projections/host_read_model.ex +++ b/lib/trento/hosts/projections/host_read_model.ex @@ -22,6 +22,7 @@ defmodule Trento.Hosts.Projections.HostReadModel do schema "hosts" do field :hostname, :string field :ip_addresses, {:array, :string} + field :netmasks, {:array, :integer} field :agent_version, :string field :fully_qualified_domain_name, :string field :cluster_id, Ecto.UUID diff --git a/lib/trento_web/openapi/v1/schema/host.ex b/lib/trento_web/openapi/v1/schema/host.ex index b4199d3b9d..2dd9c7b908 100644 --- a/lib/trento_web/openapi/v1/schema/host.ex +++ b/lib/trento_web/openapi/v1/schema/host.ex @@ -61,6 +61,12 @@ defmodule TrentoWeb.OpenApi.V1.Schema.Host do ] } }, + netmasks: %Schema{ + type: :array, + description: + "Netmasks associated to the ip_addresses field. The position of the item is associated to the ip address position in ip_addresses", + items: %Schema{type: :integer, nullable: true} + }, agent_version: %Schema{ type: :string, description: "Version of the agent installed on the host" diff --git a/priv/repo/migrations/20240716143321_add_netmasks_host_read_model.exs b/priv/repo/migrations/20240716143321_add_netmasks_host_read_model.exs new file mode 100644 index 0000000000..51b5e97d78 --- /dev/null +++ b/priv/repo/migrations/20240716143321_add_netmasks_host_read_model.exs @@ -0,0 +1,9 @@ +defmodule Trento.Repo.Migrations.AddNetmasksHostReadModel do + use Ecto.Migration + + def change do + alter table(:hosts) do + add :netmasks, {:array, :integer} + end + end +end diff --git a/test/e2e/cypress/fixtures/host-details/selected_host.js b/test/e2e/cypress/fixtures/host-details/selected_host.js index da2ddca239..044579b360 100644 --- a/test/e2e/cypress/fixtures/host-details/selected_host.js +++ b/test/e2e/cypress/fixtures/host-details/selected_host.js @@ -4,7 +4,7 @@ export const selectedHost = { hostName: 'vmhdbprd01', clusterName: 'hana_cluster_3', clusterId: '469e7be5-4e20-5007-b044-c6f540a87493', - ipAddresses: '10.80.1.11, 10.80.1.13', + ipAddresses: '10.80.1.11/24, 10.80.1.13/24', azureCloudDetails: { provider: 'Azure', vmName: 'vmhdbprd01', diff --git a/test/e2e/cypress/fixtures/hosts-overview/available_hosts.js b/test/e2e/cypress/fixtures/hosts-overview/available_hosts.js index 2de2a190c5..858d46c878 100644 --- a/test/e2e/cypress/fixtures/hosts-overview/available_hosts.js +++ b/test/e2e/cypress/fixtures/hosts-overview/available_hosts.js @@ -2,7 +2,7 @@ export const availableHosts = [ { id: '240f96b1-8d26-53b7-9e99-ffb0f2e735bf', name: 'vmdrbddev01', - ipAddresses: ['10.100.1.31', '10.100.1.33'], + ipAddresses: ['10.100.1.31/24', '10.100.1.33/24'], provider: 'Azure', clusterName: 'drbd_cluster', clusterId: '', @@ -14,7 +14,7 @@ export const availableHosts = [ { id: '21de186a-e38f-5804-b643-7f4ef22fecfd', name: 'vmdrbddev02', - ipAddresses: ['10.100.1.32'], + ipAddresses: ['10.100.1.32/24'], provider: 'Azure', clusterName: 'drbd_cluster', clusterId: '', @@ -26,7 +26,7 @@ export const availableHosts = [ { id: 'a09d9cf3-46c1-505c-8fb8-4b0a71a9114e', name: 'vmdrbdprd01', - ipAddresses: ['10.80.1.31', '10.80.1.33'], + ipAddresses: ['10.80.1.31/24', '10.80.1.33/24'], provider: 'Azure', clusterName: 'drbd_cluster', clusterId: '', @@ -38,7 +38,7 @@ export const availableHosts = [ { id: '927901fa-2c87-524e-b18c-3ef5187f504f', name: 'vmdrbdprd02', - ipAddresses: ['10.80.1.32'], + ipAddresses: ['10.80.1.32/24'], provider: 'Azure', clusterName: 'drbd_cluster', clusterId: '', @@ -50,7 +50,7 @@ export const availableHosts = [ { id: 'ddcb7992-2ffb-5c10-8b39-80685f6eaaba', name: 'vmdrbdqas01', - ipAddresses: ['10.90.1.31', '10.90.1.33'], + ipAddresses: ['10.90.1.31/24', '10.90.1.33/24'], provider: 'Azure', clusterName: 'drbd_cluster', clusterId: '', @@ -62,7 +62,7 @@ export const availableHosts = [ { id: '422686d6-b2d1-5092-93e8-a744854f5085', name: 'vmdrbdqas02', - ipAddresses: ['10.90.1.32'], + ipAddresses: ['10.90.1.32/24'], provider: 'Azure', clusterName: 'drbd_cluster', clusterId: '', @@ -74,7 +74,7 @@ export const availableHosts = [ { id: '13e8c25c-3180-5a9a-95c8-51ec38e50cfc', name: 'vmhdbdev01', - ipAddresses: ['10.100.1.11', '10.100.1.13'], + ipAddresses: ['10.100.1.11/24', '10.100.1.13/24'], provider: 'Azure', clusterName: 'hana_cluster_1', clusterId: '7965f822-0254-5858-abca-f6e8b4c27714', @@ -86,7 +86,7 @@ export const availableHosts = [ { id: '0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4', name: 'vmhdbdev02', - ipAddresses: ['10.100.1.12'], + ipAddresses: ['10.100.1.12/24'], provider: 'Azure', clusterName: 'hana_cluster_1', clusterId: '7965f822-0254-5858-abca-f6e8b4c27714', @@ -98,7 +98,7 @@ export const availableHosts = [ { id: '9cd46919-5f19-59aa-993e-cf3736c71053', name: 'vmhdbprd01', - ipAddresses: ['10.80.1.11', '10.80.1.13'], + ipAddresses: ['10.80.1.11/24', '10.80.1.13/24'], provider: 'Azure', clusterName: 'hana_cluster_3', clusterId: '469e7be5-4e20-5007-b044-c6f540a87493', @@ -110,7 +110,7 @@ export const availableHosts = [ { id: 'b767b3e9-e802-587e-a442-541d093b86b9', name: 'vmhdbprd02', - ipAddresses: ['10.80.1.12'], + ipAddresses: ['10.80.1.12/24'], provider: 'Azure', clusterName: 'hana_cluster_3', clusterId: '469e7be5-4e20-5007-b044-c6f540a87493', diff --git a/test/fixtures/discovery/host_discovery.json b/test/fixtures/discovery/host_discovery.json index 40631b11b0..7ae666991f 100644 --- a/test/fixtures/discovery/host_discovery.json +++ b/test/fixtures/discovery/host_discovery.json @@ -4,6 +4,7 @@ "payload": { "os_version": "15-SP2", "ip_addresses": ["10.1.1.4", "10.1.1.5", "10.1.1.6"], + "netmasks": [16, 24, 32], "hostname": "suse", "cpu_count": 2, "socket_count": 1, diff --git a/test/fixtures/discovery/host_discovery_with_installation_source.json b/test/fixtures/discovery/host_discovery_with_installation_source.json index e998d93529..a28fcefd19 100644 --- a/test/fixtures/discovery/host_discovery_with_installation_source.json +++ b/test/fixtures/discovery/host_discovery_with_installation_source.json @@ -4,6 +4,7 @@ "payload": { "os_version": "15-SP2", "ip_addresses": ["10.1.1.4", "10.1.1.5", "10.1.1.6"], + "netmasks": [16, 24, 32], "hostname": "suse", "cpu_count": 2, "socket_count": 1, diff --git a/test/fixtures/scenarios/aws-landscape/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json b/test/fixtures/scenarios/aws-landscape/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json index f1f5d6a1b3..aa750cecd9 100644 --- a/test/fixtures/scenarios/aws-landscape/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json +++ b/test/fixtures/scenarios/aws-landscape/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json @@ -11,9 +11,15 @@ "10.100.1.12", "fe80::6245:bdff:fe8a:5f6b" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, "fully_qualified_domain_name": "vmhdbdev02.l15cqsinwnpu5gfyrf1r5l51fe.ax.internal.cloudapp.net" } -} +} \ No newline at end of file diff --git a/test/fixtures/scenarios/aws-landscape/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json b/test/fixtures/scenarios/aws-landscape/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json index 84ee45d10c..64ede97f2e 100644 --- a/test/fixtures/scenarios/aws-landscape/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json +++ b/test/fixtures/scenarios/aws-landscape/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.13", "fe80::6245:bdff:fe8d:9b69" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, diff --git a/test/fixtures/scenarios/aws-landscape/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json b/test/fixtures/scenarios/aws-landscape/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json index d6ea7d3b3c..d0aaf8853a 100644 --- a/test/fixtures/scenarios/aws-landscape/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json +++ b/test/fixtures/scenarios/aws-landscape/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.28", "fe80::6245:bdff:fe8d:9a74" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/aws-landscape/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json b/test/fixtures/scenarios/aws-landscape/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json index eb97d51497..3d234e684f 100644 --- a/test/fixtures/scenarios/aws-landscape/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json +++ b/test/fixtures/scenarios/aws-landscape/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.25", "fe80::6245:bdff:fe8a:5ce7" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/aws-landscape/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json b/test/fixtures/scenarios/aws-landscape/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json index 3078645d57..4a6c9139a9 100644 --- a/test/fixtures/scenarios/aws-landscape/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json +++ b/test/fixtures/scenarios/aws-landscape/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.27", "fe80::6245:bdff:fe8d:9ef4" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/aws-landscape/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json b/test/fixtures/scenarios/aws-landscape/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json index 9f6259777f..4e102cc562 100644 --- a/test/fixtures/scenarios/aws-landscape/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json +++ b/test/fixtures/scenarios/aws-landscape/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.26", "fe80::6245:bdff:fe8d:9c7d" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/gcp-landscape/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json b/test/fixtures/scenarios/gcp-landscape/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json index f1f5d6a1b3..935eac51c0 100644 --- a/test/fixtures/scenarios/gcp-landscape/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json +++ b/test/fixtures/scenarios/gcp-landscape/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json @@ -11,6 +11,12 @@ "10.100.1.12", "fe80::6245:bdff:fe8a:5f6b" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, diff --git a/test/fixtures/scenarios/gcp-landscape/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json b/test/fixtures/scenarios/gcp-landscape/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json index 84ee45d10c..64ede97f2e 100644 --- a/test/fixtures/scenarios/gcp-landscape/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json +++ b/test/fixtures/scenarios/gcp-landscape/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.13", "fe80::6245:bdff:fe8d:9b69" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, diff --git a/test/fixtures/scenarios/gcp-landscape/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json b/test/fixtures/scenarios/gcp-landscape/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json index d6ea7d3b3c..d0aaf8853a 100644 --- a/test/fixtures/scenarios/gcp-landscape/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json +++ b/test/fixtures/scenarios/gcp-landscape/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.28", "fe80::6245:bdff:fe8d:9a74" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/gcp-landscape/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json b/test/fixtures/scenarios/gcp-landscape/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json index eb97d51497..3d234e684f 100644 --- a/test/fixtures/scenarios/gcp-landscape/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json +++ b/test/fixtures/scenarios/gcp-landscape/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.25", "fe80::6245:bdff:fe8a:5ce7" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/gcp-landscape/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json b/test/fixtures/scenarios/gcp-landscape/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json index 3078645d57..4a6c9139a9 100644 --- a/test/fixtures/scenarios/gcp-landscape/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json +++ b/test/fixtures/scenarios/gcp-landscape/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.27", "fe80::6245:bdff:fe8d:9ef4" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/gcp-landscape/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json b/test/fixtures/scenarios/gcp-landscape/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json index 9f6259777f..4e102cc562 100644 --- a/test/fixtures/scenarios/gcp-landscape/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json +++ b/test/fixtures/scenarios/gcp-landscape/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.26", "fe80::6245:bdff:fe8d:9c7d" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/hana-diskless-sbd/0f6e6491-21f2-495e-9f2d-bc50b872efaf_host_discovery.json b/test/fixtures/scenarios/hana-diskless-sbd/0f6e6491-21f2-495e-9f2d-bc50b872efaf_host_discovery.json index a4f9e69dc7..8cbe376926 100644 --- a/test/fixtures/scenarios/hana-diskless-sbd/0f6e6491-21f2-495e-9f2d-bc50b872efaf_host_discovery.json +++ b/test/fixtures/scenarios/hana-diskless-sbd/0f6e6491-21f2-495e-9f2d-bc50b872efaf_host_discovery.json @@ -14,6 +14,14 @@ "10.110.1.15", "55:4d:24:96:f3:08" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "24", + "64" + ], "os_version": "15-SP4", "socket_count": 2, "total_memory_mb": 1547378, diff --git a/test/fixtures/scenarios/hana-diskless-sbd/43dcb497-2652-4254-b53a-3ff1d3b2a0ff_host_discovery.json b/test/fixtures/scenarios/hana-diskless-sbd/43dcb497-2652-4254-b53a-3ff1d3b2a0ff_host_discovery.json index c7b85b4ef1..f6361c0dcb 100644 --- a/test/fixtures/scenarios/hana-diskless-sbd/43dcb497-2652-4254-b53a-3ff1d3b2a0ff_host_discovery.json +++ b/test/fixtures/scenarios/hana-diskless-sbd/43dcb497-2652-4254-b53a-3ff1d3b2a0ff_host_discovery.json @@ -12,6 +12,12 @@ "10.110.1.13", "7d:88:16:29:cb:a0" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP4", "socket_count": 1, "total_memory_mb": 128418, diff --git a/test/fixtures/scenarios/hana-diskless-sbd/5f2632a9-7b18-4c37-955a-fe16cadaaef4_host_discovery.json b/test/fixtures/scenarios/hana-diskless-sbd/5f2632a9-7b18-4c37-955a-fe16cadaaef4_host_discovery.json index fa8044854f..937601dd13 100644 --- a/test/fixtures/scenarios/hana-diskless-sbd/5f2632a9-7b18-4c37-955a-fe16cadaaef4_host_discovery.json +++ b/test/fixtures/scenarios/hana-diskless-sbd/5f2632a9-7b18-4c37-955a-fe16cadaaef4_host_discovery.json @@ -13,6 +13,13 @@ "10.110.1.16", "b7:45:a1:2d:8b:8b" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "os_version": "15-SP4", "socket_count": 1, "total_memory_mb": 1547378, diff --git a/test/fixtures/scenarios/hana-scale-out/1109be4b-54fb-4796-b073-f4cc04d2ca55_host_discovery.json b/test/fixtures/scenarios/hana-scale-out/1109be4b-54fb-4796-b073-f4cc04d2ca55_host_discovery.json index 12f99d17fc..785d18fcf5 100644 --- a/test/fixtures/scenarios/hana-scale-out/1109be4b-54fb-4796-b073-f4cc04d2ca55_host_discovery.json +++ b/test/fixtures/scenarios/hana-scale-out/1109be4b-54fb-4796-b073-f4cc04d2ca55_host_discovery.json @@ -12,6 +12,12 @@ "10.0.0.9", "a9:77:8c:c5:43:f9" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP5", "socket_count": 1, "total_memory_mb": 7888, diff --git a/test/fixtures/scenarios/hana-scale-out/12ab9a68-c047-4eda-81c8-1e24578d9973_host_discovery.json b/test/fixtures/scenarios/hana-scale-out/12ab9a68-c047-4eda-81c8-1e24578d9973_host_discovery.json index 702a638bf2..fe50151adb 100644 --- a/test/fixtures/scenarios/hana-scale-out/12ab9a68-c047-4eda-81c8-1e24578d9973_host_discovery.json +++ b/test/fixtures/scenarios/hana-scale-out/12ab9a68-c047-4eda-81c8-1e24578d9973_host_discovery.json @@ -12,6 +12,12 @@ "10.0.0.6", "6c:52:47:65:7f:45" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP5", "socket_count": 1, "total_memory_mb": 32043, diff --git a/test/fixtures/scenarios/hana-scale-out/16bd3ed1-923d-46ff-b6d0-9bfed42e387b_host_discovery.json b/test/fixtures/scenarios/hana-scale-out/16bd3ed1-923d-46ff-b6d0-9bfed42e387b_host_discovery.json index bf6ba9153f..699d18da44 100644 --- a/test/fixtures/scenarios/hana-scale-out/16bd3ed1-923d-46ff-b6d0-9bfed42e387b_host_discovery.json +++ b/test/fixtures/scenarios/hana-scale-out/16bd3ed1-923d-46ff-b6d0-9bfed42e387b_host_discovery.json @@ -13,6 +13,13 @@ "10.0.0.10", "0b:70:5f:54:31:ef" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "os_version": "15-SP5", "socket_count": 1, "total_memory_mb": 32043, diff --git a/test/fixtures/scenarios/hana-scale-out/28edd956-2155-487e-a4eb-f3d4cf7c9543_host_discovery.json b/test/fixtures/scenarios/hana-scale-out/28edd956-2155-487e-a4eb-f3d4cf7c9543_host_discovery.json index 8fce9d0dd1..3682e53941 100644 --- a/test/fixtures/scenarios/hana-scale-out/28edd956-2155-487e-a4eb-f3d4cf7c9543_host_discovery.json +++ b/test/fixtures/scenarios/hana-scale-out/28edd956-2155-487e-a4eb-f3d4cf7c9543_host_discovery.json @@ -12,6 +12,12 @@ "10.0.0.8", "ba:32:8e:e8:91:83" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP5", "socket_count": 1, "total_memory_mb": 3862, diff --git a/test/fixtures/scenarios/hana-scale-out/33ec3a15-103b-453b-b6b2-f3f971582dc_host_discovery.json b/test/fixtures/scenarios/hana-scale-out/33ec3a15-103b-453b-b6b2-f3f971582dc_host_discovery.json index b2b5319072..03701fc924 100644 --- a/test/fixtures/scenarios/hana-scale-out/33ec3a15-103b-453b-b6b2-f3f971582dc_host_discovery.json +++ b/test/fixtures/scenarios/hana-scale-out/33ec3a15-103b-453b-b6b2-f3f971582dc_host_discovery.json @@ -12,6 +12,12 @@ "10.0.0.5", "15:f5:98:ac:13:bb" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP5", "socket_count": 1, "total_memory_mb": 32043, diff --git a/test/fixtures/scenarios/hana-scale-out/f3463fd1-004a-4214-afd4-b15160b0d521_host_discovery.json b/test/fixtures/scenarios/hana-scale-out/f3463fd1-004a-4214-afd4-b15160b0d521_host_discovery.json index c12da5d5ca..6d5495f043 100644 --- a/test/fixtures/scenarios/hana-scale-out/f3463fd1-004a-4214-afd4-b15160b0d521_host_discovery.json +++ b/test/fixtures/scenarios/hana-scale-out/f3463fd1-004a-4214-afd4-b15160b0d521_host_discovery.json @@ -12,6 +12,12 @@ "10.0.0.4", "11:6c:ba:82:4c:06" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP5", "socket_count": 1, "total_memory_mb": 32043, diff --git a/test/fixtures/scenarios/hana-scale-up-angi/4b67842f-ccf7-46a4-a344-9e918648b117_host_discovery.json b/test/fixtures/scenarios/hana-scale-up-angi/4b67842f-ccf7-46a4-a344-9e918648b117_host_discovery.json index 6a54517b93..b0f92f8635 100644 --- a/test/fixtures/scenarios/hana-scale-up-angi/4b67842f-ccf7-46a4-a344-9e918648b117_host_discovery.json +++ b/test/fixtures/scenarios/hana-scale-up-angi/4b67842f-ccf7-46a4-a344-9e918648b117_host_discovery.json @@ -13,6 +13,12 @@ "10.70.1.5", "82ef:e867:1dcc:8e1a:50a6" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP5", "socket_count": 1, "total_memory_mb": 32043 diff --git a/test/fixtures/scenarios/hana-scale-up-angi/851a4dd3-9693-44c3-a40b-b32d22872e74_host_discovery.json b/test/fixtures/scenarios/hana-scale-up-angi/851a4dd3-9693-44c3-a40b-b32d22872e74_host_discovery.json index 633fb1b061..847bdd318c 100644 --- a/test/fixtures/scenarios/hana-scale-up-angi/851a4dd3-9693-44c3-a40b-b32d22872e74_host_discovery.json +++ b/test/fixtures/scenarios/hana-scale-up-angi/851a4dd3-9693-44c3-a40b-b32d22872e74_host_discovery.json @@ -14,6 +14,13 @@ "10.70.1.13", "f62a:7172:570f:a509:6475" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "os_version": "15-SP5", "socket_count": 1, "total_memory_mb": 32043 diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/098fc159-3ed6-58e7-91be-38fda8a833ea_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/098fc159-3ed6-58e7-91be-38fda8a833ea_host_discovery.json index a85ba0a360..c75558e356 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/098fc159-3ed6-58e7-91be-38fda8a833ea_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/098fc159-3ed6-58e7-91be-38fda8a833ea_host_discovery.json @@ -12,6 +12,13 @@ "10.90.1.23", "fe80::6245:bdff:fe8d:5d9" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json index f1f5d6a1b3..935eac51c0 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/0a055c90-4cb6-54ce-ac9c-ae3fedaf40d4_host_discovery.json @@ -11,6 +11,12 @@ "10.100.1.12", "fe80::6245:bdff:fe8a:5f6b" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/0fc07435-7ee2-54ca-b0de-fb27ffdc5deb_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/0fc07435-7ee2-54ca-b0de-fb27ffdc5deb_host_discovery.json index 032023cf38..6ac90fa4eb 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/0fc07435-7ee2-54ca-b0de-fb27ffdc5deb_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/0fc07435-7ee2-54ca-b0de-fb27ffdc5deb_host_discovery.json @@ -12,6 +12,13 @@ "10.80.1.28", "fe80::20d:3aff:fe2e:8fad" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/116d49bd-85e1-5e59-b820-83f66db8800c_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/116d49bd-85e1-5e59-b820-83f66db8800c_host_discovery.json index 9e4f15e25f..f54abbdf71 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/116d49bd-85e1-5e59-b820-83f66db8800c_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/116d49bd-85e1-5e59-b820-83f66db8800c_host_discovery.json @@ -12,6 +12,13 @@ "10.80.1.25", "fe80::20d:3aff:fe2e:8f04" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json index 84ee45d10c..64ede97f2e 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.13", "fe80::6245:bdff:fe8d:9b69" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json index d6ea7d3b3c..d0aaf8853a 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/1b0e9297-97dd-55d6-9874-8efde4d84c90_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.28", "fe80::6245:bdff:fe8d:9a74" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/21de186a-e38f-5804-b643-7f4ef22fecfd_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/21de186a-e38f-5804-b643-7f4ef22fecfd_host_discovery.json index 2108587fed..59eac701d7 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/21de186a-e38f-5804-b643-7f4ef22fecfd_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/21de186a-e38f-5804-b643-7f4ef22fecfd_host_discovery.json @@ -11,6 +11,12 @@ "10.100.1.32", "fe80::6245:bdff:fe8d:95f1" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951 diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/240f96b1-8d26-53b7-9e99-ffb0f2e735bf_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/240f96b1-8d26-53b7-9e99-ffb0f2e735bf_host_discovery.json index 8251cf77c8..a8cc19eb98 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/240f96b1-8d26-53b7-9e99-ffb0f2e735bf_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/240f96b1-8d26-53b7-9e99-ffb0f2e735bf_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.33", "fe80::6245:bdff:fe8a:5969" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/25677e37-fd33-5005-896c-9275b1284534_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/25677e37-fd33-5005-896c-9275b1284534_host_discovery.json index a14d9d8b1f..44f57906a6 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/25677e37-fd33-5005-896c-9275b1284534_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/25677e37-fd33-5005-896c-9275b1284534_host_discovery.json @@ -12,6 +12,13 @@ "10.90.1.25", "fe80::6245:bdff:fe8d:a30" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/3711ea88-9ccc-5b07-8f9d-042be449d72b_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/3711ea88-9ccc-5b07-8f9d-042be449d72b_host_discovery.json index fd6477ab7a..b941a3603d 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/3711ea88-9ccc-5b07-8f9d-042be449d72b_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/3711ea88-9ccc-5b07-8f9d-042be449d72b_host_discovery.json @@ -12,6 +12,13 @@ "10.90.1.26", "fe80::6245:bdff:fe8d:6ef" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/422686d6-b2d1-5092-93e8-a744854f5085_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/422686d6-b2d1-5092-93e8-a744854f5085_host_discovery.json index 283b749e17..706364497e 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/422686d6-b2d1-5092-93e8-a744854f5085_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/422686d6-b2d1-5092-93e8-a744854f5085_host_discovery.json @@ -11,6 +11,12 @@ "10.90.1.32", "fe80::6245:bdff:fe8d:523" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/4b30a6af-4b52-5bda-bccb-f2248a12c992_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/4b30a6af-4b52-5bda-bccb-f2248a12c992_host_discovery.json index 184a61bf1b..01bbaeca98 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/4b30a6af-4b52-5bda-bccb-f2248a12c992_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/4b30a6af-4b52-5bda-bccb-f2248a12c992_host_discovery.json @@ -12,6 +12,13 @@ "10.80.1.26", "fe80::20d:3aff:fe2e:8038" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/69f4dcbb-efa2-5a16-8bc8-01df7dbb7384_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/69f4dcbb-efa2-5a16-8bc8-01df7dbb7384_host_discovery.json index cac99232cf..1713ed5ff4 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/69f4dcbb-efa2-5a16-8bc8-01df7dbb7384_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/69f4dcbb-efa2-5a16-8bc8-01df7dbb7384_host_discovery.json @@ -11,6 +11,12 @@ "10.100.1.4", "fe80::20d:3aff:fe2a:aabe" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 3421, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json index eb97d51497..3d234e684f 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/7269ee51-5007-5849-aaa7-7c4a98b0c9ce_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.25", "fe80::6245:bdff:fe8a:5ce7" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/81e9b629-c1e7-538f-bff1-47d3a6580522_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/81e9b629-c1e7-538f-bff1-47d3a6580522_host_discovery.json index 1222b9df2f..77fe036cf8 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/81e9b629-c1e7-538f-bff1-47d3a6580522_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/81e9b629-c1e7-538f-bff1-47d3a6580522_host_discovery.json @@ -12,6 +12,13 @@ "10.90.1.24", "fe80::6245:bdff:fe8d:dca" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/927901fa-2c87-524e-b18c-3ef5187f504f_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/927901fa-2c87-524e-b18c-3ef5187f504f_host_discovery.json index d424826356..6fe6e11185 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/927901fa-2c87-524e-b18c-3ef5187f504f_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/927901fa-2c87-524e-b18c-3ef5187f504f_host_discovery.json @@ -11,6 +11,12 @@ "10.80.1.32", "fe80::20d:3aff:fe2e:8b91" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/99cf8a3a-48d6-57a4-b302-6e4482227ab6_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/99cf8a3a-48d6-57a4-b302-6e4482227ab6_host_discovery.json index 5dd5fc864a..57aefd3402 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/99cf8a3a-48d6-57a4-b302-6e4482227ab6_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/99cf8a3a-48d6-57a4-b302-6e4482227ab6_host_discovery.json @@ -12,6 +12,13 @@ "10.90.1.13", "fe80::6245:bdff:fe8d:1d5" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9a26b6d0-6e72-597c-9fe5-152a6875f214_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9a26b6d0-6e72-597c-9fe5-152a6875f214_host_discovery.json index ef41f025c6..a76dfdabb0 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9a26b6d0-6e72-597c-9fe5-152a6875f214_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9a26b6d0-6e72-597c-9fe5-152a6875f214_host_discovery.json @@ -11,6 +11,12 @@ "10.80.1.4", "fe80::20d:3aff:fe2e:835a" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 3421, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json index 3078645d57..4a6c9139a9 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9a3ec76a-dd4f-5013-9cf0-5eb4cf89898f_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.27", "fe80::6245:bdff:fe8d:9ef4" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9cd46919-5f19-59aa-993e-cf3736c71053_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9cd46919-5f19-59aa-993e-cf3736c71053_host_discovery.json index b1444d701b..c61b1a0ac4 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9cd46919-5f19-59aa-993e-cf3736c71053_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/9cd46919-5f19-59aa-993e-cf3736c71053_host_discovery.json @@ -12,6 +12,13 @@ "10.80.1.13", "fe80::20d:3aff:fe23:2c6b" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/a09d9cf3-46c1-505c-8fb8-4b0a71a9114e_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/a09d9cf3-46c1-505c-8fb8-4b0a71a9114e_host_discovery.json index 33d13d7efb..8d99e6c922 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/a09d9cf3-46c1-505c-8fb8-4b0a71a9114e_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/a09d9cf3-46c1-505c-8fb8-4b0a71a9114e_host_discovery.json @@ -12,6 +12,13 @@ "10.80.1.33", "fe80::20d:3aff:fe25:7df0" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/a3297d85-5e8b-5ac5-b8a3-55eebc2b8d12_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/a3297d85-5e8b-5ac5-b8a3-55eebc2b8d12_host_discovery.json index 38f68b3abc..a54751a3d2 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/a3297d85-5e8b-5ac5-b8a3-55eebc2b8d12_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/a3297d85-5e8b-5ac5-b8a3-55eebc2b8d12_host_discovery.json @@ -12,6 +12,13 @@ "10.80.1.27", "fe80::20d:3aff:fe25:7f83" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/b767b3e9-e802-587e-a442-541d093b86b9_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/b767b3e9-e802-587e-a442-541d093b86b9_host_discovery.json index 9ac3192e60..c09ff83859 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/b767b3e9-e802-587e-a442-541d093b86b9_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/b767b3e9-e802-587e-a442-541d093b86b9_host_discovery.json @@ -11,6 +11,12 @@ "10.80.1.12", "fe80::20d:3aff:fe21:f108" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/ddcb7992-2ffb-5c10-8b39-80685f6eaaba_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/ddcb7992-2ffb-5c10-8b39-80685f6eaaba_host_discovery.json index bbf08a62be..f0b4c70d2a 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/ddcb7992-2ffb-5c10-8b39-80685f6eaaba_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/ddcb7992-2ffb-5c10-8b39-80685f6eaaba_host_discovery.json @@ -12,6 +12,13 @@ "10.90.1.33", "fe80::6245:bdff:fe8d:c2" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/e0c182db-32ff-55c6-a9eb-2b82dd21bc8b_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/e0c182db-32ff-55c6-a9eb-2b82dd21bc8b_host_discovery.json index b6e4cffd65..b9282800f6 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/e0c182db-32ff-55c6-a9eb-2b82dd21bc8b_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/e0c182db-32ff-55c6-a9eb-2b82dd21bc8b_host_discovery.json @@ -11,6 +11,12 @@ "10.90.1.12", "fe80::6245:bdff:fe8d:8b3" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 32107, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/f0c808b3-d869-5192-a944-20f66a6a8449_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/f0c808b3-d869-5192-a944-20f66a6a8449_host_discovery.json index 7cd405c906..0b5609ebe8 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/f0c808b3-d869-5192-a944-20f66a6a8449_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/f0c808b3-d869-5192-a944-20f66a6a8449_host_discovery.json @@ -11,6 +11,12 @@ "10.90.1.4", "fe80::222:48ff:fe7f:d2f9" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 3422, diff --git a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json index 9f6259777f..4e102cc562 100644 --- a/test/fixtures/scenarios/healthy-27-node-SAP-cluster/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json +++ b/test/fixtures/scenarios/healthy-27-node-SAP-cluster/fb2c6b8a-9915-5969-a6b7-8b5a42de1971_host_discovery.json @@ -12,6 +12,13 @@ "10.100.1.26", "fe80::6245:bdff:fe8d:9c7d" ], + "netmasks": [ + "8", + "128", + "24", + "24", + "64" + ], "socket_count": 1, "agent_version": "2.1.0", "total_memory_mb": 7951, diff --git a/test/fixtures/scenarios/multi-tenant/544cbc99-c856-4b0a-88cf-e6b8db4606f6_host_discovery.json b/test/fixtures/scenarios/multi-tenant/544cbc99-c856-4b0a-88cf-e6b8db4606f6_host_discovery.json index 6241db8cd2..055989a067 100644 --- a/test/fixtures/scenarios/multi-tenant/544cbc99-c856-4b0a-88cf-e6b8db4606f6_host_discovery.json +++ b/test/fixtures/scenarios/multi-tenant/544cbc99-c856-4b0a-88cf-e6b8db4606f6_host_discovery.json @@ -5,11 +5,24 @@ "fully_qualified_domain_name": "hanadb3.example.com", "hostname": "hanadb3", "installation_source": "Suse", - "ip_addresses": ["127.0.0.1", "::1", "10.17.0.6", "10.17.2.6", "10.17.3.6"], + "ip_addresses": [ + "127.0.0.1", + "::1", + "10.17.0.6", + "10.17.2.6", + "10.17.3.6" + ], + "netmasks": [ + "8", + "128", + "24", + "24", + "24" + ], "os_version": "15-SP4", "socket_count": 1, "total_memory_mb": 64240 }, "discovery_type": "host_discovery", "agent_id": "544cbc99-c856-4b0a-88cf-e6b8db4606f6" -} +} \ No newline at end of file diff --git a/test/fixtures/scenarios/multi-tenant/c0ecf7d1-bdd3-4c29-b768-cfb97efcc585_host_discovery.json b/test/fixtures/scenarios/multi-tenant/c0ecf7d1-bdd3-4c29-b768-cfb97efcc585_host_discovery.json index 43e70fb79b..49f6a627f0 100644 --- a/test/fixtures/scenarios/multi-tenant/c0ecf7d1-bdd3-4c29-b768-cfb97efcc585_host_discovery.json +++ b/test/fixtures/scenarios/multi-tenant/c0ecf7d1-bdd3-4c29-b768-cfb97efcc585_host_discovery.json @@ -11,6 +11,12 @@ "10.17.0.7", "fe80::1525:bdaa:fa1c:c411" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP4", "socket_count": 1, "total_memory_mb": 7880 diff --git a/test/fixtures/scenarios/multi-tenant/e0564d66-be9e-4763-9917-655af1bb4b58_host_discovery.json b/test/fixtures/scenarios/multi-tenant/e0564d66-be9e-4763-9917-655af1bb4b58_host_discovery.json index 78c74ce002..ab3f1bf634 100644 --- a/test/fixtures/scenarios/multi-tenant/e0564d66-be9e-4763-9917-655af1bb4b58_host_discovery.json +++ b/test/fixtures/scenarios/multi-tenant/e0564d66-be9e-4763-9917-655af1bb4b58_host_discovery.json @@ -5,11 +5,24 @@ "fully_qualified_domain_name": "hanadb2.example.com", "hostname": "hanadb2", "installation_source": "Suse", - "ip_addresses": ["127.0.0.1", "::1", "10.17.0.5", "10.17.2.5", "10.17.3.5"], + "ip_addresses": [ + "127.0.0.1", + "::1", + "10.17.0.5", + "10.17.2.5", + "10.17.3.5" + ], + "netmasks": [ + "8", + "128", + "24", + "24", + "24" + ], "os_version": "15-SP4", "socket_count": 1, "total_memory_mb": 64240 }, "discovery_type": "host_discovery", "agent_id": "e0564d66-be9e-4763-9917-655af1bb4b58" -} +} \ No newline at end of file diff --git a/test/fixtures/scenarios/multi-tenant/edf755fd-abc7-4883-af81-8b06d836db37_host_discovery.json b/test/fixtures/scenarios/multi-tenant/edf755fd-abc7-4883-af81-8b06d836db37_host_discovery.json index 5cb2917a3d..fbd5df85e5 100644 --- a/test/fixtures/scenarios/multi-tenant/edf755fd-abc7-4883-af81-8b06d836db37_host_discovery.json +++ b/test/fixtures/scenarios/multi-tenant/edf755fd-abc7-4883-af81-8b06d836db37_host_discovery.json @@ -11,6 +11,12 @@ "10.17.0.8", "fe80::6111:bdef:af94:11ae" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP4", "socket_count": 1, "total_memory_mb": 7880 diff --git a/test/fixtures/scenarios/multi-tenant/f7a8969b-db9e-4162-b82a-d5cfafe1c4e9_host_discovery.json b/test/fixtures/scenarios/multi-tenant/f7a8969b-db9e-4162-b82a-d5cfafe1c4e9_host_discovery.json index 0c4c7cbc70..7e074502b2 100644 --- a/test/fixtures/scenarios/multi-tenant/f7a8969b-db9e-4162-b82a-d5cfafe1c4e9_host_discovery.json +++ b/test/fixtures/scenarios/multi-tenant/f7a8969b-db9e-4162-b82a-d5cfafe1c4e9_host_discovery.json @@ -5,11 +5,24 @@ "fully_qualified_domain_name": "hanadb1.example.com", "hostname": "hanadb1", "installation_source": "Suse", - "ip_addresses": ["127.0.0.1", "::1", "10.17.0.4", "10.17.2.4", "10.17.3.4"], + "ip_addresses": [ + "127.0.0.1", + "::1", + "10.17.0.4", + "10.17.2.4", + "10.17.3.4" + ], + "netmasks": [ + "8", + "128", + "24", + "24", + "24" + ], "os_version": "15-SP5", "socket_count": 1, "total_memory_mb": 64248 }, "discovery_type": "host_discovery", "agent_id": "f7a8969b-db9e-4162-b82a-d5cfafe1c4e9" -} +} \ No newline at end of file diff --git a/test/fixtures/scenarios/single-hana-single-app/c4914bd4-efa3-553a-9a52-e9b562e210e5_host_discovery.json b/test/fixtures/scenarios/single-hana-single-app/c4914bd4-efa3-553a-9a52-e9b562e210e5_host_discovery.json index 0f529c6005..e414b892fa 100644 --- a/test/fixtures/scenarios/single-hana-single-app/c4914bd4-efa3-553a-9a52-e9b562e210e5_host_discovery.json +++ b/test/fixtures/scenarios/single-hana-single-app/c4914bd4-efa3-553a-9a52-e9b562e210e5_host_discovery.json @@ -12,6 +12,12 @@ "10.0.1.10", "fe80::bc:ffff:fe56:bd6a" ], + "netmasks": [ + "8", + "128", + "24", + "64" + ], "os_version": "15-SP4", "socket_count": 1, "total_memory_mb": 31578, diff --git a/test/fixtures/scenarios/single-hana-single-app/e77ab524-c4e4-5381-bb59-5af8639d52a4_host_discovery.json b/test/fixtures/scenarios/single-hana-single-app/e77ab524-c4e4-5381-bb59-5af8639d52a4_host_discovery.json index cb477a48a9..98e078d66d 100644 --- a/test/fixtures/scenarios/single-hana-single-app/e77ab524-c4e4-5381-bb59-5af8639d52a4_host_discovery.json +++ b/test/fixtures/scenarios/single-hana-single-app/e77ab524-c4e4-5381-bb59-5af8639d52a4_host_discovery.json @@ -19,6 +19,19 @@ "fe80::8d3:33ff:feee:9701", "fe80::ec17:89ff:feb6:a456" ], + "netmasks": [ + "8", + "128", + "16", + "24", + "24", + "64", + "24", + "24", + "64", + "64", + "64" + ], "os_version": "15-SP4", "socket_count": 1, "total_memory_mb": 15699, diff --git a/test/support/factory.ex b/test/support/factory.ex index 4794af0c81..4629fe03a0 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -143,7 +143,7 @@ defmodule Trento.Factory do %HostRegistered{ host_id: Faker.UUID.v4(), hostname: Faker.StarWars.character(), - ip_addresses: [Faker.Internet.ip_v4_address()], + ip_addresses: ["#{Faker.Internet.ip_v4_address()}/#{Enum.random([16, 24, 32])}"], agent_version: Faker.App.semver(), cpu_count: Enum.random(1..16), total_memory_mb: Enum.random(1..128), @@ -160,7 +160,7 @@ defmodule Trento.Factory do host_id: Faker.UUID.v4(), hostname: Faker.StarWars.character(), fully_qualified_domain_name: Faker.Internet.domain_name(), - ip_addresses: [Faker.Internet.ip_v4_address()], + ip_addresses: ["#{Faker.Internet.ip_v4_address()}/#{Enum.random([16, 24, 32])}"], agent_version: Faker.App.semver(), cpu_count: Enum.random(1..16), total_memory_mb: Enum.random(1..128), @@ -176,6 +176,7 @@ defmodule Trento.Factory do hostname: Faker.StarWars.character(), fully_qualified_domain_name: Faker.Internet.domain_name(), ip_addresses: [Faker.Internet.ip_v4_address()], + netmasks: [Enum.random([16, 24, 32])], agent_version: Faker.StarWars.planet(), cluster_id: Faker.UUID.v4(), heartbeat: :unknown, diff --git a/test/trento/discovery/policies/host_policy_test.exs b/test/trento/discovery/policies/host_policy_test.exs index 16d21ff28c..858a885a5f 100644 --- a/test/trento/discovery/policies/host_policy_test.exs +++ b/test/trento/discovery/policies/host_policy_test.exs @@ -36,7 +36,7 @@ defmodule Trento.Discovery.Policies.HostPolicyTest do agent_version: "0.1.0", host_id: "779cdd70-e9e2-58ca-b18a-bf3eb3f71244", hostname: "suse", - ip_addresses: ["10.1.1.4", "10.1.1.5", "10.1.1.6"], + ip_addresses: ["10.1.1.4/16", "10.1.1.5/24", "10.1.1.6/32"], installation_source: :unknown } } = @@ -52,7 +52,7 @@ defmodule Trento.Discovery.Policies.HostPolicyTest do agent_version: "0.1.0", host_id: "779cdd70-e9e2-58ca-b18a-bf3eb3f71244", hostname: "suse", - ip_addresses: ["10.1.1.4", "10.1.1.5", "10.1.1.6"], + ip_addresses: ["10.1.1.4/16", "10.1.1.5/24", "10.1.1.6/32"], installation_source: :community } } = @@ -61,6 +61,20 @@ defmodule Trento.Discovery.Policies.HostPolicyTest do |> HostPolicy.handle() end + test "should return the expected commands when a host_discovery payload without netmasks is handled" do + assert { + :ok, + %RegisterHost{ + ip_addresses: ["10.1.1.4", "10.1.1.5", "10.1.1.6"] + } + } = + "host_discovery" + |> load_discovery_event_fixture() + |> pop_in(["payload", "netmasks"]) + |> elem(1) + |> HostPolicy.handle() + end + test "should return the expected commands when a cloud_discovery payload with an azure provider is handled" do assert { :ok, diff --git a/test/trento/hosts/projections/host_projector_test.exs b/test/trento/hosts/projections/host_projector_test.exs index 276e4d7bed..5bc3dcbed1 100644 --- a/test/trento/hosts/projections/host_projector_test.exs +++ b/test/trento/hosts/projections/host_projector_test.exs @@ -70,6 +70,7 @@ defmodule Trento.Hosts.Projections.HostProjectorTest do hostname: hostname, id: id, ip_addresses: ip_addresses, + netmasks: netmasks, provider: provider, provider_data: provider_data } = host_projection = Repo.get!(HostReadModel, event.host_id) @@ -77,7 +78,12 @@ defmodule Trento.Hosts.Projections.HostProjectorTest do assert event.host_id == host_projection.id assert event.hostname == host_projection.hostname assert event.fully_qualified_domain_name == host_projection.fully_qualified_domain_name - assert event.ip_addresses == host_projection.ip_addresses + + assert event.ip_addresses == + Enum.zip_with([ip_addresses, netmasks], fn [address, netmaks] -> + "#{address}/#{netmaks}" + end) + assert event.agent_version == host_projection.agent_version assert event.heartbeat == host_projection.heartbeat @@ -89,6 +95,7 @@ defmodule Trento.Hosts.Projections.HostProjectorTest do hostname: ^hostname, id: ^id, ip_addresses: ^ip_addresses, + netmasks: ^netmasks, provider: ^provider, provider_data: ^provider_data }, @@ -113,6 +120,26 @@ defmodule Trento.Hosts.Projections.HostProjectorTest do 1000 end + test "should project nil netmasks when HostRegistered event without netmasks is received" do + event = build(:host_registered_event, ip_addresses: [Faker.Internet.ip_v4_address()]) + + ProjectorTestHelper.project(HostProjector, event, "host_projector") + + %{ + ip_addresses: ip_addresses, + netmasks: [nil] + } = Repo.get!(HostReadModel, event.host_id) + + assert event.ip_addresses == ip_addresses + + assert_broadcast "host_registered", + %{ + ip_addresses: ^ip_addresses, + netmasks: [nil] + }, + 1000 + end + test "should update the cluster_id field when HostAddedToCluster event is received and the host was already registered" do insert( :host, @@ -206,15 +233,17 @@ defmodule Trento.Hosts.Projections.HostProjectorTest do test "should update an existing host when HostDetailsUpdated event is received", %{ host_id: host_id } do + ip_address = Faker.Internet.ip_v4_address() + netmask = Enum.random([16, 24, 32]) + %{ agent_version: agent_version, - hostname: hostname, - ip_addresses: ip_addresses + hostname: hostname } = event = %HostDetailsUpdated{ host_id: host_id, hostname: Faker.StarWars.character(), - ip_addresses: [Faker.Internet.ip_v4_address()], + ip_addresses: ["#{ip_address}/#{netmask}"], agent_version: Faker.StarWars.planet(), cpu_count: Enum.random(1..16), total_memory_mb: Enum.random(1..128), @@ -227,7 +256,8 @@ defmodule Trento.Hosts.Projections.HostProjectorTest do assert event.host_id == host_projection.id assert event.hostname == host_projection.hostname - assert event.ip_addresses == host_projection.ip_addresses + assert [ip_address] == host_projection.ip_addresses + assert [netmask] == host_projection.netmasks assert event.agent_version == host_projection.agent_version assert_broadcast "host_details_updated", @@ -235,7 +265,8 @@ defmodule Trento.Hosts.Projections.HostProjectorTest do agent_version: ^agent_version, hostname: ^hostname, id: ^host_id, - ip_addresses: ^ip_addresses, + ip_addresses: [^ip_address], + netmasks: [^netmask], provider_data: nil }, 1000