Class: Hula::BoshManifest
- Inherits:
-
Object
- Object
- Hula::BoshManifest
show all
- Defined in:
- lib/hula/bosh_manifest.rb,
lib/hula/bosh_manifest/job.rb
Defined Under Namespace
Classes: Job, NoManifestPathGiven
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(manifest_yaml, path: nil) ⇒ BoshManifest
Returns a new instance of BoshManifest.
20
21
22
23
24
|
# File 'lib/hula/bosh_manifest.rb', line 20
def initialize(manifest_yaml, path: nil)
@manifest_hash = YAML.load(manifest_yaml)
@path = path
fail 'Invalid manifest' unless manifest_hash.is_a?(Hash)
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
18
19
20
|
# File 'lib/hula/bosh_manifest.rb', line 18
def path
@path
end
|
Class Method Details
.from_file(path) ⇒ Object
26
27
28
29
30
|
# File 'lib/hula/bosh_manifest.rb', line 26
def self.from_file(path)
new(File.read(path), path: path)
rescue Errno::ENOENT
raise "Could not open the manifest file: '#{path}'"
end
|
Instance Method Details
#deployment_name ⇒ Object
45
46
47
48
49
|
# File 'lib/hula/bosh_manifest.rb', line 45
def deployment_name
manifest_hash.fetch('name')
rescue KeyError
raise "Could not find deployment name in #{manifest_hash.inspect}"
end
|
#job(job_name) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/hula/bosh_manifest.rb', line 51
def job(job_name)
jobs = manifest_hash.fetch('jobs')
job = jobs.detect { |j| j.fetch('name') == job_name }
fail "Could not find job name '#{job_name}' in job list: #{jobs.inspect}" if job.nil?
Job.new(job)
end
|
#property(property_name) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/hula/bosh_manifest.rb', line 32
def property(property_name)
components = property_components(property_name)
traverse_properties(components)
rescue KeyError
raise "Could not find property '#{property_name}' in #{properties.inspect}"
end
|
#resource_pools ⇒ Object
60
61
62
|
# File 'lib/hula/bosh_manifest.rb', line 60
def resource_pools
manifest_hash.fetch('resource_pools')
end
|
#set_property(property_name, value) ⇒ Object
39
40
41
42
43
|
# File 'lib/hula/bosh_manifest.rb', line 39
def set_property(property_name, value)
components = property_components(property_name)
traverse_properties_and_set(properties, components, value)
save
end
|