class Bosh::Director::Api::CloudConfigManager

Public Instance Methods

find_by_id(id) click to toggle source
# File lib/bosh/director/api/cloud_config_manager.rb, line 21
def find_by_id(id)
  Bosh::Director::Models::CloudConfig.find(id: id)
end
latest() click to toggle source
# File lib/bosh/director/api/cloud_config_manager.rb, line 17
def latest
  list(1).first
end
list(limit) click to toggle source
# File lib/bosh/director/api/cloud_config_manager.rb, line 13
def list(limit)
  Bosh::Director::Models::CloudConfig.order(Sequel.desc(:id)).limit(limit).to_a
end
update(cloud_config_yaml) click to toggle source
# File lib/bosh/director/api/cloud_config_manager.rb, line 5
def update(cloud_config_yaml)
  cloud_config = Bosh::Director::Models::CloudConfig.new(
    properties: cloud_config_yaml
  )
  validate_manifest!(cloud_config)
  cloud_config.save
end

Private Instance Methods

validate_manifest!(cloud_config) click to toggle source
# File lib/bosh/director/api/cloud_config_manager.rb, line 27
def validate_manifest!(cloud_config)
  # FIXME: we really just need to validate the manifest, we don't care about the subnets being able to reserve IPs here
  global_network_resolver = Bosh::Director::DeploymentPlan::NullGlobalNetworkResolver.new

  parser = Bosh::Director::DeploymentPlan::CloudManifestParser.new(Config.logger)
  _ = parser.parse(cloud_config.manifest, global_network_resolver, nil) # valid if this doesn't blow up
end