bosh_cli_plugin_redis 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -22,6 +22,10 @@ Converted into a bosh plugin. Prefix "bosh" to the sub-commands below:
22
22
 
23
23
  Note: the `cf bind-redis-env-var` command has been removed as it is a) specific to a Cloud Foundry user not a bosh user; b) kinda crappy "services" integration. Perhaps move it back into a cf plugin in future.
24
24
 
25
+ Other features/fixes:
26
+
27
+ * Validates the resource size with available sizes in the template [v0.2.1]
28
+
25
29
  ## v0.1 - redis-cf-plugin
26
30
 
27
31
  Initial release! The initial commands offered are:
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "bosh_cli_plugin_redis"
5
- spec.version = "0.2.0"
5
+ spec.version = "0.2.1"
6
6
  spec.authors = ["Dr Nic Williams"]
7
7
  spec.email = ["drnicwilliams@gmail.com"]
8
8
  spec.description = %q{Create dedicated Redis servers using Bosh}
@@ -0,0 +1,13 @@
1
+ ---
2
+ resources:
3
+ - small
4
+ - medium
5
+ - large
6
+ - xlarge
7
+
8
+ properties:
9
+ - name: redis.resource
10
+ description: Resource/flavor of instance to use
11
+ - name: redis.security_group
12
+ description: Security group for instance(s). Must have TCP ports 22 & 6379 open.
13
+ default: default
@@ -66,9 +66,14 @@ module Bosh::Cli::Command
66
66
  nl
67
67
  say "CPI: #{bosh_cpi}"
68
68
  say "Deployment name: #{service_name.make_green}"
69
- say "Resource size: #{resource_size.make_green}"
69
+ say "Resource size: #{validated_resource_size_colored(resource_size)}"
70
70
  say "Security group: #{security_group.make_green}"
71
71
  nl
72
+
73
+ step("Validating resource size", "Resource size must be in #{available_resource_sizes.join(', ')}", :fatal) do
74
+ available_resource_sizes.include?(resource_size)
75
+ end
76
+
72
77
  unless confirmed?("Security group exists with ports 22 & #{redis_port}")
73
78
  cancel_deployment
74
79
  end
@@ -119,6 +124,10 @@ module Bosh::Cli::Command
119
124
  # re-set current deployment to show output
120
125
  deployment_cmd.set_current(deployment_file)
121
126
  deployment_cmd(non_interactive: options[:non_interactive]).perform
127
+ rescue Bosh::Cli::ValidationHalted
128
+ errors.each do |error|
129
+ say error.make_red
130
+ end
122
131
  end
123
132
 
124
133
  usage "show redis uri"
@@ -165,6 +174,35 @@ module Bosh::Cli::Command
165
174
  chdir(bosh_release_dir, &block)
166
175
  end
167
176
 
177
+ def template_file(file)
178
+ File.join(bosh_release_dir, "templates", bosh_cpi, file)
179
+ end
180
+
181
+ def bosh_release_spec
182
+ @bosh_release_spec ||= begin
183
+ unless File.exists?(template_file("spec"))
184
+ err "Bosh release templates missing 'spec'"
185
+ end
186
+ YAML.load_file(template_file("spec"))
187
+ end
188
+ end
189
+
190
+ def available_resource_sizes
191
+ resources = bosh_release_spec["resources"]
192
+ if resources && resources.is_a?(Array) && resources.first.is_a?(String)
193
+ resources
194
+ else
195
+ err "template spec needs 'resources' key with list of resource pool names available"
196
+ end
197
+ end
198
+
199
+ # If resource_size is within +available_resource_sizes+ then display it in green;
200
+ # else display it in red.
201
+ def validated_resource_size_colored(resource_size)
202
+ available_resource_sizes.include?(resource_size) ?
203
+ resource_size.make_green : resource_size.make_red
204
+ end
205
+
168
206
  def bosh_status
169
207
  @bosh_status ||= begin
170
208
  step("Fetching bosh information", "Cannot fetch bosh information", :fatal) do
@@ -182,10 +220,6 @@ module Bosh::Cli::Command
182
220
  bosh_status["cpi"]
183
221
  end
184
222
 
185
- def template_file(file)
186
- File.join(bosh_release_dir, "templates", bosh_cpi, file)
187
- end
188
-
189
223
  # TODO this is now a bosh cli command itself; use #director
190
224
  def bosh_director_client
191
225
  director
@@ -207,9 +241,8 @@ module Bosh::Cli::Command
207
241
  cmd
208
242
  end
209
243
 
210
- # TODO this is now a bosh cli command itself
211
244
  def deployment_file
212
- @current_deployment_file ||= ::Bosh::Cli::Command::Deployment.new.deployment
245
+ deployment
213
246
  end
214
247
 
215
248
  # TODO use bosh cli helpers to validate/require this
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli_plugin_redis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -87,6 +87,7 @@ files:
87
87
  - bosh_release/templates/aws/spec
88
88
  - bosh_release/templates/openstack/sample_deployment_file.yml
89
89
  - bosh_release/templates/openstack/single_vm.yml.erb
90
+ - bosh_release/templates/openstack/spec
90
91
  - lib/bosh/cli/commands/redis.rb
91
92
  homepage: ''
92
93
  licenses:
@@ -103,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
104
  version: '0'
104
105
  segments:
105
106
  - 0
106
- hash: 4389263479679262262
107
+ hash: -3254480115549192426
107
108
  required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  none: false
109
110
  requirements:
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
113
  version: '0'
113
114
  segments:
114
115
  - 0
115
- hash: 4389263479679262262
116
+ hash: -3254480115549192426
116
117
  requirements: []
117
118
  rubyforge_project:
118
119
  rubygems_version: 1.8.25