diff --git a/lib/trento/hosts/commands/discover_software_updates.ex b/lib/trento/hosts/commands/discover_software_updates.ex deleted file mode 100644 index ebb5c35eec..0000000000 --- a/lib/trento/hosts/commands/discover_software_updates.ex +++ /dev/null @@ -1,13 +0,0 @@ -defmodule Trento.Hosts.Commands.DiscoverSoftwareUpdates do - @moduledoc """ - Issues the software updates discovery for a host - """ - - @required_fields :all - - use Trento.Support.Command - - defcommand do - field :host_id, Ecto.UUID - end -end diff --git a/lib/trento/hosts/host.ex b/lib/trento/hosts/host.ex index 7ba059769f..e36632f84e 100644 --- a/lib/trento/hosts/host.ex +++ b/lib/trento/hosts/host.ex @@ -79,7 +79,6 @@ defmodule Trento.Hosts.Host do CompleteHostChecksExecution, CompleteSoftwareUpdatesDiscovery, DeregisterHost, - DiscoverSoftwareUpdates, RegisterHost, RequestHostDeregistration, RollUpHost, @@ -551,25 +550,6 @@ defmodule Trento.Hosts.Host do # Software Updates Discovery - def execute( - %Host{fully_qualified_domain_name: nil}, - %DiscoverSoftwareUpdates{} - ), - do: [] - - def execute( - %Host{ - host_id: host_id, - fully_qualified_domain_name: fully_qualified_domain_name - }, - %DiscoverSoftwareUpdates{} - ) do - %SoftwareUpdatesDiscoveryRequested{ - host_id: host_id, - fully_qualified_domain_name: fully_qualified_domain_name - } - end - def execute( %Host{ host_id: host_id, diff --git a/lib/trento/router.ex b/lib/trento/router.ex index 288cd6954b..fbd8d98e86 100644 --- a/lib/trento/router.ex +++ b/lib/trento/router.ex @@ -16,7 +16,6 @@ defmodule Trento.Router do CompleteHostChecksExecution, CompleteSoftwareUpdatesDiscovery, DeregisterHost, - DiscoverSoftwareUpdates, RegisterHost, RequestHostDeregistration, RollUpHost, @@ -64,7 +63,6 @@ defmodule Trento.Router do RequestHostDeregistration, DeregisterHost, CompleteHostChecksExecution, - DiscoverSoftwareUpdates, CompleteSoftwareUpdatesDiscovery, ClearSoftwareUpdatesDiscovery ], diff --git a/test/trento/hosts/host_test.exs b/test/trento/hosts/host_test.exs index f702e161c4..f7919d12a9 100644 --- a/test/trento/hosts/host_test.exs +++ b/test/trento/hosts/host_test.exs @@ -8,7 +8,6 @@ defmodule Trento.Hosts.HostTest do CompleteHostChecksExecution, CompleteSoftwareUpdatesDiscovery, DeregisterHost, - DiscoverSoftwareUpdates, RegisterHost, RequestHostDeregistration, RollUpHost, @@ -1597,7 +1596,6 @@ defmodule Trento.Hosts.HostTest do describe "software updates discovery" do test "should not accept software updates discovery commands if a host is not registered yet" do commands = [ - %DiscoverSoftwareUpdates{host_id: Faker.UUID.v4()}, %CompleteSoftwareUpdatesDiscovery{host_id: Faker.UUID.v4()}, %ClearSoftwareUpdatesDiscovery{host_id: Faker.UUID.v4()} ] @@ -1607,64 +1605,6 @@ defmodule Trento.Hosts.HostTest do end end - test "should not trigger the software updates discovery process without a valid FQDN" do - host_id = Faker.UUID.v4() - - initial_events = [ - build(:host_registered_event, - host_id: host_id, - fully_qualified_domain_name: nil - ), - build(:heartbeat_succeded, host_id: host_id) - ] - - assert_events_and_state( - initial_events, - DiscoverSoftwareUpdates.new!(%{ - host_id: host_id - }), - [], - fn host -> - assert %Host{ - host_id: ^host_id, - fully_qualified_domain_name: nil, - heartbeat: Health.passing() - } = host - end - ) - end - - test "should trigger the software updates discovery process" do - host_id = Faker.UUID.v4() - fully_qualified_domain_name = Faker.Internet.domain_name() - - initial_events = [ - build(:host_registered_event, - host_id: host_id, - fully_qualified_domain_name: fully_qualified_domain_name - ), - build(:heartbeat_succeded, host_id: host_id) - ] - - assert_events_and_state( - initial_events, - DiscoverSoftwareUpdates.new!(%{ - host_id: host_id - }), - %SoftwareUpdatesDiscoveryRequested{ - host_id: host_id, - fully_qualified_domain_name: fully_qualified_domain_name - }, - fn host -> - assert %Host{ - host_id: ^host_id, - fully_qualified_domain_name: ^fully_qualified_domain_name, - heartbeat: Health.passing() - } = host - end - ) - end - defp get_host_health_changed_event(host_id, scenario) do case Map.get(scenario, :expect_host_health_changed, true) do true -> @@ -1972,7 +1912,6 @@ defmodule Trento.Hosts.HostTest do vpc_id: "vpc-12345" } }), - DiscoverSoftwareUpdates.new!(%{host_id: host_id}), RollUpHost.new!(%{ host_id: host_id }) @@ -2315,7 +2254,6 @@ defmodule Trento.Hosts.HostTest do %UpdateHeartbeat{host_id: host_id}, %UpdateProvider{host_id: host_id}, %UpdateSlesSubscriptions{host_id: host_id}, - %DiscoverSoftwareUpdates{host_id: host_id}, %CompleteSoftwareUpdatesDiscovery{host_id: host_id}, %ClearSoftwareUpdatesDiscovery{host_id: host_id}, %SelectHostChecks{host_id: host_id}