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