bosh-director 1.5.0.pre.1113
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +34 -0
- data/bin/bosh-director +36 -0
- data/bin/bosh-director-console +84 -0
- data/bin/bosh-director-drain-workers +42 -0
- data/bin/bosh-director-migrate +58 -0
- data/bin/bosh-director-scheduler +27 -0
- data/bin/bosh-director-worker +76 -0
- data/db/migrations/README +1 -0
- data/db/migrations/director/20110209010747_initial.rb +118 -0
- data/db/migrations/director/20110406055800_add_task_user.rb +9 -0
- data/db/migrations/director/20110518225809_remove_cid_constrain.rb +13 -0
- data/db/migrations/director/20110617211923_add_deployments_release_versions.rb +32 -0
- data/db/migrations/director/20110622212607_add_task_checkpoint_timestamp.rb +9 -0
- data/db/migrations/director/20110628023039_add_state_to_instances.rb +21 -0
- data/db/migrations/director/20110709012332_add_disk_size_to_instances.rb +9 -0
- data/db/migrations/director/20110906183441_add_log_bundles.rb +11 -0
- data/db/migrations/director/20110907194830_add_logs_json_to_templates.rb +9 -0
- data/db/migrations/director/20110915205610_add_persistent_disks.rb +51 -0
- data/db/migrations/director/20111005180929_add_properties.rb +14 -0
- data/db/migrations/director/20111110024617_add_deployment_problems.rb +24 -0
- data/db/migrations/director/20111216214145_recreate_support_for_vms.rb +9 -0
- data/db/migrations/director/20120102084027_add_credentials_to_vms.rb +7 -0
- data/db/migrations/director/20120427235217_allow_multiple_releases_per_deployment.rb +36 -0
- data/db/migrations/director/20120524175805_add_task_type.rb +44 -0
- data/db/migrations/director/20120614001930_delete_redundant_deployment_release_relation.rb +34 -0
- data/db/migrations/director/20120822004528_add_fingerprint_to_templates_and_packages.rb +17 -0
- data/db/migrations/director/20120830191244_add_properties_to_templates.rb +9 -0
- data/db/migrations/director/20121106190739_persist_vm_env.rb +9 -0
- data/db/migrations/director/20130222232131_add_sha1_to_stemcells.rb +9 -0
- data/db/migrations/director/20130312211407_add_commit_hash_to_release_versions.rb +19 -0
- data/db/migrations/director/20130409235338_snapshot.rb +15 -0
- data/db/migrations/director/20130530164918_add_paused_flag_to_instance.rb +14 -0
- data/db/migrations/director/20130531172604_add_director_attributes.rb +13 -0
- data/db/migrations/dns/20120123234908_initial.rb +27 -0
- data/lib/bosh/director.rb +133 -0
- data/lib/bosh/director/agent_client.rb +78 -0
- data/lib/bosh/director/api.rb +29 -0
- data/lib/bosh/director/api/api_helper.rb +81 -0
- data/lib/bosh/director/api/backup_manager.rb +15 -0
- data/lib/bosh/director/api/controller.rb +639 -0
- data/lib/bosh/director/api/controller_helpers.rb +34 -0
- data/lib/bosh/director/api/deployment_lookup.rb +13 -0
- data/lib/bosh/director/api/deployment_manager.rb +60 -0
- data/lib/bosh/director/api/http_constants.rb +16 -0
- data/lib/bosh/director/api/instance_lookup.rb +44 -0
- data/lib/bosh/director/api/instance_manager.rb +63 -0
- data/lib/bosh/director/api/problem_manager.rb +40 -0
- data/lib/bosh/director/api/property_manager.rb +69 -0
- data/lib/bosh/director/api/release_manager.rb +59 -0
- data/lib/bosh/director/api/resource_manager.rb +69 -0
- data/lib/bosh/director/api/resurrector_manager.rb +15 -0
- data/lib/bosh/director/api/snapshot_manager.rb +94 -0
- data/lib/bosh/director/api/stemcell_manager.rb +50 -0
- data/lib/bosh/director/api/task_helper.rb +46 -0
- data/lib/bosh/director/api/task_manager.rb +64 -0
- data/lib/bosh/director/api/user_manager.rb +72 -0
- data/lib/bosh/director/api/vm_state_manager.rb +11 -0
- data/lib/bosh/director/app.rb +35 -0
- data/lib/bosh/director/blob_util.rb +87 -0
- data/lib/bosh/director/blobstores.rb +29 -0
- data/lib/bosh/director/client.rb +156 -0
- data/lib/bosh/director/cloudcheck_helper.rb +204 -0
- data/lib/bosh/director/compile_task.rb +157 -0
- data/lib/bosh/director/config.rb +370 -0
- data/lib/bosh/director/configuration_hasher.rb +114 -0
- data/lib/bosh/director/cycle_helper.rb +36 -0
- data/lib/bosh/director/db_backup.rb +22 -0
- data/lib/bosh/director/db_backup/adapter.rb +3 -0
- data/lib/bosh/director/db_backup/adapter/mysql2.rb +27 -0
- data/lib/bosh/director/db_backup/adapter/postgres.rb +36 -0
- data/lib/bosh/director/db_backup/adapter/sqlite.rb +17 -0
- data/lib/bosh/director/db_backup/error.rb +10 -0
- data/lib/bosh/director/deployment_plan.rb +26 -0
- data/lib/bosh/director/deployment_plan/assembler.rb +430 -0
- data/lib/bosh/director/deployment_plan/compilation_config.rb +54 -0
- data/lib/bosh/director/deployment_plan/compiled_package.rb +35 -0
- data/lib/bosh/director/deployment_plan/dynamic_network.rb +91 -0
- data/lib/bosh/director/deployment_plan/idle_vm.rb +109 -0
- data/lib/bosh/director/deployment_plan/instance.rb +413 -0
- data/lib/bosh/director/deployment_plan/job.rb +470 -0
- data/lib/bosh/director/deployment_plan/manual_network.rb +137 -0
- data/lib/bosh/director/deployment_plan/network.rb +74 -0
- data/lib/bosh/director/deployment_plan/network_subnet.rb +167 -0
- data/lib/bosh/director/deployment_plan/planner.rb +288 -0
- data/lib/bosh/director/deployment_plan/preparer.rb +52 -0
- data/lib/bosh/director/deployment_plan/release.rb +126 -0
- data/lib/bosh/director/deployment_plan/resource_pool.rb +143 -0
- data/lib/bosh/director/deployment_plan/resource_pools.rb +68 -0
- data/lib/bosh/director/deployment_plan/stemcell.rb +56 -0
- data/lib/bosh/director/deployment_plan/template.rb +94 -0
- data/lib/bosh/director/deployment_plan/update_config.rb +80 -0
- data/lib/bosh/director/deployment_plan/updater.rb +55 -0
- data/lib/bosh/director/deployment_plan/vip_network.rb +79 -0
- data/lib/bosh/director/dns_helper.rb +204 -0
- data/lib/bosh/director/download_helper.rb +44 -0
- data/lib/bosh/director/duration.rb +36 -0
- data/lib/bosh/director/encryption_helper.rb +10 -0
- data/lib/bosh/director/errors.rb +198 -0
- data/lib/bosh/director/event_log.rb +136 -0
- data/lib/bosh/director/ext.rb +64 -0
- data/lib/bosh/director/hash_string_vals.rb +13 -0
- data/lib/bosh/director/instance_deleter.rb +109 -0
- data/lib/bosh/director/instance_updater.rb +506 -0
- data/lib/bosh/director/ip_util.rb +67 -0
- data/lib/bosh/director/job_queue.rb +16 -0
- data/lib/bosh/director/job_runner.rb +162 -0
- data/lib/bosh/director/job_updater.rb +121 -0
- data/lib/bosh/director/jobs/backup.rb +86 -0
- data/lib/bosh/director/jobs/base_job.rb +66 -0
- data/lib/bosh/director/jobs/cloud_check/apply_resolutions.rb +46 -0
- data/lib/bosh/director/jobs/cloud_check/scan.rb +38 -0
- data/lib/bosh/director/jobs/cloud_check/scan_and_fix.rb +73 -0
- data/lib/bosh/director/jobs/create_snapshot.rb +23 -0
- data/lib/bosh/director/jobs/delete_deployment.rb +183 -0
- data/lib/bosh/director/jobs/delete_deployment_snapshots.rb +34 -0
- data/lib/bosh/director/jobs/delete_release.rb +219 -0
- data/lib/bosh/director/jobs/delete_snapshots.rb +23 -0
- data/lib/bosh/director/jobs/delete_stemcell.rb +102 -0
- data/lib/bosh/director/jobs/fetch_logs.rb +99 -0
- data/lib/bosh/director/jobs/scheduled_backup.rb +38 -0
- data/lib/bosh/director/jobs/snapshot_deployment.rb +61 -0
- data/lib/bosh/director/jobs/snapshot_deployments.rb +23 -0
- data/lib/bosh/director/jobs/snapshot_self.rb +43 -0
- data/lib/bosh/director/jobs/ssh.rb +59 -0
- data/lib/bosh/director/jobs/update_deployment.rb +110 -0
- data/lib/bosh/director/jobs/update_release.rb +672 -0
- data/lib/bosh/director/jobs/update_stemcell.rb +109 -0
- data/lib/bosh/director/jobs/vm_state.rb +89 -0
- data/lib/bosh/director/lock.rb +133 -0
- data/lib/bosh/director/lock_helper.rb +92 -0
- data/lib/bosh/director/models.rb +29 -0
- data/lib/bosh/director/models/compiled_package.rb +33 -0
- data/lib/bosh/director/models/deployment.rb +22 -0
- data/lib/bosh/director/models/deployment_problem.rb +49 -0
- data/lib/bosh/director/models/deployment_property.rb +21 -0
- data/lib/bosh/director/models/director_attribute.rb +9 -0
- data/lib/bosh/director/models/dns.rb +9 -0
- data/lib/bosh/director/models/dns/domain.rb +9 -0
- data/lib/bosh/director/models/dns/record.rb +7 -0
- data/lib/bosh/director/models/helpers/model_helper.rb +7 -0
- data/lib/bosh/director/models/instance.rb +28 -0
- data/lib/bosh/director/models/log_bundle.rb +10 -0
- data/lib/bosh/director/models/package.rb +30 -0
- data/lib/bosh/director/models/persistent_disk.rb +13 -0
- data/lib/bosh/director/models/release.rb +17 -0
- data/lib/bosh/director/models/release_version.rb +16 -0
- data/lib/bosh/director/models/snapshot.rb +13 -0
- data/lib/bosh/director/models/stemcell.rb +18 -0
- data/lib/bosh/director/models/task.rb +10 -0
- data/lib/bosh/director/models/template.rb +44 -0
- data/lib/bosh/director/models/user.rb +11 -0
- data/lib/bosh/director/models/vm.rb +42 -0
- data/lib/bosh/director/nats_rpc.rb +54 -0
- data/lib/bosh/director/network_reservation.rb +121 -0
- data/lib/bosh/director/next_rebase_version.rb +20 -0
- data/lib/bosh/director/package_compiler.rb +423 -0
- data/lib/bosh/director/problem_handlers/base.rb +153 -0
- data/lib/bosh/director/problem_handlers/inactive_disk.rb +112 -0
- data/lib/bosh/director/problem_handlers/invalid_problem.rb +28 -0
- data/lib/bosh/director/problem_handlers/missing_vm.rb +34 -0
- data/lib/bosh/director/problem_handlers/mount_info_mismatch.rb +62 -0
- data/lib/bosh/director/problem_handlers/out_of_sync_vm.rb +64 -0
- data/lib/bosh/director/problem_handlers/unbound_instance_vm.rb +85 -0
- data/lib/bosh/director/problem_handlers/unresponsive_agent.rb +78 -0
- data/lib/bosh/director/problem_resolver.rb +103 -0
- data/lib/bosh/director/problem_scanner.rb +268 -0
- data/lib/bosh/director/resource_pool_updater.rb +216 -0
- data/lib/bosh/director/scheduler.rb +57 -0
- data/lib/bosh/director/sequel.rb +13 -0
- data/lib/bosh/director/tar_gzipper.rb +47 -0
- data/lib/bosh/director/task_result_file.rb +19 -0
- data/lib/bosh/director/thread_pool.rb +8 -0
- data/lib/bosh/director/validation_helper.rb +55 -0
- data/lib/bosh/director/version.rb +7 -0
- data/lib/bosh/director/vm_creator.rb +80 -0
- data/lib/bosh/director/vm_data.rb +63 -0
- data/lib/bosh/director/vm_metadata_updater.rb +29 -0
- data/lib/bosh/director/vm_reuser.rb +63 -0
- data/lib/cloud/dummy.rb +149 -0
- metadata +664 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class CompiledPackage < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
many_to_one :package
|
6
|
+
many_to_one :stemcell
|
7
|
+
|
8
|
+
def validate
|
9
|
+
validates_presence [:package_id, :stemcell_id, :sha1,
|
10
|
+
:blobstore_id, :dependency_key]
|
11
|
+
validates_unique [:package_id, :stemcell_id, :dependency_key]
|
12
|
+
validates_unique [:package_id, :stemcell_id, :build]
|
13
|
+
end
|
14
|
+
|
15
|
+
def name
|
16
|
+
package.name
|
17
|
+
end
|
18
|
+
|
19
|
+
def version
|
20
|
+
package.version
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.generate_build_number(package, stemcell)
|
24
|
+
attrs = {
|
25
|
+
:package_id => package.id,
|
26
|
+
:stemcell_id => stemcell.id
|
27
|
+
}
|
28
|
+
|
29
|
+
filter(attrs).max(:build).to_i + 1
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class Deployment < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
many_to_many :stemcells
|
6
|
+
many_to_many :releases
|
7
|
+
many_to_many :release_versions
|
8
|
+
one_to_many :job_instances, :class => "Bosh::Director::Models::Instance"
|
9
|
+
one_to_many :vms
|
10
|
+
one_to_many :properties, :class => "Bosh::Director::Models::DeploymentProperty"
|
11
|
+
one_to_many :problems, :class => "Bosh::Director::Models::DeploymentProblem"
|
12
|
+
|
13
|
+
def validate
|
14
|
+
validates_presence :name
|
15
|
+
validates_unique :name
|
16
|
+
validates_format VALID_ID, :name
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Deployment.plugin :association_dependencies
|
21
|
+
Deployment.add_association_dependencies :stemcells => :nullify, :problems => :destroy
|
22
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class DeploymentProblem < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
|
6
|
+
many_to_one :deployment
|
7
|
+
|
8
|
+
STATES = %w(open closed resolved)
|
9
|
+
|
10
|
+
def validate
|
11
|
+
validates_presence :deployment_id
|
12
|
+
validates_presence :resource_id
|
13
|
+
validates_presence :type
|
14
|
+
validates_presence :data_json
|
15
|
+
validates_presence :state
|
16
|
+
validates_includes STATES, :state
|
17
|
+
end
|
18
|
+
|
19
|
+
def before_create
|
20
|
+
self.created_at ||= Time.now
|
21
|
+
self.last_seen_at ||= Time.now
|
22
|
+
end
|
23
|
+
|
24
|
+
def data
|
25
|
+
Yajl::Parser.parse(data_json)
|
26
|
+
end
|
27
|
+
|
28
|
+
def data=(raw_data)
|
29
|
+
self.data_json = Yajl::Encoder.encode(raw_data)
|
30
|
+
end
|
31
|
+
|
32
|
+
def handler
|
33
|
+
@handler ||= Bosh::Director::ProblemHandlers::Base.create_from_model(self)
|
34
|
+
end
|
35
|
+
|
36
|
+
def resolutions
|
37
|
+
handler.resolutions
|
38
|
+
end
|
39
|
+
|
40
|
+
def description
|
41
|
+
handler.description
|
42
|
+
end
|
43
|
+
|
44
|
+
def open?
|
45
|
+
state == "open"
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class DeploymentProperty < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
|
6
|
+
VALID_PROPERTY_NAME = /^[-a-z0-9_.]+$/i
|
7
|
+
|
8
|
+
many_to_one :deployment
|
9
|
+
|
10
|
+
def validate
|
11
|
+
validates_presence :deployment_id
|
12
|
+
validates_presence :name
|
13
|
+
validates_presence :value
|
14
|
+
|
15
|
+
validates_unique [:name, :deployment_id]
|
16
|
+
|
17
|
+
validates_format VALID_PROPERTY_NAME, :name, :allow_blank => true
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class Instance < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
many_to_one :deployment
|
6
|
+
many_to_one :vm
|
7
|
+
one_to_many :persistent_disks
|
8
|
+
|
9
|
+
def validate
|
10
|
+
validates_presence [:deployment_id, :job, :index, :state]
|
11
|
+
validates_unique [:deployment_id, :job, :index]
|
12
|
+
validates_unique [:vm_id] if vm_id
|
13
|
+
validates_integer :index
|
14
|
+
validates_includes ["started", "stopped", "detached"], :state
|
15
|
+
end
|
16
|
+
|
17
|
+
def persistent_disk
|
18
|
+
# Currently we support only 1 persistent disk.
|
19
|
+
self.persistent_disks.find { |disk| disk.active }
|
20
|
+
end
|
21
|
+
|
22
|
+
def persistent_disk_cid
|
23
|
+
disk = persistent_disk
|
24
|
+
return disk.disk_cid if disk
|
25
|
+
nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class Package < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
many_to_one :release
|
6
|
+
many_to_many :release_versions
|
7
|
+
one_to_many :compiled_packages
|
8
|
+
|
9
|
+
# @return [Set<String>] A set of package names this package depends on
|
10
|
+
def dependency_set
|
11
|
+
json = self.dependency_set_json
|
12
|
+
|
13
|
+
::Set.new(json ? Yajl::Parser.parse(json) : nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
def dependency_set=(deps)
|
17
|
+
self.dependency_set_json = Yajl::Encoder.encode(deps.to_a)
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate
|
21
|
+
validates_presence [:release_id, :name, :version, :blobstore_id, :sha1]
|
22
|
+
validates_unique [:release_id, :name, :version]
|
23
|
+
validates_format VALID_ID, [:name, :version]
|
24
|
+
end
|
25
|
+
|
26
|
+
def desc
|
27
|
+
"#{name}/#{version}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class PersistentDisk < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
many_to_one :instance
|
6
|
+
one_to_many :snapshots
|
7
|
+
|
8
|
+
def validate
|
9
|
+
validates_presence [:instance_id, :disk_cid]
|
10
|
+
validates_unique [:disk_cid]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class Release < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
one_to_many :versions, :class => "Bosh::Director::Models::ReleaseVersion"
|
6
|
+
one_to_many :packages
|
7
|
+
one_to_many :templates
|
8
|
+
|
9
|
+
many_to_many :deployments
|
10
|
+
|
11
|
+
def validate
|
12
|
+
validates_presence :name
|
13
|
+
validates_unique :name
|
14
|
+
validates_format VALID_ID, :name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class ReleaseVersion < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
many_to_one :release
|
6
|
+
many_to_many :packages
|
7
|
+
many_to_many :templates
|
8
|
+
many_to_many :deployments
|
9
|
+
|
10
|
+
def validate
|
11
|
+
validates_presence [:release_id, :version]
|
12
|
+
validates_unique [:release_id, :version]
|
13
|
+
validates_format VALID_ID, :version
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class Stemcell < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
many_to_many :deployments
|
6
|
+
one_to_many :compiled_packages
|
7
|
+
|
8
|
+
def validate
|
9
|
+
validates_presence [:name, :version, :cid]
|
10
|
+
validates_unique [:name, :version]
|
11
|
+
validates_format VALID_ID, [:name, :version]
|
12
|
+
end
|
13
|
+
|
14
|
+
def desc
|
15
|
+
"#{name}/#{version}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class Template < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
many_to_one :release
|
6
|
+
many_to_many :release_versions
|
7
|
+
|
8
|
+
def package_names
|
9
|
+
result = self.package_names_json
|
10
|
+
result ? Yajl::Parser.parse(result) : nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def package_names=(packages)
|
14
|
+
self.package_names_json = Yajl::Encoder.encode(packages)
|
15
|
+
end
|
16
|
+
|
17
|
+
def logs=(logs_spec)
|
18
|
+
self.logs_json = Yajl::Encoder.encode(logs_spec)
|
19
|
+
end
|
20
|
+
|
21
|
+
def logs
|
22
|
+
result = self.logs_json
|
23
|
+
result ? Yajl::Parser.parse(result) : nil
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param [Object] property_spec Property spec from job spec
|
27
|
+
def properties=(property_spec)
|
28
|
+
self.properties_json = Yajl::Encoder.encode(property_spec)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [Hash] Template properties (as provided in job spec)
|
32
|
+
# @return [nil] if no properties have been defined in job spec
|
33
|
+
def properties
|
34
|
+
result = self.properties_json
|
35
|
+
result ? Yajl::Parser.parse(result) : nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def validate
|
39
|
+
validates_presence [:release_id, :name, :version, :blobstore_id, :sha1]
|
40
|
+
validates_unique [:release_id, :name, :version]
|
41
|
+
validates_format VALID_ID, [:name, :version]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
module Bosh::Director::Models
|
4
|
+
class Vm < Sequel::Model(Bosh::Director::Config.db)
|
5
|
+
many_to_one :deployment
|
6
|
+
one_to_one :instance
|
7
|
+
|
8
|
+
def validate
|
9
|
+
validates_presence [:deployment_id, :agent_id]
|
10
|
+
validates_unique :agent_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def apply_spec
|
14
|
+
return nil if apply_spec_json.nil?
|
15
|
+
Yajl::Parser.parse(apply_spec_json)
|
16
|
+
end
|
17
|
+
|
18
|
+
def apply_spec=(spec)
|
19
|
+
self.apply_spec_json = Yajl::Encoder.encode(spec)
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param [Hash] env_hash Environment hash
|
23
|
+
def env=(env_hash)
|
24
|
+
self.env_json = Yajl::Encoder.encode(env_hash)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [Hash] VM environment hash
|
28
|
+
def env
|
29
|
+
return nil if env_json.nil?
|
30
|
+
Yajl::Parser.parse(env_json)
|
31
|
+
end
|
32
|
+
|
33
|
+
def credentials
|
34
|
+
return nil if credentials_json.nil?
|
35
|
+
Yajl::Parser.parse(credentials_json)
|
36
|
+
end
|
37
|
+
|
38
|
+
def credentials=(spec)
|
39
|
+
self.credentials_json = Yajl::Encoder.encode(spec)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|