ey-core 3.0.4 → 3.0.5
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.
- checksums.yaml +4 -4
- data/lib/ey-core/cli.rb +10 -2
- data/lib/ey-core/client.rb +2 -1
- data/lib/ey-core/models/environment.rb +21 -15
- data/lib/ey-core/models/log.rb +11 -0
- data/lib/ey-core/models/request.rb +8 -3
- data/lib/ey-core/models/server.rb +9 -0
- data/lib/ey-core/requests/update_environment.rb +17 -0
- data/lib/ey-core/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dc4da29698ad9bb948ca751e854c4efb134aab9
|
4
|
+
data.tar.gz: 89e4e06dfeee04459768395059a892ce38865f2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bea713bee5a23c8e5371eac1c4138e4d6cc240fb9bf96ba4995c84e923c01ec1fbdc3fe0100827d4182578bca59feb894301d76d867482d25e7def36e8812ca
|
7
|
+
data.tar.gz: af636f6e784f5371f79e9f9ddd300a171cfa76c6ee1ac976d81d0b163850e307a36c4063ef5fe642f8b4cd8278bab42a810c5b84aa262f88d0aa73529eebbd02
|
data/lib/ey-core/cli.rb
CHANGED
@@ -45,6 +45,10 @@ class Ey::Core::Cli
|
|
45
45
|
options[:logger] = v ? Logger.new(STDOUT) : Logger.new(nil)
|
46
46
|
end
|
47
47
|
|
48
|
+
opts.on("-e", "--execute-command [COMMAND]", "Execute Command") do |c|
|
49
|
+
@execute_command = c
|
50
|
+
end
|
51
|
+
|
48
52
|
opts.separator ""
|
49
53
|
opts.separator "Common options:"
|
50
54
|
|
@@ -74,8 +78,12 @@ class Ey::Core::Cli
|
|
74
78
|
end
|
75
79
|
|
76
80
|
def console
|
77
|
-
|
78
|
-
|
81
|
+
if @execute_command
|
82
|
+
@client.instance_eval(@execute_command)
|
83
|
+
else
|
84
|
+
Pry.config.prompt = proc { |obj, nest_level, _| "ey-core:> " }
|
85
|
+
@client.pry
|
86
|
+
end
|
79
87
|
end
|
80
88
|
|
81
89
|
def show
|
data/lib/ey-core/client.rb
CHANGED
@@ -292,6 +292,7 @@ class Ey::Core::Client < Cistern::Service
|
|
292
292
|
request :update_application_archive
|
293
293
|
request :update_billing
|
294
294
|
request :update_blueprint
|
295
|
+
request :update_environment
|
295
296
|
request :update_membership
|
296
297
|
request :update_server
|
297
298
|
request :update_ssl_certificate
|
@@ -334,7 +335,7 @@ class Ey::Core::Client < Cistern::Service
|
|
334
335
|
|
335
336
|
unless @authentication == :none
|
336
337
|
if !@auth_id && !@auth_key && !@token
|
337
|
-
raise "Missing token. Use Ey::Core::Client.new(token: mytoken) or add \"'#{@url}': mytoken\" to your ~/.ey-core file" unless @token
|
338
|
+
raise "Missing token. Use Ey::Core::Client.new(token: mytoken) or add \"'#{@url}': mytoken\" to your ~/.ey-core file (see: https://cloud.engineyard.com/cli)" unless @token
|
338
339
|
elsif options[:token] || (@token && !@auth_id) # token was explicitly provided
|
339
340
|
@authentication = :token
|
340
341
|
else
|
@@ -51,8 +51,8 @@ class Ey::Core::Client::Environment < Ey::Core::Model
|
|
51
51
|
connection.requests.new(response.body["request"])
|
52
52
|
end
|
53
53
|
|
54
|
-
def apply(type="main")
|
55
|
-
connection.requests.new(self.connection.apply_environment_updates("id" => self.id, "type" => type).body["request"])
|
54
|
+
def apply(type="main", data={})
|
55
|
+
connection.requests.new(self.connection.apply_environment_updates("id" => self.id, "type" => type, "data" => data).body["request"])
|
56
56
|
end
|
57
57
|
|
58
58
|
def deprovision
|
@@ -152,23 +152,29 @@ class Ey::Core::Client::Environment < Ey::Core::Model
|
|
152
152
|
end
|
153
153
|
|
154
154
|
def save!
|
155
|
-
|
155
|
+
if new_record?
|
156
|
+
requires :application_id, :account_id, :region
|
156
157
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
158
|
+
params = {
|
159
|
+
"url" => self.collection.url,
|
160
|
+
"account" => self.account_id,
|
161
|
+
"environment" => {
|
162
|
+
"name" => self.name,
|
163
|
+
"application_id" => self.application_id,
|
164
|
+
"region" => self.region,
|
165
|
+
},
|
166
|
+
}
|
166
167
|
|
167
|
-
|
168
|
+
params["environment"].merge!("database_service" => self.database_service.id) if self.database_service
|
168
169
|
|
169
|
-
if new_record?
|
170
170
|
merge_attributes(self.connection.create_environment(params).body["environment"])
|
171
|
-
else
|
171
|
+
else
|
172
|
+
requires :identity
|
173
|
+
attributes = Cistern::Hash.slice(Cistern::Hash.stringify_keys(self.attributes), "nane", "release_label")
|
174
|
+
connection.update_environment(
|
175
|
+
"id" => self.identity,
|
176
|
+
"environment" => attributes,
|
177
|
+
)
|
172
178
|
end
|
173
179
|
end
|
174
180
|
end
|
data/lib/ey-core/models/log.rb
CHANGED
@@ -3,6 +3,7 @@ class Ey::Core::Client::Log < Ey::Core::Model
|
|
3
3
|
|
4
4
|
identity :id
|
5
5
|
|
6
|
+
attribute :created_at
|
6
7
|
attribute :filename
|
7
8
|
attribute :mime_type
|
8
9
|
attribute :download_url
|
@@ -30,4 +31,14 @@ class Ey::Core::Client::Log < Ey::Core::Model
|
|
30
31
|
|
31
32
|
merge_attributes(self.connection.create_log(params).body["log"])
|
32
33
|
end
|
34
|
+
|
35
|
+
def contents
|
36
|
+
body = Faraday.get(download_url).body
|
37
|
+
if filename.match(/\.gz$/)
|
38
|
+
Zlib::GzipReader.new(StringIO.new(body, "rb")).read
|
39
|
+
else
|
40
|
+
body
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
33
44
|
end
|
@@ -21,9 +21,14 @@ class Ey::Core::Client::Request < Ey::Core::Model
|
|
21
21
|
merge_attributes(connection.request_callback("url" => self.callback_url).body["request"])
|
22
22
|
end
|
23
23
|
|
24
|
-
def ready!(timeout = self.service.timeout, interval = self.service.poll_interval)
|
25
|
-
wait_for!(timeout, interval)
|
26
|
-
|
24
|
+
def ready!(timeout = self.service.timeout, interval = self.service.poll_interval, raise_on_failure = true, &block)
|
25
|
+
wait_for!(timeout, interval) do
|
26
|
+
yield self if block_given?
|
27
|
+
ready?
|
28
|
+
end
|
29
|
+
if raise_on_failure && !successful?
|
30
|
+
raise Ey::Core::RequestFailure.new(self)
|
31
|
+
end
|
27
32
|
self
|
28
33
|
end
|
29
34
|
|
@@ -33,6 +33,7 @@ class Ey::Core::Client::Server < Ey::Core::Model
|
|
33
33
|
has_many :volumes
|
34
34
|
has_many :events, key: :server_events
|
35
35
|
has_many :firewalls
|
36
|
+
has_many :logs
|
36
37
|
|
37
38
|
attr_accessor :mnt_volume_size, :volume_size, :iops, :snapshot_id
|
38
39
|
|
@@ -42,6 +43,14 @@ class Ey::Core::Client::Server < Ey::Core::Model
|
|
42
43
|
connection.requests.new(self.connection.apply_server_updates("id" => self.identity, "type" => type).body["request"])
|
43
44
|
end
|
44
45
|
|
46
|
+
def latest_main_log
|
47
|
+
logs.select{|l| l.filename.match(/main/)}.sort_by(&:created_at).last
|
48
|
+
end
|
49
|
+
|
50
|
+
def latest_custom_log
|
51
|
+
logs.select{|l| l.filename.match(/custom/)}.sort_by(&:created_at).last
|
52
|
+
end
|
53
|
+
|
45
54
|
def reboot
|
46
55
|
requires :identity
|
47
56
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Ey::Core::Client
|
2
|
+
class Real
|
3
|
+
def update_environment(params={})
|
4
|
+
request(
|
5
|
+
:method => :put,
|
6
|
+
:path => "/environments/#{params.fetch("id")}",
|
7
|
+
:body => {"environment" => params.fetch("environment")},
|
8
|
+
)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class Mock
|
13
|
+
def update_environment(params={})
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/ey-core/version.rb
CHANGED
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.5
|
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-05-
|
11
|
+
date: 2016-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -435,6 +435,7 @@ files:
|
|
435
435
|
- lib/ey-core/requests/update_billing.rb
|
436
436
|
- lib/ey-core/requests/update_blueprint.rb
|
437
437
|
- lib/ey-core/requests/update_connector.rb
|
438
|
+
- lib/ey-core/requests/update_environment.rb
|
438
439
|
- lib/ey-core/requests/update_membership.rb
|
439
440
|
- lib/ey-core/requests/update_server.rb
|
440
441
|
- lib/ey-core/requests/update_ssl_certificate.rb
|
@@ -522,7 +523,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
522
523
|
version: '0'
|
523
524
|
requirements: []
|
524
525
|
rubyforge_project:
|
525
|
-
rubygems_version: 2.5
|
526
|
+
rubygems_version: 2.4.5
|
526
527
|
signing_key:
|
527
528
|
specification_version: 4
|
528
529
|
summary: Client library providing real and mock functionality for accessing Engine
|