Fix mapping of lists in ONE Records, import both VM and VM_POOL
subrecords
This commit is contained in:
parent
ae52442bd6
commit
053d5a3320
2 changed files with 12 additions and 2 deletions
|
@ -63,6 +63,9 @@ defmodule RecycledCloud.OpenNebula.Schema do
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp transform_value({k, l}) when is_list(l) do
|
||||||
|
{k, Enum.map(l, fn v -> map_record(v) end)}
|
||||||
|
end
|
||||||
defp transform_value({k, v}), do: {k, map_record(v)}
|
defp transform_value({k, v}), do: {k, map_record(v)}
|
||||||
|
|
||||||
# Here be dragons! See moduledoc.
|
# Here be dragons! See moduledoc.
|
||||||
|
|
|
@ -19,8 +19,15 @@ defmodule RecycledCloud.OpenNebula.Schema.Records do
|
||||||
|
|
||||||
def get_model_for(object), do: Map.get(@models, object)
|
def get_model_for(object), do: Map.get(@models, object)
|
||||||
|
|
||||||
for {name, record} <- Record.extract_all(from: Schema.get_hrl_for("vm")) do
|
extract = fn name, acc -> Record.extract_all(from: Schema.get_hrl_for(name)) ++ acc end
|
||||||
|
sources = ["vm", "vm_pool"]
|
||||||
|
|> Enum.reduce([], extract)
|
||||||
|
|> Enum.sort_by(fn {name, _} -> name end)
|
||||||
|
|> Enum.dedup_by(fn {name, _} -> name end)
|
||||||
|
|
||||||
|
#IO.inspect sources |> Enum.dedup_by(fn {, _} -> name end)
|
||||||
|
|
||||||
|
for {name, record} <- sources do
|
||||||
Record.defrecord name, record
|
Record.defrecord name, record
|
||||||
end
|
end
|
||||||
Record.defrecord :VM_POOL, Record.extract(:VM_POOL, from: Schema.get_hrl_for("vm_pool"))
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue