docker_cloud 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59c2aefec9011edee7b419eff4d029878d02a2ce
4
- data.tar.gz: 1c1e8e87a55587968b446d21e8d692cb748ec82a
3
+ metadata.gz: 319b4a0aec23043751f0b6188881d0b955bc72e8
4
+ data.tar.gz: 2f8bd36bf99fd3a8360a68f04578b76306cb5dc7
5
5
  SHA512:
6
- metadata.gz: 16fd776a797fa45301fb0d48b04421bf969be06d4db2b07b0c04df84eb16bb4ca7d539a18f5cb292f7e43f4d0e18428bbd8b75b26c91328cf96783acc2ae8c94
7
- data.tar.gz: 6434be0c98ded603d0c0a472cb1eeb38131f4faab64d1176b81a2a7017922d92ecddbd44fbdd4589883293449f0c2c9c5cc298e8cb0fdf0244c6578db7f8b9a0
6
+ metadata.gz: 8fd869a3c22b4b1cf80a8fd286e93b27dcc43ce88ddc377600f239fc84985bf1afc084f79d74214ae1bb720bfb989fd047082f06af19761b57d1b5df240bba1a
7
+ data.tar.gz: b1c18bc6f274743a20518c8c559c5d7e1eaae5cee9ebc7f2d62d948c6459a3204ef71c9bfe9038ad9e8d52fe3f9fc2ad5ab717755adfd9921a9342d7bcfbf395
@@ -35,7 +35,7 @@ This code of conduct applies both within project spaces and in public spaces
35
35
  when an individual is representing the project or its community.
36
36
 
37
37
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at tullo_jillian@bah.com. All
38
+ reported by contacting a project maintainer at jillian.tullo@gmail.com. All
39
39
  complaints will be reviewed and investigated and will result in a response that
40
40
  is deemed necessary and appropriate to the circumstances. Maintainers are
41
41
  obligated to maintain confidentiality with regard to the reporter of an
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 jillianntulloADM
3
+ Copyright (c) 2016 Jillian Tullo
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,8 @@
1
+ # helpers
2
+ require 'docker_cloud/helpers/services'
3
+ require 'docker_cloud/helpers/api'
4
+
1
5
  # types
2
- require 'docker_cloud/helpers'
3
6
  require 'docker_cloud/type'
4
7
  require 'docker_cloud/availability_zone'
5
8
  require 'docker_cloud/version'
@@ -2,7 +2,7 @@ require 'rest-client'
2
2
 
3
3
  module DockerCloud
4
4
  class API
5
- include DockerCloud::Helpers
5
+ include DockerCloud::Helpers::API
6
6
  attr_reader :headers, :type, :client
7
7
 
8
8
  BASE_API_PATH = 'https://cloud.docker.com/api'.freeze
@@ -32,7 +32,7 @@ module DockerCloud
32
32
  end
33
33
 
34
34
  def http_patch(path, content = {})
35
- response = RestClient.patch(url(path), content.to_json, headers)
35
+ response = RestClient.patch(url("#{path}/"), content.to_json, headers)
36
36
  parse(response)
37
37
  end
38
38
 
@@ -12,27 +12,31 @@ module DockerCloud
12
12
  end
13
13
 
14
14
  def get(uuid)
15
- http_get(resource_url(uuid))
15
+ response = http_get(resource_url(uuid))
16
16
  format_object(response, TYPE)
17
17
  end
18
18
 
19
19
  def start(uuid)
20
20
  url = "#{uuid}/start/"
21
- http_post(resource_url(url))
21
+ response = http_post(resource_url(url))
22
+ format_object(response, TYPE)
22
23
  end
23
24
 
24
25
  def stop(uuid)
25
26
  url = "#{uuid}/stop/"
26
- http_post(resource_url(url))
27
+ response = http_post(resource_url(url))
28
+ format_object(response, TYPE)
27
29
  end
28
30
 
29
31
  def logs(uuid)
30
32
  url = "#{uuid}/logs/"
31
- http_get(resource_url(url))
33
+ response = http_get(resource_url(url))
34
+ format_object(response, TYPE)
32
35
  end
33
36
 
34
37
  def terminate(uuid)
35
- http_terminate(resource_url(uuid))
38
+ response = http_delete(resource_url(uuid))
39
+ format_object(response, TYPE)
36
40
  end
37
41
  end
38
42
  end
@@ -27,7 +27,7 @@ module DockerCloud
27
27
  end
28
28
 
29
29
  def delete(name, user, image)
30
- url = "#{name}/#{user}/#{image}"
30
+ url = "#{name}/#{user}/#{image}/"
31
31
  http_delete(resource_url(url))
32
32
  end
33
33
  end
@@ -17,11 +17,19 @@ module DockerCloud
17
17
  end
