module GClouder::Resources::Container::NodePools
Public Class Methods
clean()
click to toggle source
FIXME: create a collection then iterate through it to avoid printing messages when no clusters are undefined
# File lib/gclouder/resources/container/node_pools.rb, line 56 def self.clean return if GClouder::Resources::Container::Clusters::Local.list.empty? header :clean GClouder::Resources::Container::Clusters::Local.list.each do |region, clusters| info region, heading: true, indent: 2 clusters.each do |cluster| next if undefined(cluster).empty? info cluster["name"], heading: true, indent: 3 undefined(cluster).each do |namespace, resources| resources.each do |resource| message = resource['name'] message += " (not defined locally)" info warning message, indent: 4 #resource_purge(namespace, user) end end end end end
delete_default_nodepool()
click to toggle source
# File lib/gclouder/resources/container/node_pools.rb, line 14 def self.delete_default_nodepool Resource.purge :"container node-pools", "default-pool" end
ensure()
click to toggle source
# File lib/gclouder/resources/container/node_pools.rb, line 32 def self.ensure return if GClouder::Resources::Container::Clusters::Local.list.empty? header GClouder::Resources::Container::Clusters::Local.list.each do |region, clusters| info region, heading: true, indent: 2 clusters.each do |cluster| next if cluster["node_pools"].empty? info cluster["name"], heading: true, indent: 3 cluster["node_pools"].each do |pool| NodePool.create(cluster, pool) NodePool.resize(cluster, pool) NodePool.autoscale(cluster, pool) end end end end
header(stage = :ensure)
click to toggle source
# File lib/gclouder/resources/container/node_pools.rb, line 50 def self.header(stage = :ensure) info "[#{stage}] container / node-pools", title: true, indent: 1 end
undefined(cluster)
click to toggle source
# File lib/gclouder/resources/container/node_pools.rb, line 79 def self.undefined(cluster) return {} unless Resource.resource?("container clusters", cluster["name"], silent: true) self::Remote.list(cluster).each_with_object({}) do |(namespace, resources), collection| resources.each do |resource| namespace_resources = self::Local.list(cluster)[namespace] next if namespace_resources && namespace_resources.select {|r| resource["name"] == r["name"] }.length > 0 collection[namespace] ||= [] collection[namespace] << resource end end end
validate()
click to toggle source
# File lib/gclouder/resources/container/node_pools.rb, line 18 def self.validate return if GClouder::Resources::Container::Clusters::Local.list.empty? header :validate GClouder::Resources::Container::Clusters::Local.list.each do |region, clusters| info region, heading: true, indent: 2 clusters.each do |cluster| next if cluster["node_pools"].empty? info cluster["name"], heading: true, indent: 3 Local.validate(cluster) end end end