bosh-cloudfoundry 0.7.0.alpha.2 → 0.7.0.alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.2"
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}
@@ -106,7 +106,7 @@ module Bosh::Cli::Command
106
106
  },
107
107
  "networks" => {},
108
108
  "properties" => {
109
- "cf" => attrs.attributes_with_string_keys
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] = default_name
15
- @attributes[:core_size] = default_size
16
- @attributes[:persistent_disk] = default_persistent_disk
17
- @attributes[:security_group] = default_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
@@ -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
- it "requires --ip 1.2.3.4" do
103
- command.add_option(:dns, "mycloud.com")
104
- command.add_option(:size, "xlarge")
105
- expect { command.create_cf }.to raise_error(Bosh::Cli::CliError)
106
- end
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 = random_string 12, :common
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 = random_string 12, :common
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.2
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: -4235919160106065906
414
+ hash: -1493789515290037622
415
415
  required_rubygems_version: !ruby/object:Gem::Requirement
416
416
  none: false
417
417
  requirements: