ey-core 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -2
- data/lib/ey-core/client.rb +7 -0
- data/lib/ey-core/client/mock.rb +1 -0
- data/lib/ey-core/collections/blueprints.rb +9 -0
- data/lib/ey-core/models/blueprint.rb +30 -0
- data/lib/ey-core/models/environment.rb +60 -39
- data/lib/ey-core/requests/blueprint_environment.rb +72 -0
- data/lib/ey-core/requests/boot_environment.rb +61 -14
- data/lib/ey-core/requests/destroy_blueprint.rb +22 -0
- data/lib/ey-core/requests/get_blueprint.rb +21 -0
- data/lib/ey-core/requests/get_blueprints.rb +29 -0
- data/lib/ey-core/requests/update_blueprint.rb +29 -0
- data/lib/ey-core/version.rb +1 -1
- data/spec/blueprints_spec.rb +34 -0
- data/spec/environments_spec.rb +16 -1
- data/spec/support/resource_helper.rb +1 -0
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fc43dd7e0537390e4176ab2bba75430348f3f54
|
4
|
+
data.tar.gz: ff4cb06ebced47b4838dc04fc0cb3da8c23fc02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70165d9bd64ae03255a4c12c6e75f683649ab68a66657d3d8e894c1decf7c9d974c60c8b2e5fc81a16abf6015dea88af9ef0791398960cfac3261e9077d88561
|
7
|
+
data.tar.gz: e3f26187c8549e810afa942983754af7adcf00e380b7436594012db0bfbc427656f615b2fde33572e10953e1a09cfdbffe516f17bc5b7eadb185df617675ce13
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3
|
data/.travis.yml
CHANGED
data/lib/ey-core/client.rb
CHANGED
@@ -15,6 +15,7 @@ class Ey::Core::Client < Cistern::Service
|
|
15
15
|
collection :application_deployments
|
16
16
|
collection :applications
|
17
17
|
collection :backup_files
|
18
|
+
collection :blueprints
|
18
19
|
collection :components
|
19
20
|
collection :contacts
|
20
21
|
collection :costs
|
@@ -70,6 +71,7 @@ class Ey::Core::Client < Cistern::Service
|
|
70
71
|
model :application_deployment
|
71
72
|
model :backup_file
|
72
73
|
model :billing
|
74
|
+
model :blueprint
|
73
75
|
model :component
|
74
76
|
model :contact
|
75
77
|
model :cost
|
@@ -118,6 +120,7 @@ class Ey::Core::Client < Cistern::Service
|
|
118
120
|
request :apply_server_updates
|
119
121
|
request :attach_address
|
120
122
|
request :authorized_channel
|
123
|
+
request :blueprint_environment
|
121
124
|
request :boot_environment
|
122
125
|
request :bootstrap_logical_database
|
123
126
|
request :cancel_account
|
@@ -155,6 +158,7 @@ class Ey::Core::Client < Cistern::Service
|
|
155
158
|
request :deploy_environment_application
|
156
159
|
request :deprovision_environment
|
157
160
|
request :destroy_addon
|
161
|
+
request :destroy_blueprint
|
158
162
|
request :destroy_database_server
|
159
163
|
request :destroy_database_server_snapshot
|
160
164
|
request :destroy_database_service
|
@@ -198,6 +202,8 @@ class Ey::Core::Client < Cistern::Service
|
|
198
202
|
request :get_backup_file
|
199
203
|
request :get_backup_files
|
200
204
|
request :get_billing
|
205
|
+
request :get_blueprint
|
206
|
+
request :get_blueprints
|
201
207
|
request :get_component
|
202
208
|
request :get_components
|
203
209
|
request :get_contacts
|
@@ -285,6 +291,7 @@ class Ey::Core::Client < Cistern::Service
|
|
285
291
|
request :update_alert
|
286
292
|
request :update_application_archive
|
287
293
|
request :update_billing
|
294
|
+
request :update_blueprint
|
288
295
|
request :update_membership
|
289
296
|
request :update_server
|
290
297
|
request :update_ssl_certificate
|
data/lib/ey-core/client/mock.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
class Ey::Core::Client::Blueprint < Ey::Core::Model
|
2
|
+
extend Ey::Core::Associations
|
3
|
+
|
4
|
+
identity :id
|
5
|
+
|
6
|
+
attribute :data, type: :hash
|
7
|
+
attribute :name
|
8
|
+
attribute :created_at, type: :time
|
9
|
+
attribute :updated_at, type: :time
|
10
|
+
|
11
|
+
has_one :account
|
12
|
+
has_one :environment
|
13
|
+
|
14
|
+
def save!
|
15
|
+
requires :id
|
16
|
+
|
17
|
+
params = {
|
18
|
+
"id" => self.id,
|
19
|
+
"blueprint" => {
|
20
|
+
"name" => self.name
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
merge_attributes(self.connection.update_blueprint(params).body["blueprint"])
|
25
|
+
end
|
26
|
+
|
27
|
+
def destroy
|
28
|
+
self.connection.destroy_blueprint("id" => self.identity)
|
29
|
+
end
|
30
|
+
end
|
@@ -69,65 +69,86 @@ class Ey::Core::Client::Environment < Ey::Core::Model
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
+
def blueprints
|
73
|
+
requires :id
|
74
|
+
self.connection.blueprints.all(environment: self.identity)
|
75
|
+
end
|
76
|
+
|
77
|
+
def save_blueprint(options={})
|
78
|
+
requires :id
|
79
|
+
raise "name is a required key" unless options["name"]
|
80
|
+
self.connection.blueprints.new(self.connection.blueprint_environment("id" => self.id, "name" => options["name"]).body["blueprint"])
|
81
|
+
end
|
82
|
+
|
72
83
|
def boot(options={})
|
73
84
|
options = Cistern::Hash.stringify_keys(options)
|
74
|
-
|
75
|
-
|
85
|
+
if options["blueprint_id"]
|
86
|
+
params = {
|
87
|
+
"cluster_configuration" => {
|
88
|
+
"blueprint_id" => options["blueprint_id"]
|
89
|
+
}
|
90
|
+
}
|
76
91
|
|
77
|
-
|
92
|
+
self.connection.requests.new(self.connection.boot_environment(params.merge("id" => self.id)).body["request"])
|
93
|
+
else
|
94
|
+
raise "configuration is a required key" unless options["configuration"]
|
95
|
+
raise "configuration['type'] is required" unless options["configuration"]["type"]
|
78
96
|
|
79
|
-
|
80
|
-
required_keys = %w(flavor volume_size mnt_volume_size)
|
97
|
+
missing_keys = []
|
81
98
|
|
82
|
-
|
83
|
-
|
99
|
+
configuration = options["configuration"]
|
100
|
+
required_keys = %w(flavor volume_size mnt_volume_size)
|
84
101
|
|
85
|
-
|
86
|
-
|
102
|
+
if self.database_service
|
103
|
+
raise "application_id is a required key" unless options["application_id"]
|
87
104
|
|
88
|
-
|
89
|
-
apps = configuration["apps"] ||= {}
|
90
|
-
db_master = configuration["db_master"] ||= {}
|
91
|
-
db_slaves = configuration["db_slaves"] ||= []
|
92
|
-
utils = configuration["utils"] ||= []
|
93
|
-
|
94
|
-
missing_keys << "apps" unless apps.any?
|
95
|
-
(required_keys + ["count"]).each do |required|
|
96
|
-
missing_keys << "apps[#{required}]" unless apps[required]
|
105
|
+
configuration["logical_database"] = "#{self.name}_#{self.application.name}"
|
97
106
|
end
|
98
107
|
|
99
|
-
|
100
|
-
|
108
|
+
if configuration["type"] == 'custom'
|
109
|
+
apps = configuration["apps"] ||= {}
|
110
|
+
db_master = configuration["db_master"] ||= {}
|
111
|
+
db_slaves = configuration["db_slaves"] ||= []
|
112
|
+
utils = configuration["utils"] ||= []
|
101
113
|
|
102
|
-
|
103
|
-
|
114
|
+
missing_keys << "apps" unless apps.any?
|
115
|
+
(required_keys + ["count"]).each do |required|
|
116
|
+
missing_keys << "apps[#{required}]" unless apps[required]
|
104
117
|
end
|
105
|
-
end
|
106
118
|
|
107
|
-
|
108
|
-
|
109
|
-
|
119
|
+
unless configuration["database_service_id"]
|
120
|
+
missing_keys << "db_master" unless db_master.any?
|
121
|
+
|
122
|
+
required_keys.each do |key|
|
123
|
+
missing_keys << "db_master[#{key}]" unless db_master[key]
|
124
|
+
end
|
110
125
|
end
|
111
|
-
end
|
112
126
|
|
113
|
-
|
114
|
-
|
115
|
-
|
127
|
+
db_slaves.each_with_index do |slave, i|
|
128
|
+
(required_keys - ["volume_size", "mnt_volume_size"]).each do |key|
|
129
|
+
missing_keys << "db_slaves[#{i}][#{key}]" unless slave[key]
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
utils.each_with_index do |util, i|
|
134
|
+
required_keys.each do |key|
|
135
|
+
missing_keys << "utils[#{i}][#{key}]" unless util[key]
|
136
|
+
end
|
116
137
|
end
|
117
138
|
end
|
118
|
-
end
|
119
139
|
|
120
|
-
|
121
|
-
|
122
|
-
|
140
|
+
if missing_keys.any?
|
141
|
+
raise "Invalid configuration - The following keys are missing from the configuration:\n#{missing_keys.join(",\n")}"
|
142
|
+
end
|
123
143
|
|
124
|
-
|
125
|
-
|
126
|
-
|
144
|
+
params = {
|
145
|
+
"cluster_configuration" => {
|
146
|
+
"configuration" => configuration
|
147
|
+
}
|
127
148
|
}
|
128
|
-
}
|
129
149
|
|
130
|
-
|
150
|
+
connection.requests.new(self.connection.boot_environment(params.merge("id" => self.id)).body["request"])
|
151
|
+
end
|
131
152
|
end
|
132
153
|
|
133
154
|
def save!
|
@@ -0,0 +1,72 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def blueprint_environment(params={})
|
4
|
+
id = params.delete("id")
|
5
|
+
url = params.delete("url")
|
6
|
+
|
7
|
+
request(
|
8
|
+
:body => params,
|
9
|
+
:method => :post,
|
10
|
+
:path => "environments/#{id}/blueprint",
|
11
|
+
:url => url,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def blueprint_environment(params={})
|
18
|
+
params = Cistern::Hash.stringify_keys(params)
|
19
|
+
id = params.delete("id")
|
20
|
+
environment = find(:environments, id)
|
21
|
+
blueprint_id = self.uuid
|
22
|
+
servers = self.data[:servers].values.select { |s| s["environment"] == url_for("/environments/#{id}") && s["deleted_at"].nil? }
|
23
|
+
volumes = servers.inject({}) do |hash,server|
|
24
|
+
hash.merge!(server["id"] => self.data[:volumes].values.select { |v| v["server"] == url_for("/servers/#{server["id"]}") })
|
25
|
+
hash
|
26
|
+
end
|
27
|
+
instances = {}
|
28
|
+
instances["apps"] = servers.select { |s| %w(app_master app solo).include?(s["role"]) }
|
29
|
+
instances["db_master"] = servers.select { |s| s["role"] == "db_master" }
|
30
|
+
instances["db_slaves"] = servers.select { |s| s["role"] == "db_slave" }
|
31
|
+
instances["utils"] = servers.select { |s| s["role"] == "util" }
|
32
|
+
|
33
|
+
%w(apps db_master db_slaves utils).each do |type|
|
34
|
+
mapped_types = instances[type].map do |server|
|
35
|
+
volume = volumes[server["id"]].first
|
36
|
+
mnt_volume = server["devices"].detect { |d| d["mount"] == "/mnt" }
|
37
|
+
{
|
38
|
+
"encrypted" => volume && volume["encrypted"],
|
39
|
+
"flavor" => server["flavor"]["id"],
|
40
|
+
"mnt_volume_size" => mnt_volume["size"],
|
41
|
+
"name" => server["name"],
|
42
|
+
"volume_iops" => volume["iops"],
|
43
|
+
"volume_size" => volume["size"]
|
44
|
+
}
|
45
|
+
end
|
46
|
+
instances["blueprint_#{type}"] = mapped_types
|
47
|
+
end
|
48
|
+
|
49
|
+
blueprint = {
|
50
|
+
"id" => blueprint_id,
|
51
|
+
"account" => environment["account"],
|
52
|
+
"environment" => url_for("/environments/#{id}"),
|
53
|
+
"created_at" => Time.now,
|
54
|
+
"updated_at" => Time.now,
|
55
|
+
"name" => params["name"],
|
56
|
+
"data" => {
|
57
|
+
"app_instances" => instances["blueprint_apps"],
|
58
|
+
"db_master" => instances["blueprint_db_master"],
|
59
|
+
"db_slaves" => instances["blueprint_db_slaves"],
|
60
|
+
"utils" => instances["blueprint_utils"],
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
self.data[:blueprints][blueprint_id] = blueprint
|
65
|
+
|
66
|
+
response(
|
67
|
+
:body => {"blueprint" => blueprint},
|
68
|
+
:status => 200,
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -13,6 +13,7 @@ class Ey::Core::Client
|
|
13
13
|
|
14
14
|
class Mock
|
15
15
|
def boot_environment(params={})
|
16
|
+
params = Cistern::Hash.stringify_keys(params)
|
16
17
|
id = params.delete("id")
|
17
18
|
configuration = params["cluster_configuration"]["configuration"]
|
18
19
|
request_id = self.uuid
|
@@ -20,22 +21,54 @@ class Ey::Core::Client
|
|
20
21
|
|
21
22
|
servers = {}
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
if blueprint_id = params["cluster_configuration"]["blueprint_id"]
|
25
|
+
blueprint = find(:blueprints, blueprint_id)
|
26
|
+
|
27
|
+
%w(app_instances db_master db_slaves utils).each do |type|
|
28
|
+
blueprint_data = blueprint["data"][type]
|
29
|
+
role = case type
|
30
|
+
when "app_instances" then "app"
|
31
|
+
when "db_master" then "db_master"
|
32
|
+
when "db_slaves" then "db_slave"
|
33
|
+
when "utils" then "util"
|
34
|
+
end
|
35
|
+
blueprint_data.each_with_index do |server_data,index|
|
36
|
+
role = "app_master" if type == 'app_instances' && index == 0
|
37
|
+
server = server_hash(role: role, environment: environment, flavor: server_data["flavor"]["id"], name: server_data["name"])
|
38
|
+
create_volume(server: server, size: server_data["volume_size"], iops: server_data["volume_iops"])
|
39
|
+
servers[server["id"]] = server
|
40
|
+
end
|
31
41
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
42
|
+
else
|
43
|
+
case configuration["type"]
|
44
|
+
when "solo"
|
45
|
+
server = server_hash(environment: environment)
|
35
46
|
servers[server["id"]] = server
|
47
|
+
when "cluster"
|
48
|
+
%w(app_master app db_master).each do |role|
|
49
|
+
server = server_hash(role: role, environment: environment)
|
50
|
+
servers[server["id"]] = server
|
51
|
+
volume_size, iops = if %w(app_master app).include?(role)
|
52
|
+
[configuration["apps"] ? configuration["apps"]["volume_size"] : 25, nil]
|
53
|
+
elsif %w(db_master db_slave).include?(role)
|
54
|
+
[configuration["db_master"] ? configuration["db_master"]["volume_size"] : 25, configuration["db_master"] ? configuration["db_master"]["iops"] : nil]
|
55
|
+
end
|
56
|
+
create_volume(server: server, volume_size: volume_size, iops: iops)
|
57
|
+
end
|
58
|
+
when "production-cluster"
|
59
|
+
%w(app_master app app db_master db_slave).each do |role|
|
60
|
+
server = server_hash(role: role, environment: environment)
|
61
|
+
servers[server["id"]] = server
|
62
|
+
volume_size, iops = if %w(app_master app).include?(role)
|
63
|
+
[configuration["apps"] ? configuration["apps"]["volume_size"] : 25, nil]
|
64
|
+
elsif %w(db_master db_slave).include?(role)
|
65
|
+
[configuration["db_master"] ? configuration["db_master"]["volume_size"] : 25, configuration["db_master"] ? configuration["db_master"]["iops"] : nil]
|
66
|
+
end
|
67
|
+
create_volume(server: server, size: volume_size, iops: iops)
|
68
|
+
end
|
69
|
+
when "custom"
|
70
|
+
raise "not implemented"
|
36
71
|
end
|
37
|
-
when "custom"
|
38
|
-
raise "not implemented"
|
39
72
|
end
|
40
73
|
|
41
74
|
self.data[:servers].merge!(servers)
|
@@ -65,7 +98,7 @@ class Ey::Core::Client
|
|
65
98
|
|
66
99
|
def server_hash(options={})
|
67
100
|
id = self.serial_id
|
68
|
-
flavor = options.delete(:flavor)
|
101
|
+
flavor = options.delete(:flavor) || "m3_medium"
|
69
102
|
role = options.delete(:role)
|
70
103
|
name = options.delete(:name)
|
71
104
|
environment = options.delete(:environment)
|
@@ -128,5 +161,19 @@ class Ey::Core::Client
|
|
128
161
|
{ "device" => "/dev/sdb", "name" => "ephemeral0", },
|
129
162
|
]
|
130
163
|
end
|
164
|
+
|
165
|
+
def create_volume(params={})
|
166
|
+
server = params[:server]
|
167
|
+
volume_size = params[:size]
|
168
|
+
volume_iops = params[:iops]
|
169
|
+
volume_id = self.serial_id
|
170
|
+
|
171
|
+
self.data[:volumes][volume_id] = {
|
172
|
+
"id" => volume_id,
|
173
|
+
"size" => volume_size,
|
174
|
+
"iops" => volume_iops,
|
175
|
+
"server" => url_for("/servers/#{server["id"]}")
|
176
|
+
}
|
177
|
+
end
|
131
178
|
end
|
132
179
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def destroy_blueprint(params={})
|
4
|
+
id = params.delete("id")
|
5
|
+
|
6
|
+
request(
|
7
|
+
:path => "blueprints/#{id}",
|
8
|
+
:method => :delete
|
9
|
+
)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Mock
|
14
|
+
def destroy_blueprint(params={})
|
15
|
+
blueprint = find(:blueprints, params["id"])
|
16
|
+
|
17
|
+
self.data[:blueprints].delete(blueprint["id"])
|
18
|
+
|
19
|
+
response(status: 204)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def get_blueprint(params={})
|
4
|
+
id = params.delete("id")
|
5
|
+
url = params.delete("url")
|
6
|
+
|
7
|
+
request(
|
8
|
+
:path => "blueprints/#{id}",
|
9
|
+
:url => url,
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
def get_blueprint(params={})
|
16
|
+
response(
|
17
|
+
:body => {"blueprint" => self.find(:blueprints, resource_identity(params))}
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def get_blueprints(params={})
|
4
|
+
query = Ey::Core.paging_parameters(params)
|
5
|
+
url = params.delete("url")
|
6
|
+
|
7
|
+
request(
|
8
|
+
:path => "/blueprints",
|
9
|
+
:params => params,
|
10
|
+
:query => query,
|
11
|
+
:url => url,
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class Mock
|
17
|
+
def get_blueprints(params={})
|
18
|
+
extract_url_params!(params)
|
19
|
+
|
20
|
+
headers, blueprints_page = search_and_page(params, :blueprints, search_keys: %w[account environment environment_id name])
|
21
|
+
|
22
|
+
response(
|
23
|
+
:body => {"blueprints" => blueprints_page},
|
24
|
+
:status => 200,
|
25
|
+
:headers => headers,
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def update_blueprint(params={})
|
4
|
+
id = params.delete("id")
|
5
|
+
|
6
|
+
request(
|
7
|
+
:path => "blueprints/#{id}",
|
8
|
+
:body => params,
|
9
|
+
:method => :put
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
def update_blueprint(params={})
|
16
|
+
params = Cistern::Hash.stringify_keys(params)
|
17
|
+
blueprint_params = params["blueprint"]
|
18
|
+
blueprint = find(:blueprints, params["id"])
|
19
|
+
|
20
|
+
blueprint["name"] = blueprint_params["name"]
|
21
|
+
self.data[:blueprints][blueprint["id"]] = blueprint
|
22
|
+
|
23
|
+
response(
|
24
|
+
:body => {"blueprint" => blueprint},
|
25
|
+
:status => 200,
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/ey-core/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'as a user' do
|
4
|
+
let!(:client) { create_client }
|
5
|
+
|
6
|
+
context "with a blueprint" do
|
7
|
+
let!(:account) { create_account(client: client) }
|
8
|
+
let!(:provider) { create_provider(account: account) }
|
9
|
+
let!(:app) { create_application(account: account, client: client) }
|
10
|
+
let!(:environment) { create_environment(account: account, app: app, environment: { name: SecureRandom.hex(3)}, configuration: { type: "production"}) }
|
11
|
+
let!(:blueprint) { environment.save_blueprint("name" => SecureRandom.hex(3)) }
|
12
|
+
|
13
|
+
it "changes the name" do
|
14
|
+
name = SecureRandom.hex(4)
|
15
|
+
expect {
|
16
|
+
blueprint.update(name: name)
|
17
|
+
}.to change { blueprint.reload.name }.to(name)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "deletes the blueprint" do
|
21
|
+
expect {
|
22
|
+
blueprint.destroy
|
23
|
+
}.to change { blueprint.reload }.to(nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "boots an environment from a blueprint" do
|
27
|
+
new_environment = create_environment(account: account, app: app, environment: {name: SecureRandom.hex(5)}, boot: false)
|
28
|
+
|
29
|
+
expect {
|
30
|
+
new_environment.boot("blueprint_id" => blueprint.id)
|
31
|
+
}.to change { new_environment.servers.count }.to(5)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/environments_spec.rb
CHANGED
@@ -68,7 +68,22 @@ describe 'as a user' do
|
|
68
68
|
|
69
69
|
context "with an environment" do
|
70
70
|
let!(:name) { Faker::Name.first_name }
|
71
|
-
let!(:environment) { create_environment(account: account, application: app, environment: {name: name}) }
|
71
|
+
let!(:environment) { create_environment(account: account, application: app, environment: {name: name}, configuration: {type: "production"}) }
|
72
|
+
|
73
|
+
it "has the right number of servers" do
|
74
|
+
expect(environment.servers.count).to eq(5)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "creates a blueprint" do
|
78
|
+
blueprint = nil
|
79
|
+
expect {
|
80
|
+
blueprint = environment.save_blueprint("name" => SecureRandom.hex(3))
|
81
|
+
}.to change { environment.blueprints.count }.by(1)
|
82
|
+
|
83
|
+
expect(blueprint.data["app_instances"].count).to eq(3)
|
84
|
+
expect(blueprint.data["db_master"].count).to eq(1)
|
85
|
+
expect(blueprint.data["db_slaves"].count).to eq(1)
|
86
|
+
end
|
72
87
|
|
73
88
|
it "applies main" do
|
74
89
|
expect(environment.apply.ready!).to be_successful
|
@@ -111,6 +111,7 @@ module ResourceHelper
|
|
111
111
|
application = options[:application] || create_application(account: account)
|
112
112
|
database_service = options[:database_service]
|
113
113
|
configuration = Cistern::Hash.stringify_keys(options[:configuration] || {})
|
114
|
+
configuration["type"] = "production-cluster" if configuration["type"] == "production"
|
114
115
|
configuration["type"] ||= "solo"
|
115
116
|
environment[:name] ||= options.fetch(:name, SecureRandom.hex(3))
|
116
117
|
environment[:region] ||= "us-west-2"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ey-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- lib/ey-core/collections/application_deployments.rb
|
146
146
|
- lib/ey-core/collections/applications.rb
|
147
147
|
- lib/ey-core/collections/backup_files.rb
|
148
|
+
- lib/ey-core/collections/blueprints.rb
|
148
149
|
- lib/ey-core/collections/components.rb
|
149
150
|
- lib/ey-core/collections/contacts.rb
|
150
151
|
- lib/ey-core/collections/costs.rb
|
@@ -207,6 +208,7 @@ files:
|
|
207
208
|
- lib/ey-core/models/application_deployment.rb
|
208
209
|
- lib/ey-core/models/backup_file.rb
|
209
210
|
- lib/ey-core/models/billing.rb
|
211
|
+
- lib/ey-core/models/blueprint.rb
|
210
212
|
- lib/ey-core/models/component.rb
|
211
213
|
- lib/ey-core/models/contact.rb
|
212
214
|
- lib/ey-core/models/cost.rb
|
@@ -256,6 +258,7 @@ files:
|
|
256
258
|
- lib/ey-core/requests/apply_server_updates.rb
|
257
259
|
- lib/ey-core/requests/attach_address.rb
|
258
260
|
- lib/ey-core/requests/authorized_channel.rb
|
261
|
+
- lib/ey-core/requests/blueprint_environment.rb
|
259
262
|
- lib/ey-core/requests/boot_environment.rb
|
260
263
|
- lib/ey-core/requests/bootstrap_logical_database.rb
|
261
264
|
- lib/ey-core/requests/cancel_account.rb
|
@@ -293,6 +296,7 @@ files:
|
|
293
296
|
- lib/ey-core/requests/deploy_environment_application.rb
|
294
297
|
- lib/ey-core/requests/deprovision_environment.rb
|
295
298
|
- lib/ey-core/requests/destroy_addon.rb
|
299
|
+
- lib/ey-core/requests/destroy_blueprint.rb
|
296
300
|
- lib/ey-core/requests/destroy_database_server.rb
|
297
301
|
- lib/ey-core/requests/destroy_database_server_snapshot.rb
|
298
302
|
- lib/ey-core/requests/destroy_database_service.rb
|
@@ -336,6 +340,8 @@ files:
|
|
336
340
|
- lib/ey-core/requests/get_backup_file.rb
|
337
341
|
- lib/ey-core/requests/get_backup_files.rb
|
338
342
|
- lib/ey-core/requests/get_billing.rb
|
343
|
+
- lib/ey-core/requests/get_blueprint.rb
|
344
|
+
- lib/ey-core/requests/get_blueprints.rb
|
339
345
|
- lib/ey-core/requests/get_component.rb
|
340
346
|
- lib/ey-core/requests/get_components.rb
|
341
347
|
- lib/ey-core/requests/get_contacts.rb
|
@@ -427,6 +433,7 @@ files:
|
|
427
433
|
- lib/ey-core/requests/update_alert.rb
|
428
434
|
- lib/ey-core/requests/update_application_archive.rb
|
429
435
|
- lib/ey-core/requests/update_billing.rb
|
436
|
+
- lib/ey-core/requests/update_blueprint.rb
|
430
437
|
- lib/ey-core/requests/update_connector.rb
|
431
438
|
- lib/ey-core/requests/update_membership.rb
|
432
439
|
- lib/ey-core/requests/update_server.rb
|
@@ -447,6 +454,7 @@ files:
|
|
447
454
|
- spec/application_archives_spec.rb
|
448
455
|
- spec/applications_spec.rb
|
449
456
|
- spec/billing_spec.rb
|
457
|
+
- spec/blueprints_spec.rb
|
450
458
|
- spec/client_spec.rb
|
451
459
|
- spec/collection_spec.rb
|
452
460
|
- spec/costs_spec.rb
|
@@ -514,7 +522,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
514
522
|
version: '0'
|
515
523
|
requirements: []
|
516
524
|
rubyforge_project:
|
517
|
-
rubygems_version: 2.
|
525
|
+
rubygems_version: 2.5.1
|
518
526
|
signing_key:
|
519
527
|
specification_version: 4
|
520
528
|
summary: Client library providing real and mock functionality for accessing Engine
|
@@ -529,6 +537,7 @@ test_files:
|
|
529
537
|
- spec/application_archives_spec.rb
|
530
538
|
- spec/applications_spec.rb
|
531
539
|
- spec/billing_spec.rb
|
540
|
+
- spec/blueprints_spec.rb
|
532
541
|
- spec/client_spec.rb
|
533
542
|
- spec/collection_spec.rb
|
534
543
|
- spec/costs_spec.rb
|