Skip to content

Commit b3e39dc

Browse files
committed
Add storage cli param to cc deployment updater
1 parent 88c8843 commit b3e39dc

File tree

6 files changed

+222
-0
lines changed

6 files changed

+222
-0
lines changed

jobs/cc_deployment_updater/spec

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ templates:
2727
resource_pool_ca_cert.pem.erb: config/certs/resource_pool_ca_cert.pem
2828
droplets_ca_cert.pem.erb: config/certs/droplets_ca_cert.pem
2929
buildpacks_ca_cert.pem.erb: config/certs/buildpacks_ca_cert.pem
30+
storage_cli_config_droplets.json.erb: config/storage_cli_config_droplets.json
31+
storage_cli_config_packages.json.erb: config/storage_cli_config_packages.json
32+
storage_cli_config_buildpacks.json.erb: config/storage_cli_config_buildpacks.json
33+
storage_cli_config_resource_pool.json.erb: config/storage_cli_config_resource_pool.json
3034

3135
packages:
3236
- capi_utils
@@ -222,3 +226,24 @@ properties:
222226
cc.locket.port:
223227
default: 8891
224228
description: "Port of the Locket server"
229+
230+
cc.resource_pool.blobstore_provider:
231+
description: "The provider of blobstore storage cli to use. Valid values: ['AzureRM']"
232+
default: ~
233+
cc.resource_pool.connection_config:
234+
description: "Azure Storage Cli connection hash"
235+
cc.packages.blobstore_provider:
236+
description: "The provider of blobstore storage cli to use. Valid values: ['AzureRM']"
237+
default: ~
238+
cc.packages.connection_config:
239+
description: "Azure Storage Cli connection hash"
240+
cc.droplets.blobstore_provider:
241+
description: "The provider of blobstore storage cli to use. Valid values: ['AzureRM']"
242+
default: ~
243+
cc.droplets.connection_config:
244+
description: "Azure Storage Cli connection hash"
245+
cc.buildpacks.blobstore_provider:
246+
description: "The provider of blobstore storage cli to use. Valid values: ['AzureRM']"
247+
default: ~
248+
cc.buildpacks.connection_config:
249+
description: "Azure Storage Cli connection hash"

