Skip to content

Commit 938a926

Browse files
committed
Merged three projects into one.
0 parents  commit 938a926

252 files changed

Lines changed: 25871 additions & 0 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
local_settings.py
2+
venv/
3+
.vagrant

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2013 OpDemand LLC
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
all:
2+
python manage.py runserver
3+
4+
db:
5+
python manage.py syncdb --noinput
6+
7+
test:
8+
python manage.py test api web
9+
10+
task:
11+
python manage.py test celerytasks
12+
13+
pep8:
14+
pep8 api celerytasks deis web
15+
16+
pyflakes:
17+
pyflakes api celerytasks deis web

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn_django -c gconfig.py

README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
deis-controller
2+
===============
3+
4+
**Deis** is an open source *platform-as-a-service* (PaaS) for public and
5+
private clouds.
6+
7+
Take your agile development to the next level. Free your mind and focus on
8+
your code. Deploy updates to local metal or worldwide clouds with
9+
```git push```. Scale servers, processes, and proxies with a simple command.
10+
Enjoy the *twelve-factor app* workflow while keeping total control.
11+
12+
The [opdemand/deis-controller](https://github.com/opdemand/deis-controller)
13+
project contains the RESTful API server. To set up your own private application
14+
platform, the [deis-chef](https://github.com/opdemand/deis-chef) and
15+
[deis](https://github.com/opdemand/deis) projects are also required.
16+
17+
18+
Getting Started
19+
---------------
20+
21+
First, make a clone of the
22+
[deis-controller](https://github.com/opdemand/deis-controller)
23+
github repository:
24+
25+
git clone https://github.com/opdemand/deis-controller.git
26+
27+
This will create a **deis-controller** directory with the current code
28+
and documentation. Change your current directory to the new project:
29+
30+
cd deis-controller
31+
32+
Create a file for local application settings:
33+
34+
touch deis/local_settings.py
35+
36+
Edit this new `deis/local_settings.py` file in a text editor, adding
37+
the following section:
38+
39+
# This is just an example for Sqlite3.
40+
DATABASES = {
41+
'default': {
42+
'ENGINE': 'django.db.backends.sqlite3',
43+
'NAME': 'deis.db',
44+
'USER': '',
45+
'PASSWORD': '',
46+
'HOST': '',
47+
'PORT': '',
48+
}
49+
}
50+
51+
Also add a value for SECRET_KEY:
52+
53+
SECRET_KEY = 'atotallysecretkey'
54+
55+
Save these changes to deis/local_settings.py.
56+
57+
You might prefer to create a **virtualenv** to keep the project requirements
58+
separate from other python installations. Assuming you have **virtualenv**
59+
already installed:
60+
61+
virtualenv venv --prompt='(deis)'
62+
source venv/bin/activate
63+
64+
from the deis project root will create a **virtualenv** in the *venv*
65+
directory (which is ignored by `git` version control) and prepend the prompt
66+
**(deis)** to the shell to remind you which environment you're in.
67+
68+
Whether or not you create a **virtualenv**, next use the `pip` tool to
69+
install Django and other necessary python packages:
70+
71+
pip install -U -r requirements.txt
72+
73+
Then create the database tables and indexes:
74+
75+
python manage.py syncdb
76+
77+
Finally, run **Deis** in a test server:
78+
79+
python manage.py runserver
80+
81+
You can simplify **Deis** development by making it your default
82+
Django project. Set an environment variable in your .bashrc, .profile,
83+
or the local equivalent:
84+
85+
export DJANGO_SETTINGS_MODULE=deis.settings
86+
87+
Once you've done that, open a new command shell. You can create the
88+
database tables and indexes with:
89+
90+
make db
91+
92+
And you can run **Deis** in a test server with:
93+
94+
make
95+
96+
97+
License
98+
-------
99+
100+
**Deis** is open source software under the Apache 2.0 license.
101+
Please see the **LICENSE** file in the root directory for details.
102+
103+
104+
Credits
105+
-------
106+
107+
**Deis** rests on the shoulders of leading open source technologies:
108+
109+
* Docker
110+
* Chef
111+
* Django
112+
* Heroku buildpacks
113+
* Gitosis
114+
115+
[OpDemand](http://www.opdemand.com/) sponsors and maintains the
116+
**Deis** project.

Vagrantfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.configure("2") do |config|
5+
6+
config.vm.box = "deis-controller"
7+
config.vm.hostname = "deis-controller"
8+
9+
config.vm.provider :virtualbox do |v|
10+
v.customize ["modifyvm", :id, "--memory", 2048]
11+
end
12+
13+
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
14+
15+
config.vm.network :public_network, :bridge => 'en0: Wi-Fi (AirPort)' #, :mac => "08002769c9a0"
16+
17+
config.vm.provision :shell, :inline => "echo Bootstrap with: knife bootstrap `/sbin/ifconfig eth1|grep inet|head -1|sed 's/\:/ /'|awk '{print $3}'` -x vagrant -P vagrant -N deis-controller -r role[deis-controller] --sudo"
18+
19+
end

api/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
The Deis application programming interface (API).
3+
"""

api/admin.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
"""
2+
Classes to manage the presentation of Deis api models in the django
3+
admin interface.
4+
"""
5+
# pylint: disable=R0903,R0904
6+
7+
from __future__ import unicode_literals
8+
9+
from django.contrib import admin
10+
11+
from api import models
12+
13+
14+
class UuidAdmin(object):
15+
"""Presents a UuidField, ensuring the actual UUID is read-only."""
16+
17+
date_hierarchy = 'updated'
18+
19+
def get_readonly_fields(self, _request, obj=None):
20+
"""Override so once the UUID is set, it's read-only."""
21+
# pylint: disable=E1101
22+
if obj is not None:
23+
return self.readonly_fields + ('uuid',)
24+
else:
25+
return self.readonly_fields
26+
27+
28+
# class SshKeysInline(admin.TabularInline):
29+
# model = models.SshKey.apps.through
30+
31+
32+
# class SshKeyAdmin(admin.ModelAdmin):
33+
34+
# inlines = [SshKeysInline,]
35+
# exclude = ('apps',)
36+
37+
# admin.site.register(models.SshKey, SshKeyAdmin)
38+
#
39+
#
40+
# class InstanceAdmin(admin.ModelAdmin, UuidAdmin):
41+
# """Presents an Instance api model in the Django admin."""
42+
# pass
43+
#
44+
# admin.site.register(models.Instance, InstanceAdmin)
45+
#
46+
#
47+
# class ProcessAdmin(admin.TabularInline, UuidAdmin):
48+
# """Presents a Process api model in the Django admin."""
49+
# model = models.Process
50+
#
51+
#
52+
# class ProxyAdmin(admin.ModelAdmin, UuidAdmin):
53+
# """Presents a Proxy api model in the Django admin."""
54+
# pass
55+
#
56+
# admin.site.register(models.Proxy, ProxyAdmin)
57+
#
58+
#
59+
# class RunAdmin(admin.ModelAdmin, UuidAdmin):
60+
# """Presents a Run api model in the Django admin."""
61+
# inlines = [ProcessAdmin]
62+
#
63+
# admin.site.register(models.Run, RunAdmin)
64+
65+
66+
class BuildAdmin(admin.ModelAdmin, UuidAdmin):
67+
"""Presents a Build api model in the Django admin."""
68+
pass
69+
70+
admin.site.register(models.Build, BuildAdmin)
71+
72+
73+
class ConfigAdmin(admin.ModelAdmin, UuidAdmin):
74+
"""Presents a Config api model in the Django admin."""
75+
76+
admin.site.register(models.Config, ConfigAdmin)
77+
78+
79+
class ReleaseAdmin(admin.ModelAdmin, UuidAdmin):
80+
"""Presents a Release api model in the Django admin."""
81+
pass
82+
83+
admin.site.register(models.Release, ReleaseAdmin)
84+
85+
86+
class AccessAdmin(admin.ModelAdmin, UuidAdmin):
87+
"""Presents an Access api model in the Django admin."""
88+
pass
89+
90+
admin.site.register(models.Access, AccessAdmin)
91+
92+
93+
class EventAdmin(admin.ModelAdmin, UuidAdmin):
94+
"""Presents an Event api model in the Django admin."""
95+
pass
96+
97+
admin.site.register(models.Event, EventAdmin)

api/fields.py

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
"""
2+
Deis API custom fields for representing data in Django forms.
3+
"""
4+
5+
from __future__ import unicode_literals
6+
from uuid import uuid4
7+
8+
from django import forms
9+
from django.db import models
10+
from json_field import JSONField
11+
from yamlfield.fields import YAMLField
12+
13+
14+
class UuidField(models.CharField):
15+
16+
"""A univerally unique ID field."""
17+
# pylint: disable=R0904
18+
19+
description = __doc__
20+
21+
def __init__(self, *args, **kwargs):
22+
kwargs.setdefault('auto_created', True)
23+
kwargs.setdefault('editable', False)
24+
kwargs.setdefault('max_length', 32)
25+
kwargs.setdefault('unique', True)
26+
super(UuidField, self).__init__(*args, **kwargs)
27+
28+
def db_type(self, connection=None):
29+
"""Return the database type for a UuidField."""
30+
db_type = None
31+
if connection and 'postgres' in connection.vendor:
32+
db_type = 'uuid'
33+
else:
34+
db_type = 'char({0})'.format(self.max_length)
35+
return db_type
36+
37+
def pre_save(self, model_instance, add):
38+
"""Initialize an empty field with a new UUID before it is saved."""
39+
value = getattr(model_instance, self.get_attname(), None)
40+
if not value and add:
41+
uuid = str(uuid4())
42+
setattr(model_instance, self.get_attname(), uuid)
43+
return uuid
44+
else:
45+
return super(UuidField, self).pre_save(model_instance, add)
46+
47+
def formfield(self, **kwargs):
48+
"""Tell forms how to represent this UuidField."""
49+
kwargs.update({
50+
'form_class': forms.CharField,
51+
'max_length': self.max_length,
52+
})
53+
return super(UuidField, self).formfield(**kwargs)
54+
55+
56+
class EnvVarsField(JSONField):
57+
58+
"""
59+
A text field that accepts a JSON object, coercing its keys to uppercase.
60+
"""
61+
pass
62+
63+
64+
class DataBagField(JSONField):
65+
"""
66+
A text field that accepts a JSON object, used for storing Chef data bags.
67+
"""
68+
pass
69+
70+
71+
class ProcfileField(JSONField):
72+
"""
73+
A text field that accepts a JSON object, used for Procfile data.
74+
"""
75+
pass
76+
77+
78+
class CredentialsField(JSONField):
79+
"""
80+
A text field that accepts a JSON object, used for storing provider
81+
API Credentials.
82+
"""
83+
pass
84+
85+
86+
class ParamsField(JSONField):
87+
"""
88+
A text field that accepts a JSON object, used for storing provider
89+
API Parameters.
90+
"""
91+
92+
class CloudInitField(YAMLField):
93+
"""
94+
A text field that accepts a YAML object, used for storing cloud-init
95+
boostrapping scripts.
96+
"""
97+
pass
98+
99+
100+
class NodeStatusField(JSONField):
101+
"""
102+
A text field that accepts a YAML object, used for storing cloud-init
103+
boostrapping scripts.
104+
"""
105+
pass
106+
107+
108+
try:
109+
from south.modelsinspector import add_introspection_rules
110+
# Tell the South schema migration tool to handle a UuidField.
111+
add_introspection_rules([], [r'^api\.fields\.UuidField'])
112+
add_introspection_rules([], [r'^api\.fields\.EnvVarsField'])
113+
add_introspection_rules([], [r'^api\.fields\.DataBagField'])
114+
add_introspection_rules([], [r'^api\.fields\.ProcfileField'])
115+
add_introspection_rules([], [r'^api\.fields\.CredentialsField'])
116+
add_introspection_rules([], [r'^api\.fields\.ParamsField'])
117+
add_introspection_rules([], [r'^api\.fields\.CloudInitField'])
118+
add_introspection_rules([], [r'^api\.fields\.NodeStatusField'])
119+
except ImportError:
120+
pass

0 commit comments

Comments
 (0)