Class: Bosh::Stemcell::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/stemcell/definition.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(infrastructure, hypervisor_name, operating_system, agent, light) ⇒ Definition

Returns a new instance of Definition.



26
27
28
29
30
31
32
# File 'lib/bosh/stemcell/definition.rb', line 26

def initialize(infrastructure, hypervisor_name, operating_system, agent, light)
  @infrastructure = infrastructure
  @hypervisor_name = hypervisor_name
  @operating_system = operating_system
  @agent = agent
  @light = light
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



7
8
9
# File 'lib/bosh/stemcell/definition.rb', line 7

def agent
  @agent
end

#hypervisor_nameObject (readonly)

Returns the value of attribute hypervisor_name.



7
8
9
# File 'lib/bosh/stemcell/definition.rb', line 7

def hypervisor_name
  @hypervisor_name
end

#infrastructureObject (readonly)

Returns the value of attribute infrastructure.



7
8
9
# File 'lib/bosh/stemcell/definition.rb', line 7

def infrastructure
  @infrastructure
end

#operating_systemObject (readonly)

Returns the value of attribute operating_system.



7
8
9
# File 'lib/bosh/stemcell/definition.rb', line 7

def operating_system
  @operating_system
end

Class Method Details

.for(infrastructure_name, hypervisor_name, operating_system_name, operating_system_version, agent_name, light) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bosh/stemcell/definition.rb', line 9

def self.for(
  infrastructure_name,
  hypervisor_name,
  operating_system_name,
  operating_system_version,
  agent_name,
  light
)
  new(
    Bosh::Stemcell::Infrastructure.for(infrastructure_name),
    hypervisor_name,
    Bosh::Stemcell::OperatingSystem.for(operating_system_name, operating_system_version),
    Bosh::Stemcell::Agent.for(agent_name),
    light,
  )
end

Instance Method Details

#==(other) ⇒ Object



51
52
53
54
55
56
# File 'lib/bosh/stemcell/definition.rb', line 51

def ==(other)
  infrastructure == other.infrastructure &&
    operating_system == other.operating_system &&
    agent == other.agent &&
    light? == other.light?
end

#disk_formatsObject



47
48
49
# File 'lib/bosh/stemcell/definition.rb', line 47

def disk_formats
  infrastructure.disk_formats
end

#light?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/bosh/stemcell/definition.rb', line 58

def light?
  @light == true
end

#stemcell_name(disk_format) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bosh/stemcell/definition.rb', line 34

def stemcell_name(disk_format)
  stemcell_name_parts = [
    infrastructure.name,
    hypervisor_name,
    operating_system.name,
  ]
  stemcell_name_parts << operating_system.version if operating_system.version
  stemcell_name_parts << "#{agent.name}_agent" unless agent.name == 'ruby'
  stemcell_name_parts << disk_format unless disk_format == infrastructure.default_disk_format

  stemcell_name_parts.join('-')
end