bosh-cloudfoundry 0.7.0.alpha.2 → 0.7.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bosh-cloudfoundry.gemspec +1 -1
- data/lib/bosh/cli/commands/cf.rb +12 -1
- data/lib/bosh/cloudfoundry/deployment_attributes.rb +34 -4
- data/spec/plugin_spec.rb +21 -10
- data/templates/v132/aws/dev/deployment_file.yml.erb +3 -1
- data/templates/v132/openstack/dev/deployment_file.yml.erb +3 -1
- metadata +2 -2
data/bosh-cloudfoundry.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "bosh-cloudfoundry"
|
5
|
-
spec.version = "0.7.0.alpha.
|
5
|
+
spec.version = "0.7.0.alpha.3"
|
6
6
|
spec.authors = ["Dr Nic Williams"]
|
7
7
|
spec.email = ["drnicwilliams@gmail.com"]
|
8
8
|
spec.description = %q{Create & manage Cloud Foundry deployments}
|
data/lib/bosh/cli/commands/cf.rb
CHANGED
@@ -106,7 +106,7 @@ module Bosh::Cli::Command
|
|
106
106
|
},
|
107
107
|
"networks" => {},
|
108
108
|
"properties" => {
|
109
|
-
|
109
|
+
attrs.properties_key => attrs.attributes_with_string_keys
|
110
110
|
}
|
111
111
|
}.to_yaml
|
112
112
|
end
|
@@ -126,7 +126,18 @@ module Bosh::Cli::Command
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
usage "show cf passwords"
|
130
|
+
desc "display the internal passwords for deployment"
|
131
|
+
def show_cf_passwords
|
132
|
+
load_deployment_into_attributes
|
133
|
+
say "Common password: #{attrs.validated_color(:common_password)}"
|
134
|
+
end
|
135
|
+
|
129
136
|
protected
|
137
|
+
def load_deployment_into_attributes
|
138
|
+
attrs.load_deployment_file(deployment)
|
139
|
+
end
|
140
|
+
|
130
141
|
def release_versioned_template
|
131
142
|
@release_versioned_template ||= begin
|
132
143
|
Bosh::Cloudfoundry::ReleaseVersionedTemplate.new(release_version, bosh_cpi, deployment_size)
|
@@ -11,10 +11,11 @@ module Bosh::Cloudfoundry
|
|
11
11
|
@bosh_status = bosh_status
|
12
12
|
@released_versioned_template = released_versioned_template
|
13
13
|
@attributes = attributes
|
14
|
-
@attributes[:name]
|
15
|
-
@attributes[:core_size]
|
16
|
-
@attributes[:persistent_disk]
|
17
|
-
@attributes[:security_group]
|
14
|
+
@attributes[:name] ||= default_name
|
15
|
+
@attributes[:core_size] ||= default_size
|
16
|
+
@attributes[:persistent_disk] ||= default_persistent_disk
|
17
|
+
@attributes[:security_group] ||= default_security_group
|
18
|
+
@attributes[:common_password] ||= random_string(12, :common)
|
18
19
|
end
|
19
20
|
|
20
21
|
def name
|
@@ -49,6 +50,19 @@ module Bosh::Cloudfoundry
|
|
49
50
|
attributes[attribute.to_sym] = value if value
|
50
51
|
end
|
51
52
|
|
53
|
+
def load_deployment_file(deployment_file)
|
54
|
+
deployment_obj = YAML.load_file(deployment_file)
|
55
|
+
attributes = deployment_obj["properties"][properties_key]
|
56
|
+
@attributes = attributes.inject({}) do |mem, key_value|
|
57
|
+
k, v = key_value; mem[k.to_sym] = v; mem
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# attributes are stored within deployment file at properties.cf
|
62
|
+
def properties_key
|
63
|
+
"cf"
|
64
|
+
end
|
65
|
+
|
52
66
|
def validate(attribute)
|
53
67
|
value = attributes[attribute.to_sym]
|
54
68
|
if attribute.to_s =~ /size$/
|
@@ -120,5 +134,21 @@ module Bosh::Cloudfoundry
|
|
120
134
|
@bosh_status["cpi"]
|
121
135
|
end
|
122
136
|
|
137
|
+
# Generate a random string for passwords and tokens.
|
138
|
+
# Length is the length of the string.
|
139
|
+
# name is an optional name of a previously generated string. This is used
|
140
|
+
# to allow setting the same password for different components.
|
141
|
+
# Extracted from Bosh::Cli::Command::Biff
|
142
|
+
def random_string(length, name=nil)
|
143
|
+
random_string = SecureRandom.hex(length)[0...length]
|
144
|
+
|
145
|
+
@random_cache ||= {}
|
146
|
+
if name
|
147
|
+
@random_cache[name] ||= random_string
|
148
|
+
else
|
149
|
+
random_string
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
123
153
|
end
|
124
154
|
end
|
data/spec/plugin_spec.rb
CHANGED
@@ -40,6 +40,18 @@ describe Bosh::Cli::Command::CloudFoundry do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
context "create cf" do
|
43
|
+
it "requires --ip 1.2.3.4" do
|
44
|
+
command.add_option(:dns, "mycloud.com")
|
45
|
+
command.add_option(:size, "xlarge")
|
46
|
+
expect { command.create_cf }.to raise_error(Bosh::Cli::CliError)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "requires --dns" do
|
50
|
+
command.add_option(:ip, ["1.2.3.4"])
|
51
|
+
command.add_option(:size, "xlarge")
|
52
|
+
expect { command.create_cf }.to raise_error(Bosh::Cli::CliError)
|
53
|
+
end
|
54
|
+
|
43
55
|
context "with requirements" do
|
44
56
|
before do
|
45
57
|
command.add_option(:config, home_file(".bosh_config"))
|
@@ -97,19 +109,18 @@ describe Bosh::Cli::Command::CloudFoundry do
|
|
97
109
|
command.create_cf
|
98
110
|
end
|
99
111
|
end
|
100
|
-
end
|
101
112
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
113
|
+
context "and show passwords" do
|
114
|
+
it "displays the list of internal passwords" do
|
115
|
+
in_home_dir do
|
116
|
+
command.create_cf
|
117
|
+
command.show_cf_passwords
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
107
121
|
|
108
|
-
it "requires --dns" do
|
109
|
-
command.add_option(:ip, ["1.2.3.4"])
|
110
|
-
command.add_option(:size, "xlarge")
|
111
|
-
expect { command.create_cf }.to raise_error(Bosh::Cli::CliError)
|
112
122
|
end
|
113
123
|
|
114
124
|
end
|
125
|
+
|
115
126
|
end
|
@@ -30,7 +30,7 @@ ip_addresses = find("properties.cf.ip_addresses")
|
|
30
30
|
security_group = find("properties.cf.security_group")
|
31
31
|
core_size = find("properties.cf.core_size")
|
32
32
|
persistent_disk = find("properties.cf.persistent_disk")
|
33
|
-
common_password =
|
33
|
+
common_password = find("properties.cf.common_password")
|
34
34
|
-%>
|
35
35
|
name: <%= name %>
|
36
36
|
director_uuid: <%= find("director_uuid") %>
|
@@ -142,11 +142,13 @@ jobs:
|
|
142
142
|
|
143
143
|
properties:
|
144
144
|
cf:
|
145
|
+
name: <%= name %>
|
145
146
|
dns: <%= dns %>
|
146
147
|
ip_addresses: <%= ip_addresses.inspect %>
|
147
148
|
core_size: <%= core_size %>
|
148
149
|
security_group: <%= security_group %>
|
149
150
|
persistent_disk: <%= persistent_disk %>
|
151
|
+
common_password: <%= common_password %>
|
150
152
|
|
151
153
|
domain: <%= dns %>
|
152
154
|
system_domain: <%= dns %>.com
|
@@ -30,7 +30,7 @@ ip_addresses = find("properties.cf.ip_addresses")
|
|
30
30
|
security_group = find("properties.cf.security_group")
|
31
31
|
core_size = find("properties.cf.core_size")
|
32
32
|
persistent_disk = find("properties.cf.persistent_disk")
|
33
|
-
common_password =
|
33
|
+
common_password = find("properties.cf.common_password")
|
34
34
|
-%>
|
35
35
|
name: <%= name %>
|
36
36
|
director_uuid: <%= find("director_uuid") %>
|
@@ -142,11 +142,13 @@ jobs:
|
|
142
142
|
|
143
143
|
properties:
|
144
144
|
cf:
|
145
|
+
name: <%= name %>
|
145
146
|
dns: <%= dns %>
|
146
147
|
ip_addresses: <%= ip_addresses.inspect %>
|
147
148
|
core_size: <%= core_size %>
|
148
149
|
security_group: <%= security_group %>
|
149
150
|
persistent_disk: <%= persistent_disk %>
|
151
|
+
common_password: <%= common_password %>
|
150
152
|
|
151
153
|
domain: <%= dns %>
|
152
154
|
system_domain: <%= dns %>.com
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bosh-cloudfoundry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.0.alpha.
|
4
|
+
version: 0.7.0.alpha.3
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -411,7 +411,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
411
411
|
version: '0'
|
412
412
|
segments:
|
413
413
|
- 0
|
414
|
-
hash: -
|
414
|
+
hash: -1493789515290037622
|
415
415
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
416
416
|
none: false
|
417
417
|
requirements:
|