Skip to content

Commit 11cae2a

Browse files
committed
Merge branch 'master' into tutorial-docs
2 parents a27500b + 2f6ea93 commit 11cae2a

54 files changed

Lines changed: 283 additions & 401 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ services:
1616
- rabbitmq
1717

1818
before_install:
19-
- sudo apt-get install -qq libevent-dev libpq-dev
19+
- sudo apt-get install -qq libpq-dev
2020

2121
install:
2222
- pip install -r dev_requirements.txt coveralls --use-mirrors

Berksfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source "http://api.berkshelf.com"
1+
site :opscode
22

33
cookbook 'apt'
44
cookbook 'rsyslog'

Berksfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"dependencies": {
2+
"sources": {
33
"apt": {
44
"locked_version": "2.3.0"
55
},
@@ -10,9 +10,9 @@
1010
"locked_version": "2.2.2"
1111
},
1212
"deis": {
13-
"locked_version": "0.2.1",
13+
"locked_version": "0.3.0",
1414
"git": "https://github.com/opdemand/deis-cookbook.git",
15-
"ref": "a2698641d2042a3626df5874763ab6535ee2892b"
15+
"ref": "cb7ea38a10be3ac9f80a412f81cdc23ce0337c0e"
1616
}
1717
}
1818
}

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ source 'https://rubygems.org'
22

33
gem 'chef'
44
gem 'foodcritic'
5-
gem 'berkshelf', '3.0.0.beta3' # needed for --ssl-verify=false support
5+
#gem 'berkshelf', '3.0.0.beta3' # needed for --ssl-verify=false support
6+
gem "berkshelf", "~> 2.0.10"
67

78
gem 'knife-ec2'
89
gem 'knife-rackspace'

Gemfile.lock

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4+
activesupport (3.2.16)
5+
i18n (~> 0.6, >= 0.6.4)
6+
multi_json (~> 1.0)
47
addressable (2.3.5)
58
akami (1.2.0)
69
gyoku (>= 0.4.0)
710
nokogiri (>= 1.4.0)
8-
berkshelf (3.0.0.beta3)
11+
berkshelf (2.0.10)
12+
activesupport (~> 3.2.0)
913
addressable (~> 2.3.4)
10-
buff-config (~> 0.2)
11-
buff-extensions (~> 0.4)
1214
buff-shell_out (~> 0.1)
15+
chozo (>= 0.6.1)
1316
faraday (>= 0.8.5)
1417
hashie (>= 2.0.2)
1518
minitar (~> 0.5.4)
19+
rbzip2 (~> 0.2.0)
1620
retryable (~> 1.3.3)
17-
ridley (~> 1.6)
18-
solve (>= 0.8.0)
21+
ridley (~> 1.5.0)
22+
solve (>= 0.5.0)
1923
thor (~> 0.18.0)
2024
buff-config (0.4.0)
2125
buff-extensions (~> 0.3)
2226
varia_model (~> 0.1)
2327
buff-extensions (0.5.0)
24-
buff-ignore (1.1.0)
28+
buff-ignore (1.1.1)
2529
buff-ruby_engine (0.1.0)
2630
buff-shell_out (0.1.1)
2731
buff-ruby_engine (~> 0.1.0)
2832
builder (3.2.2)
29-
celluloid (0.15.2)
30-
timers (~> 1.1.0)
31-
celluloid-io (0.15.0)
32-
celluloid (>= 0.15.0)
33-
nio4r (>= 0.5.0)
33+
celluloid (0.14.1)
34+
timers (>= 1.0.0)
35+
celluloid-io (0.14.1)
36+
celluloid (>= 0.14.1)
37+
nio4r (>= 0.4.5)
3438
chef (11.6.2)
3539
erubis (~> 2.7)
3640
highline (~> 1.6, >= 1.6.9)
@@ -45,6 +49,10 @@ GEM
4549
ohai (>= 0.6.0, < 7.0.0)
4650
rest-client (>= 1.0.4, < 1.7.0)
4751
yajl-ruby (~> 1.1)
52+
chozo (0.6.1)
53+
activesupport (>= 3.2.0)
54+
hashie (>= 2.0.2)
55+
multi_json (>= 1.3.0)
4856
digital_ocean (1.2.0)
4957
faraday (~> 0.8.7)
5058
faraday_middleware (~> 0.9.0)
@@ -84,21 +92,22 @@ GEM
8492
httpclient (2.3.4.1)
8593
httpi (0.9.7)
8694
rack
95+
i18n (0.6.9)
8796
ipaddress (0.8.0)
8897
json (1.7.7)
89-
knife-digital_ocean (0.2.0)
98+
knife-digital_ocean (0.3.0)
9099
chef (>= 10.18)
91100
digital_ocean (~> 1.2.0)
92101
highline
93102
knife-ec2 (0.6.6)
94103
chef (>= 0.10.10)
95104
fog (~> 1.15.0)
96105
knife-windows (>= 0.5.12)
97-
knife-rackspace (0.8.1)
106+
knife-rackspace (0.8.4)
98107
chef (>= 0.10.10)
99108
fog (~> 1.12)
100109
knife-windows
101-
knife-windows (0.5.12)
110+
knife-windows (0.5.14)
102111
em-winrm (= 0.5.4)
103112
little-plugger (1.1.3)
104113
logging (1.8.1)
@@ -112,7 +121,7 @@ GEM
112121
mixlib-cli (1.3.0)
113122
mixlib-config (1.1.2)
114123
mixlib-log (1.6.0)
115-
mixlib-shellout (1.2.0)
124+
mixlib-shellout (1.3.0)
116125
multi_json (1.8.2)
117126
multipart-post (1.2.0)
118127
net-http-persistent (2.9)
@@ -139,24 +148,26 @@ GEM
139148
rack (1.5.2)
140149
rash (0.4.0)
141150
hashie (~> 2.0.0)
151+
rbzip2 (0.2.0)
142152
rest-client (1.6.7)
143153
mime-types (>= 1.16)
144154
retryable (1.3.3)
145-
ridley (1.7.1)
155+
ridley (1.5.3)
146156
addressable
147157
buff-config (~> 0.2)
148158
buff-extensions (~> 0.3)
149159
buff-ignore (~> 1.1)
150160
buff-shell_out (~> 0.1)
151-
celluloid (~> 0.15)
152-
celluloid-io (~> 0.15)
161+
celluloid (~> 0.14.0)
162+
celluloid-io (~> 0.14.0)
153163
erubis
154164
faraday (>= 0.8.4)
155165
hashie (>= 2.0.2)
156166
json (>= 1.7.7)
157167
mixlib-authentication (>= 1.3.0)
158168
net-http-persistent (>= 2.8)
159169
net-ssh
170+
nio4r (>= 0.5.0)
160171
retryable
161172
solve (>= 0.4.4)
162173
varia_model (~> 0.1)
@@ -171,7 +182,7 @@ GEM
171182
nokogiri (>= 1.4.0)
172183
nori (~> 1.0)
173184
wasabi (~> 1.0)
174-
solve (0.8.1)
185+
solve (0.8.2)
175186
systemu (2.5.2)
176187
thor (0.18.1)
177188
timers (1.1.0)
@@ -195,7 +206,7 @@ PLATFORMS
195206
ruby
196207

197208
DEPENDENCIES
198-
berkshelf (= 3.0.0.beta3)
209+
berkshelf (~> 2.0.10)
199210
chef
200211
foodcritic
201212
knife-digital_ocean

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ all:
33

44
db:
55
python manage.py syncdb --noinput
6-
python manage.py migrate
6+
python manage.py migrate --noinput
77

88
test:
9-
python manage.py test api cm provider web
9+
python -Wall manage.py test --noinput api cm provider web
1010

1111
coverage:
12-
coverage run manage.py test api cm provider web
12+
coverage run manage.py test --noinput api cm provider web
1313
coverage html
1414

1515
test_client:
16-
python -m unittest discover client.tests
16+
python -Wall -m unittest discover client.tests
1717

1818
flake8:
1919
flake8

api/migrations/0001_initial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
import datetime
2+
from south.utils import datetime_utils as datetime
33
from south.db import db
44
from south.v2 import SchemaMigration
55
from django.db import models
@@ -415,15 +415,15 @@ def backwards(self, orm):
415415
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
416416
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
417417
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
418-
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
418+
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
419419
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
420420
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
421421
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
422422
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
423423
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
424424
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
425425
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
426-
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
426+
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
427427
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
428428
},
429429
u'contenttypes.contenttype': {

api/models.py

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def delete(self, *args, **kwargs):
8383
self.owner.publish()
8484

8585

86-
@python_2_unicode_compatible
8786
class ProviderManager(models.Manager):
8887
"""Manage database interactions for :class:`Provider`."""
8988

@@ -126,7 +125,6 @@ def __str__(self):
126125
return "{}-{}".format(self.id, self.get_type_display())
127126

128127

129-
@python_2_unicode_compatible
130128
class FlavorManager(models.Manager):
131129
"""Manage database interactions for :class:`Flavor`."""
132130

@@ -187,19 +185,33 @@ def flat(self):
187185
'nodes': self.nodes}
188186

189187
def build(self):
190-
tasks.build_formation.delay(self).wait()
188+
return
191189

192190
def destroy(self, *args, **kwargs):
193-
tasks.destroy_formation.delay(self).wait()
191+
app_tasks = [tasks.destroy_app.si(a) for a in self.app_set.all()]
192+
node_tasks = [tasks.destroy_node.si(n) for n in self.node_set.all()]
193+
layer_tasks = [tasks.destroy_layer.si(l) for l in self.layer_set.all()]
194+
group(app_tasks + node_tasks).apply_async().join()
195+
group(layer_tasks).apply_async().join()
196+
CM.purge_formation(self.flat())
197+
self.delete()
198+
tasks.converge_controller.apply_async().wait()
194199

195200
def publish(self):
196201
data = self.calculate()
197202
CM.publish_formation(self.flat(), data)
198203
return data
199204

200-
def converge(self, **kwargs):
205+
def converge(self, controller=False, **kwargs):
201206
databag = self.publish()
202-
tasks.converge_formation.delay(self).wait()
207+
nodes = self.node_set.all()
208+
subtasks = []
209+
for n in nodes:
210+
subtask = tasks.converge_node.si(n)
211+
subtasks.append(subtask)
212+
if controller is True:
213+
subtasks.append(tasks.converge_controller.si())
214+
group(*subtasks).apply_async().join()
203215
return databag
204216

205217
def calculate(self):
@@ -292,7 +304,6 @@ def destroy(self):
292304
return tasks.destroy_layer.delay(self).wait()
293305

294306

295-
@python_2_unicode_compatible
296307
class NodeManager(models.Manager):
297308

298309
def new(self, formation, layer, fqdn=None):
@@ -462,10 +473,11 @@ def build(self):
462473
Release.objects.create(
463474
version=1, owner=self.owner, app=self, config=config, build=build)
464475
self.formation.publish()
465-
tasks.build_app.delay(self).wait()
466476

467477
def destroy(self):
468-
tasks.destroy_app.delay(self).wait()
478+
CM.purge_app(self.flat())
479+
self.delete()
480+
self.formation.publish()
469481

470482
def publish(self):
471483
"""Publish the application to configuration management"""
@@ -519,6 +531,7 @@ def logs(self):
519531

520532
def run(self, command):
521533
"""Run a one-off command in an ephemeral app container."""
534+
# TODO: add support for interactive shell
522535
nodes = self.formation.node_set.filter(layer__runtime=True).order_by('?')
523536
if not nodes:
524537
raise EnvironmentError('No nodes available to run command')
@@ -527,17 +540,13 @@ def run(self, command):
527540
# prepare ssh command
528541
version = release.version
529542
docker_args = ' '.join(
530-
['-v',
531-
'/opt/deis/runtime/slugs/{app_id}-{version}/app:/app'.format(**locals()),
532-
release.build.image])
533-
base_cmd = "export HOME=/app; cd /app && for profile in " \
534-
"`find /app/.profile.d/*.sh -type f`; do . $profile; done"
535-
command = "/bin/sh -c '{base_cmd} && {command}'".format(**locals())
543+
['-a', 'stdout', '-a', 'stderr',
544+
'-v', '/opt/deis/runtime/slugs/{app_id}-v{version}:/app'.format(**locals()),
545+
'deis/slugrunner'])
536546
command = "sudo docker run {docker_args} {command}".format(**locals())
537547
return node.run(command)
538548

539549

540-
@python_2_unicode_compatible
541550
class ContainerManager(models.Manager):
542551

543552
def scale(self, app, structure, **kwargs):
@@ -733,7 +742,7 @@ def push(cls, push):
733742
# create the build
734743
new_build = cls.objects.create(**push)
735744
# send a release signal
736-
release_signal.send(sender=push, build=new_build, app=app, user=user)
745+
release_signal.send(sender=user, build=new_build, app=app, user=user)
737746
# see if we need to scale an initial web container
738747
if len(app.formation.node_set.filter(layer__runtime=True)) > 0 and \
739748
len(app.container_set.filter(type='web')) < 1:

api/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class AppSerializer(serializers.ModelSerializer):
160160

161161
owner = serializers.Field(source='owner.username')
162162
id = serializers.SlugField(default=utils.generate_app_name)
163-
formation = OwnerSlugRelatedField(slug_field='id')
163+
formation = OwnerSlugRelatedField(slug_field='id', required=False)
164164

165165
class Meta:
166166
"""Metadata options for a :class:`AppSerializer`."""

0 commit comments

Comments
 (0)