class Bosh::Deployer::DeploymentsState
Constants
- DEPLOYMENTS_FILE
Attributes
deployments[R]
file[R]
state[R]
Public Class Methods
load_from_dir(dir, logger)
click to toggle source
# File lib/bosh/deployer/deployments_state.rb, line 10 def self.load_from_dir(dir, logger) file = File.join(dir, DEPLOYMENTS_FILE) if File.exists?(file) logger.info("Loading existing deployment data from: #{file}") deployments = Psych.load_file(file) else logger.info("No existing deployments found (will save to #{file})") deployments = { 'instances' => [], 'disks' => [] } end new(deployments, file) end
new(deployments, file)
click to toggle source
# File lib/bosh/deployer/deployments_state.rb, line 22 def initialize(deployments, file) @deployments = deployments @file = file end
Public Instance Methods
exists?()
click to toggle source
# File lib/bosh/deployer/deployments_state.rb, line 49 def exists? return false unless state [state.vm_cid, state.stemcell_cid, state.disk_cid].any? end
load_deployment(name)
click to toggle source
# File lib/bosh/deployer/deployments_state.rb, line 27 def load_deployment(name) models_instance.multi_insert(deployments['instances']) @state = models_instance.find(name: name) if state.nil? @state = models_instance.new state.uuid = "bm-#{SecureRandom.uuid}" state.name = name state.stemcell_sha1 = nil state.save end end
save(infrastructure)
click to toggle source
# File lib/bosh/deployer/deployments_state.rb, line 40 def save(infrastructure) state.save deployments['instances'] = models_instance.map { |instance| instance.values } File.open(file, 'w') do |file| file.write(Psych.dump(deployments)) end end
Private Instance Methods
models_instance()
click to toggle source
# File lib/bosh/deployer/deployments_state.rb, line 56 def models_instance Models::Instance end