18
18
 
19
19
  def deploy(uuid)
20
- http_post(resource_url("#{uuid}/deploy"))
20
+ http_post(resource_url("#{uuid}/deploy/"))
21
21
  end
22
22
 
23
23
  def terminate(uuid)
24
24
  http_delete(resource_url(uuid))
25
25
  end
26
+
27
+ def health_check(uuid)
28
+ http_post(resource_url("#{uuid}/health-check/"))
29
+ end
30
+
31
+ def docker_upgrade(uuid)
32
+ http_post(resource_url("#{uuid}/docker-upgrade/"))
33
+ end
26
34
  end
27
35
  end
@@ -36,7 +36,7 @@ module DockerCloud
36
36
  end
37
37
 
38
38
  def deploy(uuid)
39
- http_post(resource_url("#{uuid}/deploy"))
39
+ http_post(resource_url("#{uuid}/deploy/"))
40
40
  end
41
41
 
42
42
  def terminate(uuid)
@@ -15,7 +15,7 @@ module DockerCloud
15
15
 
16
16
  # Returns the details of a specific NodeType
17
17
  def get(provider_name, node_type_name)
18
- name = "#{provider_name}/#{node_type_name}"
18
+ name = "#{provider_name}/#{node_type_name}/"
19
19
  response = http_get(resource_url(name))
20
20
  format_object(response, TYPE)
21
21
  end
@@ -22,7 +22,7 @@ module DockerCloud
22
22
  end
23
23
 
24
24
  def logs(uuid)
25
- url = "#{uuid}/logs"
25
+ url = "#{uuid}/logs/"
26
26
  http_get(resource_url(url))
27
27
  end
28
28
 
@@ -33,21 +33,25 @@ module DockerCloud
33
33
 
34
34
  def start(uuid)
35
35
  url = "#{uuid}/start/"
36
- http_post(resource_url(url))
36
+ response = http_post(resource_url(url))
37
+ format_object(response, TYPE)
37
38
  end
38
39
 
39
40
  def stop(uuid)
40
41
  url = "#{uuid}/stop/"
41
- http_post(resource_url(url))
42
+ response = http_post(resource_url(url))
43
+ format_object(response, TYPE)
42
44
  end
43
45
 
44
46
  def redeploy(uuid)
45
47
  url = "#{uuid}/redeploy/"
46
- http_post(resource_url(url))
48
+ response = http_post(resource_url(url))
49
+ format_object(response, TYPE)
47
50
  end
48
51
 
49
52
  def terminate(uuid)
50
- http_delete(resource_url(uuid))
53
+ response = http_delete(resource_url(uuid))
54
+ format_object(response, TYPE)
51
55
  end
52
56
  end
53
57
  end
@@ -32,17 +32,17 @@ module DockerCloud
32
32
  end
33
33
 
34
34
  def stop(uuid)
35
- url = "#{uuid}/stop"
35
+ url = "#{uuid}/stop/"
36
36
  http_post(resource_url(url))
37
37
  end
38
38
 
39
39
  def start(uuid)
40
- url = "#{uuid}/start"
40
+ url = "#{uuid}/start/"
41
41
  http_post(resource_url(url))
42
42
  end
43
43
 
44
44
  def redeploy(uuid)
45
- url = "#{uuid}/redeploy"
45
+ url = "#{uuid}/redeploy/"
46
46
  http_post(resource_url(url))
47
47
  end
48
48
 
@@ -1,5 +1,7 @@
1
1
  module DockerCloud
2
2
  class Container < DockerCloud::Type
3
+ include DockerCloud::Helpers::Services
4
+
3
5
  def resource_uri
4
6
  info[:resource_uri]
5
7
  end
@@ -161,10 +163,6 @@ module DockerCloud
161
163
  info[:autodestroy]
162
164
  end
163
165
 
164
- def roles
165
- info[:roles]
166
- end
167
-
168
166
  def linked_to_container
169
167
  info[:linked_to_container]
170
168
  end
@@ -173,10 +171,6 @@ module DockerCloud
173
171
  info[:link_variables]
174
172
  end
175
173
 
176
- def privileged
177
- info[privileged]
178
- end
179
-
180
174
  def read_only
181
175
  info[:read_only]
182
176
  end
@@ -193,12 +187,14 @@ module DockerCloud
193
187
  info[:pid]
194
188
  end
195
189
 
196
- def container_ports
197
- @container_ports ||= ContainerPorts.new(info[:container_ports])
198
- end
199
-
200
190
  def node
201
191
  @node ||= client.nodes.get_from_uri(info[:node]) unless info[:node].nil?
202
192
  end
193
+
194
+ private
195
+
196
+ def api
197
+ client.containers
198
+ end
203
199
  end
