bosh-director 1.5.0.pre.1633 → 1.5.0.pre.1639

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,14 @@
1
1
  module Bosh::Director
2
2
  module Api
3
3
  class BackupManager
4
- attr_accessor :destination_path
4
+ attr_reader :destination_path
5
5
 
6
6
  def initialize
7
7
  @destination_path = '/var/vcap/store/director/backup.tgz'
8
8
  end
9
9
 
10
- def create_backup(user)
11
- JobQueue.new.enqueue(user, Jobs::Backup, 'bosh backup', [destination_path])
10
+ def create_backup(username)
11
+ JobQueue.new.enqueue(username, Jobs::Backup, 'bosh backup', [destination_path])
12
12
  end
13
13
  end
14
14
  end
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Director
4
2
  module Api
5
3
  class DeploymentManager
@@ -18,7 +16,7 @@ module Bosh::Director
18
16
  deployment_manifest_dir = Dir::tmpdir
19
17
  deployment_manifest_file = File.join(deployment_manifest_dir, random_name)
20
18
  unless check_available_disk_space(deployment_manifest_dir, deployment_manifest.size)
21
- raise NotEnoughDiskSpace, "Uploading deployment manifest failed. " +
19
+ raise NotEnoughDiskSpace, 'Uploading deployment manifest failed. ' +
22
20
  "Insufficient space on BOSH director in #{deployment_manifest_dir}"
23
21
  end
24
22
 
@@ -33,7 +31,7 @@ module Bosh::Director
33
31
 
34
32
  def deployment_to_json(deployment)
35
33
  result = {
36
- "manifest" => deployment.manifest,
34
+ 'manifest' => deployment.manifest,
37
35
  }
38
36
 
39
37
  Yajl::Encoder.encode(result)
@@ -46,10 +44,10 @@ module Bosh::Director
46
44
  instance = vm.instance
47
45
 
48
46
  vms << {
49
- "agent_id" => vm.agent_id,
50
- "cid" => vm.cid,
51
- "job" => instance ? instance.job : nil,
52
- "index" => instance ? instance.index : nil
47
+ 'agent_id' => vm.agent_id,
48
+ 'cid' => vm.cid,
49
+ 'job' => instance ? instance.job : nil,
50
+ 'index' => instance ? instance.index : nil
53
51
  }
54
52
  end
55
53
 
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Director
4
2
  module Api
5
3
  class InstanceManager
@@ -44,7 +42,7 @@ module Bosh::Director
44
42
  def fetch_logs(user, deployment_name, job, index, options = {})
45
43
  if deployment_name.nil? || job.nil? || index.nil?
46
44
  raise DirectorError,
47
- "deployment, job and index parameters are required"
45
+ 'deployment, job and index parameters are required'
48
46
  end
49
47
 
50
48
  instance = find_by_name(deployment_name, job, index)
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Director
4
2
  module Api
5
3
  class ProblemManager
@@ -1,11 +1,9 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Director
4
2
  module Api
5
3
  class ReleaseManager
6
4
  include ApiHelper
7
5
 
8
- RELEASE_TGZ = "release.tgz"
6
+ RELEASE_TGZ = 'release.tgz'
9
7
 
10
8
  # Finds release by name
11
9
  # @param [String] name Release name
@@ -35,16 +33,16 @@ module Bosh::Director
35
33
  end
36
34
 
37
35
  def create_release(user, release_bundle, options = {})
38
- release_dir = Dir.mktmpdir("release")
36
+ release_dir = Dir.mktmpdir('release')
39
37
 
40
38
  if options['remote']
41
39
  options['location'] = release_bundle
42
40
  else
43
41
  unless check_available_disk_space(release_dir, release_bundle.size)
44
- raise NotEnoughDiskSpace, "Uploading release archive failed. " +
42
+ raise NotEnoughDiskSpace, 'Uploading release archive failed. ' +
45
43
  "Insufficient space on BOSH director in #{release_dir}"
46
44
  end
47
-
45
+
48
46
  write_file(File.join(release_dir, RELEASE_TGZ), release_bundle)
49
47
  end
50
48
 
@@ -56,4 +54,4 @@ module Bosh::Director
56
54
  end
57
55
  end
58
56
  end
59
- end
57
+ end
@@ -1,10 +1,11 @@
1
1
  # Copyright (c) 2009-2012 VMware, Inc.
2
+ require 'bosh/director/api/task_remover'
2
3
 
3
4
  module Bosh::Director
4
5
  module Api
