Skip to content

Commit

Permalink
Implement container volume parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cben committed Jul 30, 2017
1 parent c01a924 commit 6ba09f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,10 @@ def initialize_inventory_collections
:parent => manager,
:builder_params => {:ems_id => manager.id},
:association => :persistent_volume_claims,
:use_ar_object => true # serialized :capacity attr
:use_ar_object => true, # serialized :capacity attr
# TODO: add container_project_id column to persistent_volume_claims.
:secondary_refs => {:by_namespace_and_name => [:namespace, :name]},
:attributes_blacklist => [:namespace],
)
)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ def get_persistent_volume_claims_graph(inv)
inv["persistent_volume_claim"].each do |pvc|
h = parse_persistent_volume_claim(pvc)

h.except!(:namespace)

collection.build(h)
end
end
Expand All @@ -386,11 +384,8 @@ def get_persistent_volumes_graph(inv)

h.except!(:namespace) # TODO: project untested?

_pvc_ref = h.delete(:persistent_volume_claim_ref)
#h[:persistent_volume_claim] = pvc_ref && @data_index.fetch_path(
# path_for_entity("persistent_volume_claim"),
# :by_namespace_and_name, pvc_ref[:namespace], pvc_ref[:name]
# )
pvc_ref = h.delete(:persistent_volume_claim_ref)
h[:persistent_volume_claim] = lazy_find_persistent_volume_claim(pvc_ref)
collection.build(h)
end
end
Expand All @@ -416,6 +411,7 @@ def get_pods_graph(inv)

get_containers_graph(container_group, children[:containers])
get_container_conditions_graph(container_group, children[:container_conditions])
get_container_volumes_graph(container_group, children[:container_volumes])
get_custom_attributes_graph(container_group,
:labels => custom_attrs[:labels],
# The actual section is "node_selectors"
Expand All @@ -440,6 +436,8 @@ def get_container_volumes_graph(parent, hashes)
collection = @inv_collections[:container_volumes]
hashes.to_a.each do |h|
h = h.merge(:parent => parent)
pvc_ref = h.delete(:persistent_volume_claim_ref)
h[:persistent_volume_claim] = lazy_find_persistent_volume_claim(pvc_ref)
collection.build(h)
end
end
Expand Down Expand Up @@ -1328,5 +1326,10 @@ def lazy_find_build_pod(hash)
return nil if hash.nil?
@inv_collections[:container_build_pods].lazy_find_by(hash, :ref => :by_namespace_and_name)
end

def lazy_find_persistent_volume_claim(hash)
return nil if hash.nil?
@inv_collections[:persistent_volume_claims].lazy_find_by(hash, :ref => :by_namespace_and_name)
end
end
end

0 comments on commit 6ba09f4

Please sign in to comment.