jobs/cc_deployment_updater/templates/cloud_controller_ng.yml.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ maximum_health_check_timeout: <%= link("cloud_controller_internal").p("cc.maximu
152152

153153
stacks_file: /var/vcap/jobs/cloud_controller_ng/config/stacks.yml
154154

155+
storage_cli_config_file_droplets: /var/vcap/jobs/cc_deployment_updater/config/storage_cli_config_droplets.json
156+
storage_cli_config_file_buildpacks: /var/vcap/jobs/cc_deployment_updater/config/storage_cli_config_buildpacks.json
157+
storage_cli_config_file_packages: /var/vcap/jobs/cc_deployment_updater/config/storage_cli_config_packages.json
158+
storage_cli_config_file_resource_pool: /var/vcap/jobs/cc_deployment_updater/config/storage_cli_config_resource_pool.json
159+
155160
resource_pool:
156161
blobstore_type: <%= link("cloud_controller_internal").p("cc.resource_pool.blobstore_type") %>
157162
webdav_config:
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<%
2+
require "json"
3+
4+
# Ensure Azure CLI connection_config has a default timeout if none is set
5+
def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds: 41)
6+
cfg = (connection_cfg || {}).dup
7+
if blobstore_type == 'storage_cli'
8+
if !cfg.key?('put_timeout_in_seconds') || cfg['put_timeout_in_seconds'].to_s.empty?
9+
cfg['put_timeout_in_seconds'] = default_seconds.to_s
10+
end
11+
end
12+
cfg
13+
end
14+
15+
# helper: add key only when value is present
16+
def add(h, key, val)
17+
return if val.nil?
18+
return if val.respond_to?(:empty?) && val.empty?
19+
h[key] = val
20+
end
21+
22+
scope = "cc.buildpacks.connection_config"
23+
provider = p("cc.buildpacks.blobstore_provider", nil)
24+
25+
if provider != "AzureRM"
26+
options = {} # for now: all non-azure providers output an empty JSON object
27+
else
28+
options = {}
29+
options["provider"] = provider
30+
options["account_name"] = p("#{scope}.azure_storage_account_name")
31+
options["container_name"] = p("#{scope}.container_name")
32+
add(options, "account_key", p("#{scope}.azure_storage_access_key"))
33+
add(options, "environment", p("#{scope}.environment", "AzureCloud"))
34+
add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil))
35+
36+
# optional passthrough for extra storage-cli flags
37+
begin
38+
custom = p("#{scope}.custom", {})
39+
if custom.respond_to?(:each)
40+
custom.each { |k, v| add(options, k.to_s, v) }
41+
end
42+
rescue
43+
# ignore if property not defined
44+
end
45+
options = cli_cfg_with_default_timeout(options, 'storage_cli')
46+
end
47+
-%>
48+
<%= JSON.pretty_generate(options) %>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<%
2+
require "json"
3+
4+
# Ensure Azure CLI connection_config has a default timeout if none is set
5+
def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds: 41)
6+
cfg = (connection_cfg || {}).dup
7+
if blobstore_type == 'storage_cli'
8+
if !cfg.key?('put_timeout_in_seconds') || cfg['put_timeout_in_seconds'].to_s.empty?
9+
cfg['put_timeout_in_seconds'] = default_seconds.to_s
10+
end
11+
end
12+
cfg
13+
end
14+
15+
# helper: add key only when value is present
16+
def add(h, key, val)
17+
return if val.nil?
18+
return if val.respond_to?(:empty?) && val.empty?
19+
h[key] = val
20+
end
21+
22+
scope = "cc.droplets.connection_config"
23+
provider = p("cc.droplets.blobstore_provider", nil)
24+
25+
if provider != "AzureRM"
26+
options = {} # for now: all non-azure providers output an empty JSON object
27+
else
28+
options = {}
29+
options["provider"] = provider
30+
options["account_name"] = p("#{scope}.azure_storage_account_name")
31+
options["container_name"] = p("#{scope}.container_name")
32+
add(options, "account_key", p("#{scope}.azure_storage_access_key"))
33+
add(options, "environment", p("#{scope}.environment", "AzureCloud"))
34+
add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil))
35+
36+
# optional passthrough for extra storage-cli flags
37+
begin
38+
custom = p("cc.droplets.connection_config.custom", {})
39+
if custom.respond_to?(:each)
40+
custom.each { |k, v| add(options, k.to_s, v) }
41+
end
42+
rescue
43+
# ignore if property not defined
44+
end
45+
options = cli_cfg_with_default_timeout(options, 'storage_cli')
46+
end
47+
-%>
48+
<%= JSON.pretty_generate(options) %>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<%
2+
require "json"
3+
4+
# Ensure Azure CLI connection_config has a default timeout if none is set
5+
def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds: 41)
6+
cfg = (connection_cfg || {}).dup
7+
if blobstore_type == 'storage_cli'
8+
if !cfg.key?('put_timeout_in_seconds') || cfg['put_timeout_in_seconds'].to_s.empty?
9+
cfg['put_timeout_in_seconds'] = default_seconds.to_s
10+
end
11+
end
12+
cfg
13+
end
14+
15+
# helper: add key only when value is present
16+
def add(h, key, val)
17+
return if val.nil?
18+
return if val.respond_to?(:empty?) && val.empty?
19+
h[key] = val
20+
end
21+
22+
scope = "cc.packages.connection_config"
23+
provider = p("cc.packages.blobstore_provider", nil)
24+
25+
if provider != "AzureRM"
26+
options = {} # for now: all non-azure providers output an empty JSON object
27+
else
28+
options = {}
29+
options["provider"] = provider
30+
options["account_name"] = p("#{scope}.azure_storage_account_name")
31+
options["container_name"] = p("#{scope}.container_name")
32+
add(options, "account_key", p("#{scope}.azure_storage_access_key"))
33+
add(options, "environment", p("#{scope}.environment", "AzureCloud"))
34+
add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil))
35+
36+
# optional passthrough for extra storage-cli flags
37+
begin
38+
custom = p("#{scope}.custom", {})
39+
if custom.respond_to?(:each)
40+
custom.each { |k, v| add(options, k.to_s, v) }
41+
end
42+
rescue
43+
# ignore if property not defined
44+
end
45+
options = cli_cfg_with_default_timeout(options, 'storage_cli')
46+
end
47+
-%>
48+
<%= JSON.pretty_generate(options) %>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<%
2+
require "json"
3+
4+
# Ensure Azure CLI connection_config has a default timeout if none is set
5+
def cli_cfg_with_default_timeout(connection_cfg, blobstore_type, default_seconds: 41)
6+
cfg = (connection_cfg || {}).dup
7+
if blobstore_type == 'storage_cli'
8+
if !cfg.key?('put_timeout_in_seconds') || cfg['put_timeout_in_seconds'].to_s.empty?
9+
cfg['put_timeout_in_seconds'] = default_seconds.to_s
10+
end
11+
end
12+
cfg
13+
end
14+
15+
# helper: add key only when value is present
16+
def add(h, key, val)
17+
return if val.nil?
18+
return if val.respond_to?(:empty?) && val.empty?
19+
h[key] = val
20+
end
21+
22+
scope = "cc.resource_pool.connection_config"
23+
provider = p("cc.resource_pool.blobstore_provider", nil)
24+
25+
if provider != "AzureRM"
26+
options = {} # for now: all non-azure providers output an empty JSON object
27+
else
28+
options = {}
29+
options["provider"] = provider
30+
options["account_name"] = p("#{scope}.azure_storage_account_name")
31+
options["container_name"] = p("#{scope}.container_name")
32+
add(options, "account_key", p("#{scope}.azure_storage_access_key"))
33+
add(options, "environment", p("#{scope}.environment", "AzureCloud"))
34+
add(options, "put_timeout_in_seconds", p("#{scope}.put_timeout_in_seconds", nil))
35+
36+
# optional passthrough for extra storage-cli flags
37+
begin
38+
custom = p("#{scope}.custom", {})
39+
if custom.respond_to?(:each)
40+
custom.each { |k, v| add(options, k.to_s, v) }
41+
end
42+
rescue
43+
# ignore if property not defined
44+
end
45+
options = cli_cfg_with_default_timeout(options, 'storage_cli')
46+
end
47+
-%>
48+
<%= JSON.pretty_generate(options) %>

0 commit comments

Comments
 (0)