204
200
  end
@@ -0,0 +1,20 @@
1
+ module DockerCloud
2
+ module Helpers
3
+ module API
4
+ private
5
+
6
+ def format_object(response, type)
7
+ type = Object.const_get "DockerCloud::#{type}"
8
+ if response.is_a?(Array)
9
+ formatted = []
10
+ response.each do |obj|
11
+ formatted.push(type.new(obj, client))
12
+ end
13
+ else
14
+ formatted = type.new(response, client)
15
+ end
16
+ formatted
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,60 @@
1
+ module DockerCloud
2
+ module Helpers
3
+ module Services
4
+ # This class serves both Containers and Services
5
+
6
+ class ContainerPorts
7
+ attr_accessor :protocol, :inner_port, :outer_port, :port_name,
8
+ :uri_protocol, :endpoint_uri, :published
9
+
10
+ def initialize(container_ports)
11
+ @protocol = container_ports[:protocol]
12
+ @inner_port = container_ports[:inner_port]
13
+ @outer_port = container_ports[:outer_port]
14
+ @port_name = container_ports[:outer_port]
15
+ @uri_protocol = container_ports[:uri_protocol]
16
+ @endpoint_uri = container_ports[:endpoint_uri]
17
+ @published = container_ports[:published]
18
+ end
19
+ end
20
+
21
+ def start
22
+ api.start(uuid)
23
+ end
24
+
25
+ def stop
26
+ api.stop(uuid)
27
+ end
28
+
29
+ def redeploy
30
+ api.redeploy(uuid)
31
+ end
32
+
33
+ def terminate
34
+ api.terminate(uuid)
35
+ end
36
+
37
+ def update(params)
38
+ api.update(uuid, params)
39
+ end
40
+
41
+ def roles
42
+ info[:roles]
43
+ end
44
+
45
+ def privileged
46
+ info[:privileged]
47
+ end
48
+
49
+ def container_ports
50
+ if @container_ports.nil? && !info[:container_ports].nil?
51
+ @container_ports = []
52
+ info[:container_ports].each do |port|
53
+ @container_ports.push(ContainerPorts.new(port))
54
+ end
55
+ end
56
+ @container_ports
57
+ end
58
+ end
59
+ end
60
+ end
@@ -95,5 +95,23 @@ module DockerCloud
95
95
  @memory = response[:memory]
96
96
  end
97
97
  end
98
+
99
+ def health_check
100
+ api.health_check(uuid)
101
+ end
102
+
103
+ def terminate
104
+ api.terminate(uuid)
105
+ end
106
+
107
+ def docker_upgrade
108
+ api.docker_upgrade(uuid)
109
+ end
110
+
111
+ private
112
+
113
+ def api
114
+ client.nodes
115
+ end
98
116
  end
99
117
  end
@@ -22,7 +22,7 @@ module DockerCloud
22
22
  end
23
23
 
24
24
  def nodes
25
- if @nodes.nil?
25
+ if @nodes.nil? && !info[:nodes].nil?
26
26
  @nodes = []
27
27
  info[:nodes].each do |node_uri|
28
28
  @nodes.push(client.nodes.get_from_uri(node_uri))
@@ -63,5 +63,23 @@ module DockerCloud
63
63
  def nickname
64
64
  info[:nickname]
65
65
  end
66
+
67
+ def deploy
68
+ api.deploy(uuid)
69
+ end
70
+
71
+ def terminate
72
+ api.terminate(uuid)
73
+ end
74
+
75
+ def update(params)
76
+ api.update(uuid, params)
77
+ end
78
+
79
+ private
80
+
81
+ def api
82
+ client.node_clusters
83
+ end
66
84
  end
67
85
  end
@@ -1,13 +1,15 @@
1
1
  module DockerCloud
2
2
  class Service < DockerCloud::Type
3
- def resource_uri
4
- info[:resource_uri]
5
- end
3
+ include DockerCloud::Helpers::Services
6
4
 
7
5
  def image_name
8
6
  info[:image_name]
9
7
  end
10
8
 
9
+ def image
10
+ @image ||= client.images.get_from_uri(info[:image_tag]) unless info[:image_tag].nil?
11
+ end
12
+
11
13
  def name
12
14
  info[:name]
13
15
  end
@@ -71,19 +73,15 @@ module DockerCloud
71
73
 
72
74
  # def containers; info[:containers]; end
73
75
  def containers
74
- if @containers.nil?
76
+ if @containers.nil? && !info[:containers].nil?
75
77
  @containers = []
76
78
  info[:containers].each do |uri|
77
- @containers.push(client.containers.get_by_uri(uri))
79
+ @containers.push(client.containers.get_from_uri(uri))
78
80
  end
