VM dashboard - do not crash on missing configuration

This commit is contained in:
Timothée Floure 2021-04-12 15:48:49 +02:00
parent 82c12bd234
commit 11270fc7b1
Signed by: tfloure
GPG key ID: 4502C902C00A1E12

View file

@ -11,12 +11,12 @@ defmodule Meta.OpenNebula do
# OpenNebula daemon.
@endpoint "/RPC2"
defp get_opennebula_config(key) do
Application.get_env(:meta, :opennebula, []) |> Keyword.get(key)
defp get_opennebula_config(key, default \\ nil) do
Application.get_env(:meta, :opennebula, []) |> Keyword.get(key, default)
end
def get_locations() do
get_opennebula_config(:locations)
get_opennebula_config(:locations, [])
|> Enum.map(fn m -> Map.get(m, :name) end)
end