manifests-vmc-plugin 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,36 +16,36 @@ VMC.Plugin(VMC::App) do
16
16
  # app(s) described by the manifest, in dependency-order
17
17
  [:start, :instances, :logs].each do |wrap|
18
18
  around(wrap) do |cmd, args|
19
- if args.empty?
19
+ if args.empty? && !passed_value(:name)
20
20
  each_app do |a|
21
- cmd.call(a["name"])
21
+ cmd.call(:name => a["name"])
22
22
  puts "" unless simple_output?
23
23
  end || err("No applications to act on.")
24
24
  else
25
- cmd.call(args)
25
+ cmd.call
26
26
  end
27
27
  end
28
28
  end
29
29
 
30
30
  # same as above but in reverse dependency-order
31
31
  around(:stop) do |cmd, args|
32
- if args.empty?
32
+ if args.empty? && !passed_value(:name)
33
33
  reversed = []
34
34
  each_app do |a|
35
35
  reversed.unshift a["name"]
36
36
  end || err("No applications to act on.")
37
37
 
38
38
  reversed.each do |name|
39
- cmd.call(name)
39
+ cmd.call(:name => name)
40
40
  puts "" unless simple_output?
41
41
  end
42
42
  else
43
- cmd.call(args)
43
+ cmd.call
44
44
  end
45
45
  end
46
46
 
47
47
  around(:delete) do |cmd, args|
48
- if args.empty? && !options[:all]
48
+ if args.empty? && !options[:all] && !passed_value(:name)
49
49
  reversed = []
50
50
  has_manifest =
51
51
  each_app do |a|
@@ -53,22 +53,22 @@ VMC.Plugin(VMC::App) do
53
53
  end
54
54
 
55
55
  unless has_manifest
56
- return cmd.call(args)
56
+ return cmd.call
57
57
  end
58
58
 
59
59
  reversed.each do |name|
60
- cmd.call(name)
60
+ cmd.call(:name => name)
61
61
  puts "" unless simple_output?
62
62
  end
63
63
  else
64
- cmd.call(args)
64
+ cmd.call
65
65
  end
66
66
  end
67
67
 
68
68
  # stop apps in reverse dependency order,
69
69
  # and then start in dependency order
70
70
  around(:restart) do |cmd, args|
71
- if args.empty?
71
+ if args.empty? && !passed_value(:name)
72
72
  reversed = []
73
73
  forwards = []
74
74
  each_app do |a|
@@ -77,55 +77,53 @@ VMC.Plugin(VMC::App) do
77
77
  end || err("No applications to act on.")
78
78
 
79
79
  reversed.each do |name|
80
- stop(name)
80
+ with_inputs(:name => name) do
81
+ stop
82
+ end
81
83
  end
82
84
 
83
85
  puts "" unless simple_output?
84
86
 
85
87
  forwards.each do |name|
86
- start(name)
88
+ with_inputs(:name => name) do
89
+ start
90
+ end
87
91
  end
88
92
  else
89
- cmd.call(args)
93
+ cmd.call
90
94
  end
91
95
  end
92
96
 
93
97
  # push and sync meta changes in the manifest
94
98
  # also sets env data on creation if present in manifest
95
99
  around(:push) do |push, args|
96
- if args.empty?
97
- all_pushed =
98
- each_app do |a|
99
- app = client.app(a["name"])
100
- updating = app.exists?
100
+ name = passed_value(:name) || args.first
101
101
 
102
- start = input(:start)
102
+ all_pushed =
103
+ each_app do |a|
104
+ next if name && a["name"] != name
103
105
 
104
- begin
105
- inputs[:start] = false
106
+ app = client.app(a["name"])
107
+ updating = app.exists?
106
108
 
107
- sync_changes(a)
108
- push.call(a["name"])
109
+ sync_changes(a)
110
+ push.call(:name => a["name"], :start => false)
109
111
 
110
- unless updating
111
- app.env = a["env"]
112
+ unless updating
113
+ app.env = a["env"]
112
114
 
113
- if start
114
- start(a["name"])
115
- else
116
- app.update!
117
- end
115
+ if input(:start)
116
+ with_inputs(:name => a["name"]) do
117
+ start
118
118
  end
119
- ensure
120
- inputs[:start] = start
119
+ else
120
+ app.update!
121
121
  end
122
-
123
- puts "" unless simple_output?
124
122
  end
125
123
 
126
- push.call unless all_pushed
127
- else
128
- push.call(args)
129
- end
124
+ puts "" unless simple_output?
125
+ end
126
+
127
+ push.call unless all_pushed
130
128
  end
131
129
  end
@@ -1,3 +1,3 @@
1
1
  module VMCManifests
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -251,41 +251,18 @@ module VMCManifests
251
251
 
252
252
  private
253
253
 
254
- def inputs
255
- @inputs ||= {}
256
- end
257
-
258
254
  # call the block as if the app info and path were given as flags
259
- def with_app(path, info)
260
- before_path = inputs[:path]
261
- before_info = {}
262
-
263
- inputs[:path] = path
264
-
255
+ def with_app(path, info, &blk)
256
+ inputs = {:path => path}
265
257
  info.each do |k, v|
266
258
  if k == "mem"
267
259
  k = "memory"
268
260
  end
269
261
 
270
- before_info[k.to_sym] = inputs[k.to_sym]
271
262
  inputs[k.to_sym] = v
272
263
  end
273
264
 
274
- yield
275
- ensure
276
- if before_path.nil?
277
- inputs.delete :path
278
- else
279
- inputs[:path] = before_path
280
- end
281
-
282
- before_info.each do |k, v|
283
- if v.nil?
284
- inputs.delete k
285
- else
286
- inputs[k] = v
287
- end
288
- end
265
+ with_inputs(inputs, &blk)
289
266
  end
290
267
 
291
268
  # sort applications in dependency order
metadata CHANGED
@@ -1,23 +1,33 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: manifests-vmc-plugin
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ hash: 31
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 2
10
+ version: 0.1.2
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Alex Suraci
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-05-24 00:00:00.000000000 Z
17
+
18
+ date: 2012-05-30 00:00:00 Z
13
19
  dependencies: []
20
+
14
21
  description:
15
- email:
22
+ email:
16
23
  - asuraci@vmware.com
17
24
  executables: []
25
+
18
26
  extensions: []
27
+
19
28
  extra_rdoc_files: []
20
- files:
29
+
30
+ files:
21
31
  - Rakefile
22
32
  - lib/manifests-vmc-plugin/errors.rb
23
33
  - lib/manifests-vmc-plugin/manifest.rb
@@ -26,26 +36,36 @@ files:
26
36
  - lib/manifests-vmc-plugin.rb
27
37
  homepage: http://cloudfoundry.com/
28
38
  licenses: []
39
+
29
40
  post_install_message:
30
41
  rdoc_options: []
31
- require_paths:
42
+
43
+ require_paths:
32
44
  - lib
33
- required_ruby_version: !ruby/object:Gem::Requirement
45
+ required_ruby_version: !ruby/object:Gem::Requirement
34
46
  none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
38
- version: '0'
39
- required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ hash: 3
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
55
  none: false
41
- requirements:
42
- - - ! '>='
43
- - !ruby/object:Gem::Version
44
- version: '0'
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
45
63
  requirements: []
64
+
46
65
  rubyforge_project: manifests-vmc-plugin
47
- rubygems_version: 1.8.21
66
+ rubygems_version: 1.8.23
48
67
  signing_key:
49
68
  specification_version: 3
50
69
  summary: Cloud Foundry automation via manifest documents.
51
70
  test_files: []
71
+