5
- module TaskHelper
6
- def create_task(user, type, description)
7
- user = Models::User[:username => user]
6
+ class TaskHelper
7
+ def create_task(username, type, description)
8
+ user = Models::User[:username => username]
8
9
  task = Models::Task.create(:user => user,
9
10
  :type => type,
10
11
  :description => description,
@@ -15,27 +16,12 @@ module Bosh::Director
15
16
  task_status_file = File.join(log_dir, "debug")
16
17
  FileUtils.mkdir_p(log_dir)
17
18
  logger = Logger.new(task_status_file)
18
- logger.level= Config.logger.level
19
+ logger.level = Config.logger.level
19
20
  logger.info("Director Version : #{Bosh::Director::VERSION}")
20
21
  logger.info("Enqueuing task: #{task.id}")
21
22
 
22
23
  # remove old tasks
23
- min_task_id = task.id - Config.max_tasks
24
- task_files = Dir.glob(File.join(Config.base_dir, "tasks/*"))
25
- task_files.each do |file_path|
26
- begin
27
- task_file = File.basename(file_path)
28
- task_id = Integer(task_file)
29
-
30
- if task_id <= min_task_id && task_id >= 0
31
- logger.info("Delete #{task_file}")
32
- FileUtils.rm_rf file_path
33
- Models::Task[task_id].destroy
34
- end
35
- rescue
36
- # skip over invalid task files
37
- end
38
- end
24
+ TaskRemover.new(Config.max_tasks, logger).remove
39
25
 
40
26
  task.output = log_dir
41
27
  task.save
@@ -0,0 +1,21 @@
1
+ module Bosh::Director::Api
2
+ class TaskRemover
3
+ def initialize(max_tasks, logger)
4
+ @max_tasks = max_tasks
5
+ #@logger = logger
6
+ end
7
+
8
+ def remove
9
+ removal_candidates_dataset.each do |task|
10
+ FileUtils.rm_rf(task.output)
11
+ task.destroy
12
+ end
13
+ end
14
+
15
+ private
16
+ def removal_candidates_dataset
17
+ Bosh::Director::Models::Task.filter("state NOT IN ('processing', 'queued')").
18
+ order{id.desc}.limit(2, @max_tasks)
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Director
4
2
  module Api
5
3
  class VmStateManager
@@ -1,12 +1,12 @@
1
+ require 'bosh/director/api/task_helper'
2
+
1
3
  module Bosh::Director
2
4
 
3
5
  # Abstracts the resque system.
4
6
 
5
7
  class JobQueue
6
- include Api::TaskHelper
7
-
8
8
  def enqueue(user, job_class, description, params)
9
- task = create_task(user, job_class.job_type, description)
9
+ task = Api::TaskHelper.new.create_task(user, job_class.job_type, description)
10
10
 
11
11
  Resque.enqueue(job_class, task.id, *params)
12
12
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bosh
4
4
  module Director
5
- VERSION = '1.5.0.pre.1633'
5
+ VERSION = '1.5.0.pre.1639'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-director
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0.pre.1633
4
+ version: 1.5.0.pre.1639
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-23 00:00:00.000000000 Z
12
+ date: 2013-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bcrypt-ruby
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 1.5.0.pre.1633
37
+ version: 1.5.0.pre.1639
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 1.5.0.pre.1633
45
+ version: 1.5.0.pre.1639
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: bosh-core
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
- version: 1.5.0.pre.1633
53
+ version: 1.5.0.pre.1639
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.5.0.pre.1633
61
+ version: 1.5.0.pre.1639
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: bosh_common
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +66,7 @@ dependencies:
66
66
  requirements:
67
67
  - - ~>
68
68
  - !ruby/object:Gem::Version
69
- version: 1.5.0.pre.1633
69
+ version: 1.5.0.pre.1639
70
70
  type: :runtime
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- version: 1.5.0.pre.1633
77
+ version: 1.5.0.pre.1639
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: bosh_cpi
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +82,7 @@ dependencies:
82
82
  requirements:
83
83
  - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 1.5.0.pre.1633
85
+ version: 1.5.0.pre.1639
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +90,7 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 1.5.0.pre.1633
93
+ version: 1.5.0.pre.1639
94
94
  - !ruby/object:Gem::Dependency
95
95
  name: bosh_openstack_cpi
96
96
  requirement: !ruby/object:Gem::Requirement
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 1.5.0.pre.1633
101
+ version: 1.5.0.pre.1639
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 1.5.0.pre.1633
109
+ version: 1.5.0.pre.1639
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: bosh_aws_cpi
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.5.0.pre.1633
117
+ version: 1.5.0.pre.1639
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.5.0.pre.1633
125
+ version: 1.5.0.pre.1639
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: bosh_vsphere_cpi
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 1.5.0.pre.1633
133
+ version: 1.5.0.pre.1639
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: 1.5.0.pre.1633
141
+ version: 1.5.0.pre.1639
142
142
  - !ruby/object:Gem::Dependency
143
143
  name: eventmachine
144
144
  requirement: !ruby/object:Gem::Requirement
@@ -461,7 +461,7 @@ dependencies:
461
461
  version: '0'
462
462
  description: ! 'BOSH Director
463
463
 
464
- 72d86c'
464
+ 831cf9'
465
465
  email: support@cloudfoundry.com
466
466
  executables:
467
467
  - bosh-director
@@ -536,6 +536,7 @@ files:
536
536
  - lib/bosh/director/api/stemcell_manager.rb
537
537
  - lib/bosh/director/api/task_helper.rb
538
538
  - lib/bosh/director/api/task_manager.rb
539
+ - lib/bosh/director/api/task_remover.rb
539
540
  - lib/bosh/director/api/user_manager.rb
540
541
  - lib/bosh/director/api/vm_state_manager.rb
541
542
  - lib/bosh/director/app.rb