Class: Bosh::Gen::Models::DeploymentManifest

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/gen/models/deployment_manifest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, director_uuid, release_properties, cloud_properties, properties) ⇒ DeploymentManifest

Returns a new instance of DeploymentManifest.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/bosh/gen/models/deployment_manifest.rb', line 7

def initialize(name, director_uuid, release_properties, cloud_properties, properties)
  @manifest = {}
  @cloud_properties = cloud_properties
  @release_properties = release_properties
  @properties = properties
  @security_groups = ["default"]
  @stemcell_version = "latest"
  @stemcell = { "name" => "bosh-stemcell", "version" => @stemcell_version }
  @persistent_disk = cloud_properties.delete("persistent_disk").to_i
  @static_ips = cloud_properties.delete("static_ips") || []

  # Ignore current release version and set to 'latest'
  # This is much more helpful in early development days
  # of a release
  release_properties["version"] = 'latest'

  manifest["name"] = name
  manifest["director_uuid"] = director_uuid
  manifest["release"] = release_properties.dup
  manifest["compilation"] = {
    "workers" => 10,
    "network" => "default",
    "reuse_compilation_vms" => true,
    "cloud_properties" => cloud_properties.dup
  }
  manifest["update"] = {
    "canaries" => 1,
    "canary_watch_time" => 30000,
    "update_watch_time" => 30000,
    "max_in_flight" => 4,
    "max_errors" => 1
  }
  manifest["networks"] = [
    {
      "name" => "default",
      "type" => "dynamic",
      "cloud_properties" => { "security_groups" => @security_groups.dup }
    },
    {
      "name" => "vip_network",
      "type" => "vip",
      "cloud_properties" => { "security_groups" => @security_groups.dup }
    }
  ]
  manifest["resource_pools"] = [
    {
      "name" => "common",
      "network" => "default",
      "stemcell" => @stemcell,
      "cloud_properties" => cloud_properties.dup
    }
  ]
  manifest["resource_pools"].first["persistent_disk"] = @persistent_disk if @persistent_disk > 0
  manifest["jobs"] = []
  manifest["properties"] = @properties
end

Instance Attribute Details

#manifestObject (readonly)

Returns the value of attribute manifest.



5
6
7
# File 'lib/bosh/gen/models/deployment_manifest.rb', line 5

def manifest
  @manifest
end

Instance Method Details

#jobs=(jobs) ⇒ Object

Each item of jobs is a hash. The minimum hash is: { “name” => “jobname” } This is the equivalent to: { “name” => “jobname”, “template” => “jobname”, “instances” => 1}



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/bosh/gen/models/deployment_manifest.rb', line 69

def jobs=(jobs)
  total_instances = 0
  static_ips = @static_ips.dup
  manifest["jobs"] = []
  jobs.each do |job|
    job_instances = job["instances"] || 1
    manifest_job = {
      "name" => job["name"],
      "templates" => [
        { "name" => job["template"] || job["name"],
          "release" => @release_properties["name"]
        }
      ],
      "instances" => job_instances,
      "resource_pool" => "common",
      "networks" => [
        {
          "name" => "default",
          "default" => %w[dns gateway]
        }
      ]
    }
    if static_ips.length > 0
      job_ips, static_ips = static_ips[0..job_instances-1], static_ips[job_instances..-1]
      manifest_job["networks"] << {
        "name" => "vip_network",
        "static_ips" => job_ips
      }
    end
    manifest_job["persistent_disk"] = @persistent_disk if @persistent_disk > 0
    manifest["jobs"] << manifest_job
  end
end

#to_yamlObject



103
104
105
# File 'lib/bosh/gen/models/deployment_manifest.rb', line 103

def to_yaml
  manifest.to_yaml
end