Parent

Class/Module Index [+]

Quicksearch

OpenShift::Runtime::DeploymentMetadata

Public Class Methods

new(container, deployment_datetime) click to toggle source

Creates a new DeploymentMetadata instance for the given deployment_datetime.

If the file doesn't exist, create it and set the defaults.

If unable to create the file, log message and set the defaults.

If the file does exist, load it from disk.

@param container [ApplicationContainer] model of OpenShift application @param deployment_datetime [to_s] Timestamp of deployment in question

# File lib/openshift-origin-node/model/deployment_metadata.rb, line 48
def initialize(container, deployment_datetime)
  @file = PathUtils.join(container.container_dir, 'app-deployments', deployment_datetime, 'metadata.json')

  empty = File.exists?(@file) && File.stat(@file).size == 0
  container.logger.warn("#{@file} was found empty. Will attempt to write defaults") if empty

  if File.exists?(@file) && !empty
    load
  else
    File.new(@file, 'w', 0644)
    @metadata = defaults
    container.set_rw_permission(@file)

    save

  end
rescue => e
  container.logger.warn("Unable to create or update #{@file}. Gear may be exceeding quota. #{e.message}")
  @metadata = defaults
end

Public Instance Methods

as_json(options={}) click to toggle source
# File lib/openshift-origin-node/model/deployment_metadata.rb, line 80
def as_json(options={})
  {
    git_ref: @metadata[:git_ref],
    git_sha1: @metadata[:git_sha1],
    id: @metadata[:id],
    hot_deploy: @metadata[:hot_deploy],
    force_clean_build: @metadata[:force_clean_build],
    activations: @metadata[:activations],
    checksum: @metadata[:checksum]
  }
end
load() click to toggle source
# File lib/openshift-origin-node/model/deployment_metadata.rb, line 69
def load
  File.open(@file, 'r') do |f|
    # JSON.load is not used to prevent class injection. BZ#1086427
    @metadata = HashWithIndifferentAccess.new(JSON.parse(f.read))
  end
end
record_activation() click to toggle source
# File lib/openshift-origin-node/model/deployment_metadata.rb, line 36
def record_activation
  self.activations << Time.now.to_f
end
save() click to toggle source
# File lib/openshift-origin-node/model/deployment_metadata.rb, line 76
def save
  File.open(@file, "w") { |f| f.write JSON.dump(self) }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.