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
data/CHANGELOG
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
== 0.7 - 12/07/12
|
2
|
+
* Gem bumps:
|
3
|
+
* Upgrade openstack_cpi gem to v0.0.4 and blobstore_client to v0.5.0 in director
|
4
|
+
* Bump vSphere CPI versions in deployer and director.
|
5
|
+
* Bump director vsphere_cpi
|
6
|
+
* Bump vcloud_cpi version
|
7
|
+
* Bump aws_cpi to 0.6.3
|
8
|
+
* Rename soap log to cpi log
|
9
|
+
* `bosh releases` shows which releases are in use
|
10
|
+
* Improved DNS support
|
11
|
+
* add director feature list to /info
|
12
|
+
* Save properties from job spec on release upload
|
13
|
+
* Filter job properties
|
14
|
+
* Use common property helpers everywhere
|
15
|
+
* Release Rebase improvements
|
16
|
+
* Don't update task state when checkpointing
|
17
|
+
* Persist VM env for cloudcheck
|
18
|
+
* Trigger update when resource pool env changes
|
19
|
+
* Fix InstanceDeleter unit test for 1.9.3.
|
20
|
+
* Removed Lock.try_lock
|
21
|
+
* CPI log exposed to all providers.
|
22
|
+
* Reduce bosh vms timeout from 30 seconds to 5.
|
23
|
+
* Add LockHelper.
|
24
|
+
* Make release lock more granular in UpdateDeployment job.
|
25
|
+
* Use new set_vm_metadata call.
|
26
|
+
* Fix metadata_helper to use the deployment name.
|
27
|
+
* Use migrations from the CPI gems.
|
28
|
+
* Injecting vcloud_cpi dependencies into director
|
29
|
+
|
30
|
+
== 0.6 - 08/29/12
|
31
|
+
* release rebase support
|
32
|
+
* fingerprint matching
|
33
|
+
* updated VSphere CPI to 0.4.10 (vCPU fix)
|
34
|
+
* removed compiled package sharing
|
data/bin/bosh-director
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bosh/director'
|
4
|
+
require 'thin'
|
5
|
+
|
6
|
+
config_file = nil
|
7
|
+
|
8
|
+
opts = OptionParser.new do |opts|
|
9
|
+
opts.on('-c', '--config [ARG]', 'Configuration File') do |opt|
|
10
|
+
config_file = opt
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
opts.parse!(ARGV.dup)
|
15
|
+
|
16
|
+
config_file ||= ::File.expand_path('../../config/bosh-director.yml', __FILE__)
|
17
|
+
config = Bosh::Director::Config.load_file(config_file)
|
18
|
+
|
19
|
+
Bosh::Director::App.new(config)
|
20
|
+
|
21
|
+
thin_server = Thin::Server.new('127.0.0.1', config.hash['port'], :signals => false) do
|
22
|
+
use Rack::CommonLogger
|
23
|
+
map "/" do
|
24
|
+
run Bosh::Director::Api::Controller.new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
%w(TERM INT QUIT).each do |signal|
|
29
|
+
trap(signal) do
|
30
|
+
Bosh::Director::Config.logger.info('Shutting down Director')
|
31
|
+
thin_server.stop!
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Bosh::Director::Config.logger.info("Listening on port #{config.hash['port']}")
|
36
|
+
thin_server.start!
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
APP_DIR = File.expand_path(File.join("..", ".."), __FILE__)
|
4
|
+
|
5
|
+
DEFAULT_DIRECTOR_CONFIG = File.join(APP_DIR, "config", "bosh-director.yml")
|
6
|
+
|
7
|
+
require 'bosh/director'
|
8
|
+
require 'irb'
|
9
|
+
require 'irb/completion'
|
10
|
+
require 'rack/test'
|
11
|
+
|
12
|
+
module Bosh
|
13
|
+
module Director
|
14
|
+
|
15
|
+
class TestApplication
|
16
|
+
include Rack::Test::Methods
|
17
|
+
|
18
|
+
def app
|
19
|
+
Bosh::Director::Api::Controller.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Console
|
24
|
+
def self.start(context)
|
25
|
+
new.start(context)
|
26
|
+
end
|
27
|
+
|
28
|
+
def start(context)
|
29
|
+
options = {}
|
30
|
+
|
31
|
+
OptionParser.new do |opt|
|
32
|
+
opt.banner = "Usage: director_console [options]"
|
33
|
+
opt.on('-c', '--config [ARG]', 'configuration file') { |v| options[:config] = v }
|
34
|
+
opt.parse!(ARGV)
|
35
|
+
end
|
36
|
+
|
37
|
+
if options[:config]
|
38
|
+
config_file = File.expand_path(options[:config])
|
39
|
+
else
|
40
|
+
config_file = DEFAULT_DIRECTOR_CONFIG
|
41
|
+
end
|
42
|
+
|
43
|
+
puts "=> Loading #{config_file}"
|
44
|
+
Bosh::Director::App.new(Bosh::Director::Config.load_file(config_file))
|
45
|
+
|
46
|
+
context.instance_eval do
|
47
|
+
include BD::Models
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
require 'ruby-debug'
|
52
|
+
puts "=> Debugger enabled"
|
53
|
+
rescue LoadError
|
54
|
+
puts "=> ruby-debug not found, debugger disabled"
|
55
|
+
end
|
56
|
+
|
57
|
+
puts "=> Welcome to BOSH Director console\n=> You can use 'app' to access REST API"
|
58
|
+
puts "=> You can also use 'cloud', 'blobstore', 'nats' helpers to query these services"
|
59
|
+
|
60
|
+
IRB.start
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
BD = Bosh::Director
|
68
|
+
|
69
|
+
def app
|
70
|
+
BD::TestApplication.new
|
71
|
+
end
|
72
|
+
|
73
|
+
def config
|
74
|
+
BD::Config
|
75
|
+
end
|
76
|
+
|
77
|
+
[:redis, :blobstore, :nats, :cloud].each do |helper|
|
78
|
+
self.class.send(:define_method, helper) do
|
79
|
+
config.send(helper)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
BD::Console.start(self)
|
84
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bosh/director"
|
4
|
+
|
5
|
+
config_file = nil
|
6
|
+
report = false
|
7
|
+
active_worker = 1
|
8
|
+
|
9
|
+
opts = OptionParser.new do |opts|
|
10
|
+
opts.on("-c", "--config [ARG]", "Configuration File") do |opt|
|
11
|
+
config_file = opt
|
12
|
+
end
|
13
|
+
opts.on("-r", "--report", "Report 1 if any active worker, 0 otherwise") do |opt|
|
14
|
+
report = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.parse!(ARGV.dup)
|
19
|
+
|
20
|
+
config_file ||= ::File.expand_path("../../config/bosh-director.yml", __FILE__)
|
21
|
+
config = Bosh::Director::Config.load_file(config_file)
|
22
|
+
|
23
|
+
Bosh::Director::App.new(config)
|
24
|
+
|
25
|
+
logger = Bosh::Director::Config.logger
|
26
|
+
|
27
|
+
loop do
|
28
|
+
logger.info("Checking for any workers that are still processing..")
|
29
|
+
worker = Resque::Worker.all.find { |worker| worker.working? }
|
30
|
+
if worker.nil?
|
31
|
+
active_worker = 0
|
32
|
+
logger.info("All workers are idle")
|
33
|
+
break
|
34
|
+
end
|
35
|
+
if report
|
36
|
+
break
|
37
|
+
end
|
38
|
+
logger.info("Found worker: #{worker}, sleeping for 60 seconds.")
|
39
|
+
sleep 60
|
40
|
+
end
|
41
|
+
|
42
|
+
puts "#{active_worker}" if report
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "logger"
|
4
|
+
require "sequel"
|
5
|
+
require "bosh/director"
|
6
|
+
require "optparse"
|
7
|
+
|
8
|
+
config_file = nil
|
9
|
+
|
10
|
+
opts = OptionParser.new do |opts|
|
11
|
+
opts.on("-c", "--config FILE", "configuration file") do |opt|
|
12
|
+
config_file = opt
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
opts.parse!(ARGV.dup)
|
17
|
+
|
18
|
+
if config_file.nil?
|
19
|
+
puts opts
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
|
23
|
+
config = Psych.load_file(config_file)
|
24
|
+
unless config["db"] && config["db"]["database"]
|
25
|
+
abort ("Director database config missing from config file")
|
26
|
+
end
|
27
|
+
|
28
|
+
db = Bosh::Director::Config.configure_db(config["db"])
|
29
|
+
|
30
|
+
def migrate(database, schema_table, dir, target = nil)
|
31
|
+
options = {}
|
32
|
+
options[:table] = schema_table if schema_table
|
33
|
+
options[:target] = target.to_i if target
|
34
|
+
|
35
|
+
Sequel.extension :migration
|
36
|
+
Sequel::TimestampMigrator.new(database, dir, options).run
|
37
|
+
end
|
38
|
+
|
39
|
+
migrations_dir = File.expand_path("../../db/migrations/director", __FILE__)
|
40
|
+
|
41
|
+
migrate(db, nil, migrations_dir)
|
42
|
+
|
43
|
+
if config["dns"] && config["dns"]["db"]
|
44
|
+
dns_migrations_dir = File.expand_path("../../db/migrations/dns", __FILE__)
|
45
|
+
dns_db = Bosh::Director::Config.configure_db(config["dns"]["db"])
|
46
|
+
migrate(dns_db, "dns_schema",
|
47
|
+
dns_migrations_dir)
|
48
|
+
end
|
49
|
+
|
50
|
+
cpi = config["cloud"]["plugin"]
|
51
|
+
require_path = File.join("cloud", cpi)
|
52
|
+
cpi_path = $LOAD_PATH.find { |p| File.exist?(File.join(p, require_path)) }
|
53
|
+
migrations = File.expand_path("../db/migrations", cpi_path)
|
54
|
+
|
55
|
+
if File.directory?(migrations)
|
56
|
+
migrate(db, "#{cpi}_cpi_schema", migrations)
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bosh/director'
|
4
|
+
require 'bosh/director/scheduler'
|
5
|
+
|
6
|
+
config_file = ::File.expand_path('../../config/bosh-director.yml', __FILE__)
|
7
|
+
|
8
|
+
opts = OptionParser.new do |opts|
|
9
|
+
opts.on('-c', '--config [ARG]', 'Configuration File') do |opt|
|
10
|
+
config_file = opt
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
opts.parse!(ARGV.dup)
|
15
|
+
|
16
|
+
config = Bosh::Director::Config.load_file(config_file)
|
17
|
+
Bosh::Director::App.new(config)
|
18
|
+
|
19
|
+
scheduler = Bosh::Director::Scheduler.new(config.hash.fetch('scheduled_jobs', []))
|
20
|
+
|
21
|
+
%w(TERM INT QUIT).each do |signal|
|
22
|
+
trap(signal) do
|
23
|
+
scheduler.stop!
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
scheduler.start!
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "erb"
|
4
|
+
require "bosh/director"
|
5
|
+
|
6
|
+
config_file = nil
|
7
|
+
index = nil
|
8
|
+
erb = false
|
9
|
+
|
10
|
+
opts = OptionParser.new do |opts|
|
11
|
+
opts.on("-c", "--config [ARG]", "Configuration File") do |opt|
|
12
|
+
config_file = opt
|
13
|
+
end
|
14
|
+
|
15
|
+
opts.on("-i", "--index [ARG]", Integer, "Worker Index") do |opt|
|
16
|
+
index = opt
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("-e", "--[no-]erb", "Treat Configuration as ERB Template") do |opt|
|
20
|
+
erb = opt
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.parse!(ARGV.dup)
|
25
|
+
|
26
|
+
config_file ||= ::File.expand_path("../../config/bosh-director.yml", __FILE__)
|
27
|
+
config = nil
|
28
|
+
|
29
|
+
# Is this code even used anymore?
|
30
|
+
if erb
|
31
|
+
class ConfigBindingHelper
|
32
|
+
attr_reader :index
|
33
|
+
|
34
|
+
def initialize(index)
|
35
|
+
@index = index
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_binding
|
39
|
+
binding
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
template = ERB.new(File.read(config_file), 0, "%<>-")
|
44
|
+
contents = template.result(ConfigBindingHelper.new(index).get_binding)
|
45
|
+
config_hash = Psych.load(contents)
|
46
|
+
config = Bosh::Director::Config.load_hash(config_hash)
|
47
|
+
else
|
48
|
+
config = Bosh::Director::Config.load_file(config_file)
|
49
|
+
end
|
50
|
+
|
51
|
+
Bosh::Director::App.new(config)
|
52
|
+
|
53
|
+
resque_logging = config.hash.fetch('resque', {}).fetch('logging', {})
|
54
|
+
resque_log_device = Logger::LogDevice.new(resque_logging.fetch('file', STDOUT))
|
55
|
+
resque_logger_level = resque_logging.fetch('level', 'info').upcase
|
56
|
+
Resque.logger = Logger.new(resque_log_device)
|
57
|
+
Resque.logger.level = Logger.const_get(resque_logger_level)
|
58
|
+
|
59
|
+
worker = nil
|
60
|
+
queues = (ENV['QUEUES'] || ENV['QUEUE']).to_s.split(',')
|
61
|
+
|
62
|
+
begin
|
63
|
+
worker = Resque::Worker.new(*queues)
|
64
|
+
worker.term_child = true
|
65
|
+
rescue Resque::NoQueueError
|
66
|
+
abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work"
|
67
|
+
end
|
68
|
+
|
69
|
+
Resque.after_fork do
|
70
|
+
EM.error_handler{ |e| puts "Error raised during event loop: #{e.message}" }
|
71
|
+
Thread.new { EM.run }
|
72
|
+
end
|
73
|
+
|
74
|
+
worker.log "Starting worker #{worker}"
|
75
|
+
|
76
|
+
worker.work(ENV['INTERVAL'] || 5) # interval, will block
|
@@ -0,0 +1 @@
|
|
1
|
+
Generate migrations using rake new_migration[<type>,<name>]
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
+
|
3
|
+
Sequel.migration do
|
4
|
+
change do
|
5
|
+
create_table :releases do
|
6
|
+
primary_key :id
|
7
|
+
String :name, :null => false, :unique => true
|
8
|
+
end
|
9
|
+
|
10
|
+
create_table :release_versions do
|
11
|
+
primary_key :id
|
12
|
+
String :version, :null => false
|
13
|
+
foreign_key :release_id, :releases, :null => false
|
14
|
+
end
|
15
|
+
|
16
|
+
create_table :packages do
|
17
|
+
primary_key :id
|
18
|
+
String :name, :null => false
|
19
|
+
String :version, :null => false
|
20
|
+
String :blobstore_id, :null => false
|
21
|
+
String :sha1, :null => false
|
22
|
+
String :dependency_set_json, :null => false, :text => true
|
23
|
+
foreign_key :release_id, :releases, :null => false
|
24
|
+
unique [:release_id, :name, :version]
|
25
|
+
end
|
26
|
+
|
27
|
+
create_table :templates do
|
28
|
+
primary_key :id
|
29
|
+
String :name, :null => false
|
30
|
+
String :version, :null => false
|
31
|
+
String :blobstore_id, :null => false
|
32
|
+
String :sha1, :null => false
|
33
|
+
String :package_names_json, :null => false, :text => true
|
34
|
+
foreign_key :release_id, :releases, :null => false
|
35
|
+
unique [:release_id, :name, :version]
|
36
|
+
end
|
37
|
+
|
38
|
+
create_table :stemcells do
|
39
|
+
primary_key :id
|
40
|
+
String :name, :null => false
|
41
|
+
String :version, :null => false
|
42
|
+
String :cid, :null => false
|
43
|
+
unique [:name, :version]
|
44
|
+
end
|
45
|
+
|
46
|
+
create_table :compiled_packages do
|
47
|
+
primary_key :id
|
48
|
+
String :blobstore_id, :null => false
|
49
|
+
String :sha1, :null => false
|
50
|
+
String :dependency_key, :null => false
|
51
|
+
Integer :build, :unsigned => true, :null => false
|
52
|
+
foreign_key :package_id, :packages, :null => false
|
53
|
+
foreign_key :stemcell_id, :stemcells, :null => false
|
54
|
+
unique [:package_id, :stemcell_id, :dependency_key]
|
55
|
+
unique [:package_id, :stemcell_id, :build]
|
56
|
+
end
|
57
|
+
|
58
|
+
create_table :deployments do
|
59
|
+
primary_key :id
|
60
|
+
String :name, :null => false, :unique => true
|
61
|
+
String :manifest, :null => true, :text => true
|
62
|
+
foreign_key :release_id, :releases, :null => true
|
63
|
+
end
|
64
|
+
|
65
|
+
create_table :vms do
|
66
|
+
primary_key :id
|
67
|
+
String :agent_id, :null => false, :unique => true
|
68
|
+
String :cid, :null => false
|
69
|
+
foreign_key :deployment_id, :deployments, :null => false
|
70
|
+
end
|
71
|
+
|
72
|
+
create_table :instances do
|
73
|
+
primary_key :id
|
74
|
+
String :job, :null => false
|
75
|
+
Integer :index, :unsigned => true, :null => false
|
76
|
+
String :disk_cid, :unique => true, :null => true
|
77
|
+
foreign_key :deployment_id, :deployments, :null => false
|
78
|
+
foreign_key :vm_id, :vms, :unique => true, :null => true
|
79
|
+
end
|
80
|
+
|
81
|
+
create_table :tasks do
|
82
|
+
primary_key :id
|
83
|
+
String :state, :index => true, :null => false
|
84
|
+
Time :timestamp, :index => true, :null => false
|
85
|
+
String :description, :null => false
|
86
|
+
String :result, :text => true, :null => true
|
87
|
+
String :output, :null => true
|
88
|
+
end
|
89
|
+
|
90
|
+
create_table :users do
|
91
|
+
primary_key :id
|
92
|
+
String :username, :unique => true, :null => false
|
93
|
+
String :password, :null => false
|
94
|
+
end
|
95
|
+
|
96
|
+
create_table :packages_release_versions do
|
97
|
+
primary_key :id
|
98
|
+
foreign_key :package_id, :packages, :null => false
|
99
|
+
foreign_key :release_version_id, :release_versions, :null => false
|
100
|
+
unique [:package_id, :release_version_id]
|
101
|
+
end
|
102
|
+
|
103
|
+
create_table :release_versions_templates do
|
104
|
+
primary_key :id
|
105
|
+
foreign_key :release_version_id, :release_versions, :null => false
|
106
|
+
foreign_key :template_id, :templates, :null => false
|
107
|
+
unique [:release_version_id, :template_id]
|
108
|
+
end
|
109
|
+
|
110
|
+
create_table :deployments_stemcells do
|
111
|
+
primary_key :id
|
112
|
+
foreign_key :deployment_id, :deployments, :null => false
|
113
|
+
foreign_key :stemcell_id, :stemcells, :null => false
|
114
|
+
unique [:deployment_id, :stemcell_id]
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|