bosh-cloudfoundry 0.7.0.alpha.7 → 0.7.0.alpha.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.md +2 -1
- data/README.md +20 -5
- data/bosh-cloudfoundry.gemspec +1 -1
- data/lib/bosh/cli/commands/cf.rb +48 -16
- data/lib/bosh/cloudfoundry/deployment_attributes.rb +21 -3
- data/lib/bosh/cloudfoundry/deployment_file.rb +9 -9
- data/lib/bosh/cloudfoundry/validations/dns_ip_mapping_validation.rb +13 -3
- data/spec/deployment_attributes_spec.rb +22 -8
- data/spec/deployment_file_spec.rb +12 -12
- data/spec/plugin_spec.rb +77 -40
- data/templates/v132/aws/large/deployment_file.yml.erb +1 -1
- data/templates/v132/aws/medium/deployment_file.yml.erb +1 -1
- data/templates/v132/openstack/large/deployment_file.yml.erb +1 -1
- data/templates/v132/openstack/medium/deployment_file.yml.erb +1 -1
- data/templates/v133/aws/large/deployment_file.yml.erb +1 -1
- data/templates/v133/aws/medium/deployment_file.yml.erb +1 -1
- data/templates/v133/openstack/large/deployment_file.yml.erb +1 -1
- data/templates/v133/openstack/medium/deployment_file.yml.erb +1 -1
- metadata +2 -2
data/ChangeLog.md
CHANGED
@@ -17,6 +17,7 @@ The rewrite introduces some new implementation/feature concepts:
|
|
17
17
|
* using `bosh diff` (aka biff) to generate the deployment file
|
18
18
|
* bundles all final releases into the project & distributed rubygem/plugin (no runtime dependency on cf-release git repository; only the public blobstore)
|
19
19
|
* templates are versioned for each final release (unless new templates not required for new release)
|
20
|
-
* different sizes of deployments (orders of magnitude), such as small, medium & large
|
20
|
+
* different sizes of deployments (orders of magnitude), such as small, medium & large: `bosh create cf --deployment-size large`
|
21
|
+
* mutable/changable properties (and immutable properties) for each template version: `bosh change cf attributes persistent_disk=8192`
|
21
22
|
|
22
23
|
The latter means that new versions of this rubygem can be published that are backwards compatible with aging deployments of Cloud Foundry. There should not be any forced coupling of old `bosh-cloudfoundry` to old `cf-release` final releases.
|
data/README.md
CHANGED
@@ -2,12 +2,13 @@
|
|
2
2
|
|
3
3
|
This is a simple `bosh` CLI plugin to boot up Cloud Foundry and then grow and upgrade and maintain it. Initially runs on AWS or OpenStack via bosh.
|
4
4
|
|
5
|
-
Example create/delete scenario:
|
5
|
+
Example create/scale/delete scenario:
|
6
6
|
|
7
7
|
```
|
8
8
|
$ bosh prepare cf
|
9
9
|
$ bosh create cf --dns mycloud.com --public-ip 1.2.3.4
|
10
|
-
|
10
|
+
...
|
11
|
+
$ bosh change cf attributes persistent_disk=8192
|
11
12
|
...
|
12
13
|
$ bosh delete cf
|
13
14
|
```
|
@@ -93,6 +94,8 @@ The `bosh_cli` gem is currently only available from S3, rather than RubyGem itse
|
|
93
94
|
|
94
95
|
## Usage
|
95
96
|
|
97
|
+
### Create initial Cloud Foundry
|
98
|
+
|
96
99
|
Each time you install the latest `bosh-cloudfoundry` gem you may want to re-upload the latest available Cloud Foundry bosh release to your bosh. If no newer release is available then nothing good nor bad will occur.
|
97
100
|
|
98
101
|
```
|
@@ -123,14 +126,16 @@ $ bosh create cf --security-group cf-core
|
|
123
126
|
* TODO - how to update Cloud Foundry servers to a different instance size/flavor
|
124
127
|
* TODO - how to update the persistent disks of the deployment
|
125
128
|
|
126
|
-
|
129
|
+
### Initializing Cloud Foundry
|
127
130
|
|
128
131
|
Once Cloud Foundry is up and running, follow these steps to login (and discover your password) and create an initial organization and space:
|
129
132
|
|
130
133
|
```
|
131
134
|
$ cf target api.mycloud.com
|
132
|
-
$ bosh show cf
|
133
|
-
|
135
|
+
$ bosh show cf attributes
|
136
|
+
...
|
137
|
+
common_password: 6d7fe84f828b
|
138
|
+
...
|
134
139
|
$ cf login admin
|
135
140
|
Password> 6d7fe84f828b
|
136
141
|
|
@@ -139,6 +144,16 @@ $ cf create-space production
|
|
139
144
|
$ cf switch-space production
|
140
145
|
```
|
141
146
|
|
147
|
+
### Scaling Cloud Foundry
|
148
|
+
|
149
|
+
If your persistent disks start filling up (monitor via `bosh vms --vitals`) then you can scale them up by running:
|
150
|
+
|
151
|
+
```
|
152
|
+
$ bosh change cf attributes persistent_disk=8192
|
153
|
+
```
|
154
|
+
|
155
|
+
The initial size of persistent disks is `4096` (4Gb).
|
156
|
+
|
142
157
|
## Releasing new plugin gem versions
|
143
158
|
|
144
159
|
There are two reasons to release new versions of this plugin.
|
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.8"
|
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
@@ -73,11 +73,7 @@ module Bosh::Cli::Command
|
|
73
73
|
say "Security group: #{attrs.validated_color(:security_group)}"
|
74
74
|
nl
|
75
75
|
|
76
|
-
|
77
|
-
attrs.validate(:deployment_size)
|
78
|
-
end
|
79
|
-
|
80
|
-
validate_dns_mapping
|
76
|
+
validate_deployment_attributes
|
81
77
|
|
82
78
|
unless confirmed?("Security group #{attrs.validated_color(:security_group)} exists with ports #{attrs.required_ports.join(", ")}")
|
83
79
|
cancel_deployment
|
@@ -88,34 +84,64 @@ module Bosh::Cli::Command
|
|
88
84
|
|
89
85
|
raise Bosh::Cli::ValidationHalted unless errors.empty?
|
90
86
|
|
91
|
-
deployment_file = DeploymentFile.new(@release_version_cpi_size, attrs, bosh_status)
|
92
|
-
|
93
|
-
deployment_file.create_deployment_file
|
94
|
-
deployment_file.deploy(options)
|
95
|
-
|
87
|
+
@deployment_file = DeploymentFile.new(@release_version_cpi_size, attrs, bosh_status)
|
88
|
+
perform_deploy(options)
|
96
89
|
rescue Bosh::Cli::ValidationHalted
|
97
90
|
errors.each do |error|
|
98
91
|
say error.make_red
|
99
92
|
end
|
93
|
+
exit 1
|
100
94
|
end
|
101
95
|
|
102
|
-
usage "show cf
|
103
|
-
desc "display the deployment
|
104
|
-
def
|
96
|
+
usage "show cf attributes"
|
97
|
+
desc "display the deployment attributes, indicate which are changable"
|
98
|
+
def show_cf_attributes
|
105
99
|
setup_deployment_attributes
|
106
100
|
reconstruct_deployment_file
|
107
101
|
nl
|
108
|
-
say "Immutable
|
102
|
+
say "Immutable attributes:"
|
109
103
|
attrs.immutable_attributes.each do |attr_name|
|
110
104
|
say "#{attr_name}: #{attrs.validated_color(attr_name.to_sym)}"
|
111
105
|
end
|
112
106
|
nl
|
113
|
-
say "Mutable (changable)
|
107
|
+
say "Mutable (changable) attributes:"
|
114
108
|
attrs.mutable_attributes.each do |attr_name|
|
115
109
|
say "#{attr_name}: #{attrs.validated_color(attr_name.to_sym)}"
|
116
110
|
end
|
117
111
|
end
|
118
112
|
|
113
|
+
usage "change cf attributes"
|
114
|
+
desc "change deployment attributes and perform bosh deploy"
|
115
|
+
def change_cf_attributes(*attribute_values)
|
116
|
+
setup_deployment_attributes
|
117
|
+
reconstruct_deployment_file
|
118
|
+
|
119
|
+
# TODO fail if setting immutable attributes
|
120
|
+
attribute_values.each do |attr_value|
|
121
|
+
# FIXME check that correct format of input: xyz=123 and give feedback
|
122
|
+
attr_name, value = attr_value.split(/=/)
|
123
|
+
previous_value = attrs.validated_color(attr_name)
|
124
|
+
step("Checking '#{attr_name}' is a valid mutable attribute",
|
125
|
+
"Attribute '#{attr_name}' is not a valid mutable attribute (see 'bosh show cf attributes')", :non_fatal) do
|
126
|
+
attrs.mutable_attribute?(attr_name)
|
127
|
+
end
|
128
|
+
attrs.set_mutable(attr_name, value)
|
129
|
+
end
|
130
|
+
|
131
|
+
validate_deployment_attributes
|
132
|
+
# TODO show validated attributes like "create cf"
|
133
|
+
|
134
|
+
raise Bosh::Cli::ValidationHalted unless errors.empty?
|
135
|
+
|
136
|
+
perform_deploy(options)
|
137
|
+
|
138
|
+
rescue Bosh::Cli::ValidationHalted
|
139
|
+
errors.each do |error|
|
140
|
+
say error.make_red
|
141
|
+
end
|
142
|
+
exit 1
|
143
|
+
end
|
144
|
+
|
119
145
|
protected
|
120
146
|
def setup_deployment_attributes
|
121
147
|
@release_version_cpi = ReleaseVersionCpi.latest_for_cpi(bosh_cpi)
|
@@ -134,6 +160,10 @@ module Bosh::Cli::Command
|
|
134
160
|
@release_version_cpi_size = @deployment_file.release_version_cpi_size
|
135
161
|
end
|
136
162
|
|
163
|
+
def perform_deploy(deploy_options={})
|
164
|
+
@deployment_file.perform(deploy_options)
|
165
|
+
end
|
166
|
+
|
137
167
|
def bosh_release_dir
|
138
168
|
File.expand_path("../../../../../bosh_release", __FILE__)
|
139
169
|
end
|
@@ -193,8 +223,10 @@ module Bosh::Cli::Command
|
|
193
223
|
cmd
|
194
224
|
end
|
195
225
|
|
196
|
-
def
|
226
|
+
def validate_deployment_attributes
|
227
|
+
attrs.validate_deployment_size
|
197
228
|
attrs.validate_dns_mapping
|
198
229
|
end
|
230
|
+
|
199
231
|
end
|
200
232
|
end
|
@@ -54,12 +54,16 @@ module Bosh::Cloudfoundry
|
|
54
54
|
|
55
55
|
# Attributes & their values that can be changed via setters & deployment re-deployed successfully
|
56
56
|
def mutable_attributes
|
57
|
-
release_version_cpi.mutable_attributes
|
57
|
+
release_version_cpi.mutable_attributes.map(&:to_sym)
|
58
58
|
end
|
59
59
|
|
60
60
|
# Attributes & their values that are not to be changed over time
|
61
61
|
def immutable_attributes
|
62
|
-
release_version_cpi.immutable_attributes
|
62
|
+
release_version_cpi.immutable_attributes.map(&:to_sym)
|
63
|
+
end
|
64
|
+
|
65
|
+
def mutable_attribute?(attribute)
|
66
|
+
mutable_attributes.include?(attribute.to_sym)
|
63
67
|
end
|
64
68
|
|
65
69
|
def set_unless_nil(attribute, value)
|
@@ -67,7 +71,15 @@ module Bosh::Cloudfoundry
|
|
67
71
|
end
|
68
72
|
|
69
73
|
def set(attribute, value)
|
70
|
-
attributes[attribute.to_sym] = value
|
74
|
+
attributes[attribute.to_sym] = value
|
75
|
+
end
|
76
|
+
|
77
|
+
def set_mutable(attribute, value)
|
78
|
+
if mutable_attribute?(attribute)
|
79
|
+
attributes[attribute.to_sym] = value
|
80
|
+
else
|
81
|
+
false
|
82
|
+
end
|
71
83
|
end
|
72
84
|
|
73
85
|
def validate(attribute)
|
@@ -81,6 +93,12 @@ module Bosh::Cloudfoundry
|
|
81
93
|
end
|
82
94
|
end
|
83
95
|
|
96
|
+
def validate_deployment_size
|
97
|
+
step("Validating deployment size", "Available deployment sizes are #{available_deployment_sizes.join(', ')}", :fatal) do
|
98
|
+
validate(:deployment_size)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
84
102
|
# FIXME only supports a single ip_address
|
85
103
|
def validate_dns_mapping
|
86
104
|
validate_dns_a_record("api.#{dns}", ip_addresses.first)
|
@@ -19,6 +19,12 @@ module Bosh::Cloudfoundry
|
|
19
19
|
@bosh_status = bosh_status
|
20
20
|
end
|
21
21
|
|
22
|
+
def perform(deploy_options={})
|
23
|
+
prepare_environment
|
24
|
+
create_deployment_file
|
25
|
+
deploy(deploy_options)
|
26
|
+
end
|
27
|
+
|
22
28
|
def prepare_environment
|
23
29
|
step("Checking/creating #{deployment_file_dir} for deployment files",
|
24
30
|
"Failed to create #{deployment_file_dir} for deployment files", :fatal) do
|
@@ -31,9 +37,6 @@ module Bosh::Cloudfoundry
|
|
31
37
|
# ---
|
32
38
|
# name: NAME
|
33
39
|
# director_uuid: 4ae3a0f0-70a5-4c0d-95f2-7fafaefe8b9e
|
34
|
-
# releases:
|
35
|
-
# - name: cf-release
|
36
|
-
# version: 132
|
37
40
|
# networks: {}
|
38
41
|
# properties:
|
39
42
|
# cf:
|
@@ -51,10 +54,6 @@ module Bosh::Cloudfoundry
|
|
51
54
|
file << {
|
52
55
|
"name" => deployment_attributes.name,
|
53
56
|
"director_uuid" => bosh_uuid,
|
54
|
-
"releases" => {
|
55
|
-
"name" => release_name,
|
56
|
-
"version" => release_version_number
|
57
|
-
},
|
58
57
|
"networks" => {},
|
59
58
|
"properties" => {
|
60
59
|
self.class.properties_key => deployment_attributes.attributes_with_string_keys
|
@@ -105,8 +104,6 @@ module Bosh::Cloudfoundry
|
|
105
104
|
end
|
106
105
|
release_version = release["version"]
|
107
106
|
release_version_cpi = ReleaseVersionCpi.new(release_version, bosh_cpi)
|
108
|
-
deployment_size = deployment_file["properties"]["deployment_size"]
|
109
|
-
release_version_cpi_size = ReleaseVersionCpiSize.new(release_version_cpi, deployment_size)
|
110
107
|
|
111
108
|
attributes = deployment_file["properties"][properties_key]
|
112
109
|
# convert string keys to symbol keys
|
@@ -115,6 +112,9 @@ module Bosh::Cloudfoundry
|
|
115
112
|
end
|
116
113
|
deployment_attributes = DeploymentAttributes.new(director_client, bosh_status, release_version_cpi, attributes)
|
117
114
|
|
115
|
+
deployment_size = deployment_attributes.deployment_size
|
116
|
+
release_version_cpi_size = ReleaseVersionCpiSize.new(release_version_cpi, deployment_size)
|
117
|
+
|
118
118
|
self.new(release_version_cpi_size, deployment_attributes, bosh_status)
|
119
119
|
end
|
120
120
|
|
@@ -45,9 +45,19 @@ module Bosh::Cloudfoundry::Validations
|
|
45
45
|
|
46
46
|
protected
|
47
47
|
def resolve_dns(domain)
|
48
|
+
domain += "." if domain[-1] != "."
|
48
49
|
packet = Net::DNS::Resolver.start(domain, Net::DNS::A)
|
49
|
-
resolved_a_records = packet.answer.
|
50
|
-
|
50
|
+
resolved_a_records = packet.answer.select { |record|
|
51
|
+
record.name == domain
|
52
|
+
}.map { |record|
|
53
|
+
case record.type
|
54
|
+
when "CNAME"
|
55
|
+
resolve_dns(record.value)[1]
|
56
|
+
when "A"
|
57
|
+
record.value
|
58
|
+
end
|
59
|
+
}.flatten
|
60
|
+
[(resolved_a_records.size > 0), resolved_a_records]
|
51
61
|
end
|
52
62
|
end
|
53
|
-
end
|
63
|
+
end
|
@@ -38,14 +38,28 @@ describe Bosh::Cloudfoundry::DeploymentAttributes do
|
|
38
38
|
subject.immutable_attributes.should == immutable_attributes
|
39
39
|
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
subject
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
context "mutable attributes" do
|
42
|
+
let(:mutable_attributes) { %w[ip_addresses persistent_disk security_group].map(&:to_sym) }
|
43
|
+
before { release_version_cpi.should_receive(:mutable_attributes).and_return(mutable_attributes) }
|
44
|
+
|
45
|
+
subject do
|
46
|
+
Bosh::Cloudfoundry::DeploymentAttributes.new(director, bosh_status, release_version_cpi, {
|
47
|
+
dns: "mycloud.com", ip_addresses: ["1.2.3.4"]
|
48
|
+
})
|
49
|
+
end
|
50
|
+
|
51
|
+
# mutable_attributes ultimately determined by ReleaseVersion (from templates/vXYZ/spec)
|
52
|
+
it "mutable_attributes derived from release_version[_cpi]" do
|
53
|
+
subject.mutable_attributes.should == mutable_attributes
|
54
|
+
end
|
55
|
+
|
56
|
+
it "mutable_attribute? is true for mutable attributes" do
|
57
|
+
subject.should be_mutable_attribute("persistent_disk")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "mutable_attribute? is false for immutable attributes" do
|
61
|
+
subject.should_not be_mutable_attribute("name")
|
62
|
+
end
|
49
63
|
end
|
50
64
|
end
|
51
65
|
end
|
@@ -76,18 +76,18 @@ describe Bosh::Cloudfoundry::DeploymentFile do
|
|
76
76
|
subject.deploy(non_interactive: true)
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
79
|
+
|
80
|
+
# it "large size" do
|
81
|
+
# in_home_dir do
|
82
|
+
# command.add_option(:deployment_size, "large")
|
83
|
+
#
|
84
|
+
# command.create_cf
|
85
|
+
# files_match(spec_asset("v133/aws/large.yml"), command.deployment_file)
|
86
|
+
#
|
87
|
+
# manifest = YAML.load_file(command.deployment_file)
|
88
|
+
# Bosh::Cli::DeploymentManifest.new(manifest).normalize
|
89
|
+
# end
|
90
|
+
# end
|
91
91
|
#
|
92
92
|
# it "specifies core size" do
|
93
93
|
# in_home_dir do
|
data/spec/plugin_spec.rb
CHANGED
@@ -4,13 +4,44 @@ describe Bosh::Cli::Command::CloudFoundry do
|
|
4
4
|
include FileUtils
|
5
5
|
|
6
6
|
let(:command) { Bosh::Cli::Command::CloudFoundry.new }
|
7
|
+
let(:director) { instance_double("Bosh::Cli::Director") }
|
8
|
+
|
9
|
+
def setup_deployment
|
10
|
+
deployment_file = home_file("deployment.yml")
|
11
|
+
command.stub(:deployment).and_return(deployment_file)
|
12
|
+
File.open(deployment_file, "w") do |f|
|
13
|
+
f << {
|
14
|
+
"releases" => [
|
15
|
+
{"name" => "cf-release", "version" => 132}
|
16
|
+
],
|
17
|
+
"properties" => {
|
18
|
+
"cf" => {
|
19
|
+
# immutable attributes (determined via ReleaseVersion via templates/vXYZ/spec)
|
20
|
+
"name" => "demo",
|
21
|
+
"deployment_size" => "medium",
|
22
|
+
"dns" => "mycloud.com",
|
23
|
+
"common_password" => "qwerty",
|
24
|
+
# mutable attributes (determined via ReleaseVersion via templates/vXYZ/spec)
|
25
|
+
"ip_addresses" => ["1.2.3.4"],
|
26
|
+
"persistent_disk" => 4096,
|
27
|
+
"security_group" => "cf"
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}.to_yaml
|
31
|
+
end
|
32
|
+
deployment_file
|
33
|
+
end
|
7
34
|
|
8
35
|
before(:all) do
|
9
36
|
# Let us have pretty access to all protected methods which are protected from the bosh_cli plugin system.
|
10
37
|
Bosh::Cli::Command::CloudFoundry.send(:public, *Bosh::Cli::Command::CloudFoundry.protected_instance_methods)
|
11
38
|
end
|
12
39
|
|
13
|
-
before
|
40
|
+
before do
|
41
|
+
setup_home_dir
|
42
|
+
command.add_option(:config, home_file(".bosh_config"))
|
43
|
+
command.add_option(:non_interactive, true)
|
44
|
+
end
|
14
45
|
|
15
46
|
it "shows help" do
|
16
47
|
subject.cf_help
|
@@ -18,11 +49,8 @@ describe Bosh::Cli::Command::CloudFoundry do
|
|
18
49
|
|
19
50
|
context "prepare cf" do
|
20
51
|
before do
|
21
|
-
command.add_option(:config, home_file(".bosh_config"))
|
22
|
-
command.add_option(:non_interactive, true)
|
23
52
|
command.should_receive(:auth_required)
|
24
53
|
|
25
|
-
director = instance_double("Bosh::Cli::Director")
|
26
54
|
director.should_receive(:get_status).and_return({"uuid" => "UUID", "cpi" => "aws"})
|
27
55
|
command.stub(:director_client).and_return(director)
|
28
56
|
end
|
@@ -51,7 +79,6 @@ describe Bosh::Cli::Command::CloudFoundry do
|
|
51
79
|
context "create cf" do
|
52
80
|
context "validation failures" do
|
53
81
|
before do
|
54
|
-
director = instance_double("Bosh::Cli::Director")
|
55
82
|
director.stub(:get_status).and_return({"uuid" => "UUID", "cpi" => "aws"})
|
56
83
|
command.stub(:director_client).and_return(director)
|
57
84
|
end
|
@@ -70,65 +97,75 @@ describe Bosh::Cli::Command::CloudFoundry do
|
|
70
97
|
|
71
98
|
context "with requirements" do
|
72
99
|
it "creates cf deployment" do
|
73
|
-
command.add_option(:config, home_file(".bosh_config"))
|
74
|
-
command.add_option(:non_interactive, true)
|
75
100
|
command.add_option(:name, "demo")
|
76
101
|
command.add_option(:ip, ["1.2.3.4"])
|
77
102
|
command.add_option(:dns, "mycloud.com")
|
78
103
|
command.add_option(:common_password, "qwertyasdfgh")
|
79
104
|
|
80
105
|
command.should_receive(:auth_required)
|
81
|
-
command.should_receive(:
|
106
|
+
command.should_receive(:validate_deployment_attributes)
|
82
107
|
|
83
|
-
director = instance_double("Bosh::Cli::Director")
|
84
108
|
director.should_receive(:get_status).and_return({"uuid" => "UUID", "cpi" => "aws"})
|
85
109
|
command.stub(:director_client).and_return(director)
|
86
110
|
|
87
111
|
command.stub(:deployment).and_return(home_file("deployments/cf/demo.yml"))
|
88
112
|
|
89
|
-
deployment_file =
|
113
|
+
deployment_file = instance_double("Bosh::Cloudfoundry::DeploymentFile")
|
90
114
|
Bosh::Cloudfoundry::DeploymentFile.should_receive(:new).
|
91
115
|
and_return(deployment_file)
|
92
|
-
deployment_file.should_receive(:
|
93
|
-
deployment_file.should_receive(:create_deployment_file)
|
94
|
-
deployment_file.should_receive(:deploy)
|
116
|
+
deployment_file.should_receive(:perform)
|
95
117
|
|
96
118
|
command.create_cf
|
97
119
|
end
|
98
120
|
|
99
121
|
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "existing deployment" do
|
125
|
+
before do
|
126
|
+
@deployment_file_path = setup_deployment
|
100
127
|
|
101
|
-
it "displays the list of attributes/properties" do
|
102
|
-
command.add_option(:config, home_file(".bosh_config"))
|
103
|
-
command.add_option(:non_interactive, true)
|
104
|
-
|
105
|
-
director = instance_double("Bosh::Cli::Director")
|
106
128
|
director.should_receive(:get_status).and_return({"uuid" => "UUID", "cpi" => "aws"})
|
107
129
|
command.stub(:director_client).and_return(director)
|
130
|
+
end
|
108
131
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
132
|
+
it "displays the list of attributes/properties" do
|
133
|
+
command.show_cf_attributes
|
134
|
+
end
|
135
|
+
|
136
|
+
context "modifies attributes/properties and redeploys" do
|
137
|
+
let(:deployment_attributes) { instance_double("Bosh::Cloudfoundry::DeploymentAttributes")}
|
138
|
+
before do
|
139
|
+
deployment_file = instance_double("Bosh::Cloudfoundry::DeploymentFile")
|
140
|
+
Bosh::Cloudfoundry::DeploymentFile.should_receive(:new).
|
141
|
+
and_return(deployment_file)
|
142
|
+
deployment_file.should_receive(:deployment_attributes).and_return(deployment_attributes)
|
143
|
+
deployment_file.should_receive(:release_version_cpi_size)
|
144
|
+
deployment_file.should_receive(:perform)
|
145
|
+
|
146
|
+
command.should_receive(:validate_deployment_attributes)
|
147
|
+
|
148
|
+
deployment_attributes.stub(:mutable_attributes).and_return([:persistent_disk, :security_group])
|
149
|
+
end
|
150
|
+
|
151
|
+
it "for single property" do
|
152
|
+
deployment_attributes.should_receive(:validated_color).with("persistent_disk")
|
153
|
+
deployment_attributes.should_receive(:mutable_attribute?).with("persistent_disk").and_return(true)
|
154
|
+
deployment_attributes.should_receive(:set_mutable).with("persistent_disk", "8192")
|
155
|
+
|
156
|
+
command.change_cf_attributes("persistent_disk=8192")
|
157
|
+
end
|
158
|
+
|
159
|
+
it "for multiple properties" do
|
160
|
+
deployment_attributes.should_receive(:validated_color).with("persistent_disk")
|
161
|
+
deployment_attributes.should_receive(:validated_color).with("security_group")
|
162
|
+
deployment_attributes.should_receive(:mutable_attribute?).with("persistent_disk").and_return(true)
|
163
|
+
deployment_attributes.should_receive(:mutable_attribute?).with("security_group").and_return(true)
|
164
|
+
deployment_attributes.should_receive(:set_mutable).with("persistent_disk", "8192")
|
165
|
+
deployment_attributes.should_receive(:set_mutable).with("security_group", "cf-core")
|
166
|
+
|
167
|
+
command.change_cf_attributes("persistent_disk=8192", "security_group=cf-core")
|
129
168
|
end
|
130
|
-
command.show_cf_properties
|
131
169
|
end
|
132
170
|
end
|
133
|
-
|
134
171
|
end
|
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.8
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -494,7 +494,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
494
494
|
version: '0'
|
495
495
|
segments:
|
496
496
|
- 0
|
497
|
-
hash: -
|
497
|
+
hash: -3134788032320103940
|
498
498
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
499
499
|
none: false
|
500
500
|
requirements:
|