Class: Bosh::Director::DeploymentPlan::ManifestValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/deployment_plan/manifest_validator.rb

Constant Summary collapse

CLOUD_MANIFEST_KEYS =
['resource_pools', 'compilation', 'disk_pools', 'networks']

Instance Method Summary collapse

Instance Method Details

#validate(manifest, cloud_config) ⇒ Object



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
# File 'lib/bosh/director/deployment_plan/manifest_validator.rb', line 8

def validate(manifest, cloud_config)
  raise_if_has_key(manifest, 'vm_types')
  raise_if_has_key(manifest, 'azs')
  raise_if_has_key(manifest, 'disk_types')

  if cloud_config.nil?
    if manifest.has_key?('jobs')
      manifest['jobs'].each do |job|
        if job.has_key?('migrated_from')
          raise Bosh::Director::DeploymentInvalidProperty,
            "Deployment manifest instance groups contain 'migrated_from', but it can only be used with cloud-config."
        end
      end
    end

    raise_if_has_key(manifest, 'stemcells')
  else
    deployment_cloud_properties = manifest.keys & CLOUD_MANIFEST_KEYS
    if deployment_cloud_properties.any?
      raise(
        Bosh::Director::DeploymentInvalidProperty,
        "Deployment manifest should not contain cloud config properties: #{deployment_cloud_properties}"
      )
    end
  end
end