-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identify clustered sap instances #3397
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e98f0c7
Identify clustered sap instances
arbulu89 7cb643b
Move application instance only when clustered
arbulu89 ca07aed
Remove not used sid and additional_sids fields
arbulu89 5d821bf
Update and adapt existing tests
arbulu89 dba7f30
Add new tests
arbulu89 55dadfd
Remove duplicated code
arbulu89 c2f21b8
Fix function spec
arbulu89 3b131a4
Undo changes in legacy events
arbulu89 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule Trento.Clusters.Enums.SapInstanceResourceType do | ||
@moduledoc """ | ||
Type that represents the discovered type of a clustered SAP instance. | ||
""" | ||
|
||
use Trento.Support.Enum, values: [:sap_hana_topology, :sap_instance] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
defmodule Trento.Clusters.ValueObjects.SapInstance do | ||
@moduledoc """ | ||
Clustered SAP instance | ||
""" | ||
@required_fields [:name, :sid, :instance_number, :resource_type] | ||
|
||
use Trento.Support.Type | ||
|
||
require Trento.Clusters.Enums.SapInstanceResourceType, as: SapInstanceResourceType | ||
|
||
deftype do | ||
field :name, :string | ||
field :sid, :string | ||
field :instance_number, :string | ||
field :hostname, :string | ||
field :resource_type, Ecto.Enum, values: SapInstanceResourceType.values() | ||
end | ||
|
||
@spec get_hana_instance_sid([__MODULE__.t()]) :: String.t() | ||
def get_hana_instance_sid(sap_instances) do | ||
Enum.find_value(sap_instances, "", fn %{resource_type: resource_type, sid: sid} -> | ||
if resource_type == SapInstanceResourceType.sap_hana_topology() do | ||
sid | ||
else | ||
nil | ||
end | ||
end) | ||
end | ||
|
||
@spec get_sap_instance_sids([__MODULE__.t()]) :: [String.t()] | ||
def get_sap_instance_sids(sap_instances) do | ||
sap_instances | ||
|> Enum.filter(fn %{resource_type: resource_type} -> | ||
resource_type == SapInstanceResourceType.sap_instance() | ||
end) | ||
|> Enum.map(fn %{sid: sid} -> sid end) | ||
|> Enum.uniq() | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will raise an exception if there's more than one result, IIRC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the
host_id
, UUID and primary key in the database. It is impossible by database definition as the host can only have one cluster.But thank you for pointing it out, you never know until you double-check hehe