79
81
  end
80
82
  @containers
81
83
  end
82
84
 
83
- def container_ports
84
- @container_ports ||= ContainerPorts.new(info[:container_ports])
85
- end
86
-
87
85
  def container_env_vars
88
86
  info[:container_envvars]
89
87
  end
@@ -200,10 +198,6 @@ module DockerCloud
200
198
  info[:autodestroy]
201
199
  end
202
200
 
203
- def roles
204
- info[:roles]
205
- end
206
-
207
201
  def link_variables
208
202
  info[:link_variables]
209
203
  end
@@ -231,5 +225,11 @@ module DockerCloud
231
225
  def nickname
232
226
  info[:nickname]
233
227
  end
228
+
229
+ private
230
+
231
+ def api
232
+ client.services
233
+ end
234
234
  end
235
235
  end
@@ -1,9 +1,5 @@
1
1
  module DockerCloud
2
2
  class Stack < DockerCloud::Type
3
- def resource_uri
4
- info[:uui]
5
- end
6
-
7
3
  def name
8
4
  info[:name]
9
5
  end
@@ -27,7 +23,7 @@ module DockerCloud
27
23
  @services
28
24
  end
29
25
 
30
- def deployed_date
26
+ def deployed_datevers
31
27
  info[:deployed_datetime]
32
28
  end
33
29
 
@@ -38,5 +34,35 @@ module DockerCloud
38
34
  def nickname
39
35
  info[:nickname]
40
36
  end
37
+
38
+ def start
39
+ api.start(uuid)
40
+ end
41
+
42
+ def redeploy
43
+ api.redeploy(uuid)
44
+ end
45
+
46
+ def terminate
47
+ api.terminate(uuid)
48
+ end
49
+
50
+ def stop
51
+ api.stop(uuid)
52
+ end
53
+
54
+ def update(params)
55
+ api.update(uuid, params)
56
+ end
57
+
58
+ def export
59
+ api.export(uuid)
60
+ end
61
+
62
+ private
63
+
64
+ def api
65
+ client.stacks
66
+ end
41
67
  end
42
68
  end
@@ -1,7 +1,6 @@
1
1
  module DockerCloud
2
2
  class Type
3
- include DockerCloud::Helpers
4
- attr_accessor :uuid, :resource_uri
3
+ attr_reader :info
5
4
 
6
5
  def initialize(response, client)
7
6
  @info = response
@@ -10,10 +9,21 @@ module DockerCloud
10
9
  @resource_uri = info[:uuid]
11
10
  end
12
11
 
12
+ def reload
13
+ refreshed = api.get_from_uri(resource_uri)
14
+ @info = refreshed.info
15
+ end
16
+
17
+ def uuid
18
+ info[:uuid]
19
+ end
20
+
21
+ def resource_uri
22
+ info[:resource_uri]
23
+ end
24
+
13
25
  private
14
26
 
15
27
  attr_reader :client
16
-
17
- attr_reader :info
18
28
  end
19
29
  end
@@ -1,3 +1,3 @@
1
1
  module DockerCloud
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jillian Tullo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2016-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -155,7 +155,8 @@ files:
155
155
  - lib/docker_cloud/availability_zone.rb
156
156
  - lib/docker_cloud/container.rb
157
157
  - lib/docker_cloud/external_repository.rb
158
- - lib/docker_cloud/helpers.rb
158
+ - lib/docker_cloud/helpers/api.rb
159
+ - lib/docker_cloud/helpers/services.rb
159
160
  - lib/docker_cloud/node.rb
160
161
  - lib/docker_cloud/node_cluster.rb
161
162
  - lib/docker_cloud/node_type.rb
@@ -1,33 +0,0 @@
1
- module DockerCloud
2
- module Helpers
3
- class ContainerPorts
4
- attr_accessor :protocol, :inner_port, :outer_port, :port_name,
5
- :uri_protocol, :endpoint_uri, :published
6
-
7
- def initialize(container_ports)
8
- @protocol = container_ports[:protocol]
9
- @inner_port = container_ports[:inner_port]
10
- @outer_port = container_ports[:outer_port]
11
- @port_name = container_ports[:outer_port]
12
- @uri_protocol = container_ports[:uri_protocol]
13
- @endpoint_uri = container_ports[:endpoint_uri]
14
- @published = container_ports[:published]
15
- end
16
- end
17
-
18
- private
19
-
20
- def format_object(response, type)
21
- type = Object.const_get "DockerCloud::#{type}"
22
- if response.is_a?(Array)
23
- formatted = []
24
- response.each do |obj|
25
- formatted.push(type.new(obj, client))
26
- end
27
- else
28
- formatted = type.new(response, client)
29
- end
30
- formatted
31
- end
32
- end
33
- end